这个错误消息是什么意思?我能做些什么来纠正这个问题?

AssemblyInfo.cs退出,代码为9009


这个问题可能是在Visual Studio中的. net解决方案的构建后步骤中发生的。


当前回答

当您缺少使用Microsoft Visual Studio x86工具的一些环境设置时,就会发生这种情况。 因此,尝试在构建后的步骤中添加作为第一个命令:

使用Visual Studio 2010:

call "$(DevEnvDir)..\Tools\vsvars32.bat"

正如@FlorianKoch在评论中提到的,对于VS 2017的使用:

call "$(DevEnvDir)..\Tools\VsDevCmd.bat"

它应该放在任何其他命令之前。 它将为使用Microsoft Visual Studio x86工具设置环境。

其他回答

如果脚本确实做了它需要做的事情,而Visual Studio只是因为错误而困扰你,你可以添加:

exit 0

到你剧本的结尾。

当您缺少使用Microsoft Visual Studio x86工具的一些环境设置时,就会发生这种情况。 因此,尝试在构建后的步骤中添加作为第一个命令:

使用Visual Studio 2010:

call "$(DevEnvDir)..\Tools\vsvars32.bat"

正如@FlorianKoch在评论中提到的,对于VS 2017的使用:

call "$(DevEnvDir)..\Tools\VsDevCmd.bat"

它应该放在任何其他命令之前。 它将为使用Microsoft Visual Studio x86工具设置环境。

Yet another reason: If your pre-build event references another projects bin path and you see this error when running msbuild, but not Visual Studio, then you have to manually arrange the projects in the *.sln file (with a text editor) so that the project you are targeting in the event is built before the event's project. In other words, msbuild uses the order that projects are listed in the *.sln file whereas VS uses knowledge of project dependencies. I had this happen when a tool that creates a database to be included in a wixproj was listed after the wixproj.

对我来说,它发生在一个大型解决方案(~80个项目)中从一个PostSharp版本升级到下一个版本的nuget包之后。 我在预构建事件中有命令的项目有编译器错误。

'cmd'不能被识别为内部或外部命令、可操作程序或批处理文件。 C:\Program Files (x86)\MSBuild\14.0\bin\ Microsoft.Common.CurrentVersion.targets(1249,5):错误MSB3073:命令"cmd /c c:\GitRepos\main\ServiceInterfaces\DEV.Config\PreBuild. config . exe "cmd ServiceInterfaces退出,代码为9009。

PATH变量已损坏,变得太长,与PostSharp.Patterns.Diagnostics相关的多个重复路径。 当我关闭Visual Studio并再次打开它时,问题就解决了。

我在编校Path环境变量时导致了此错误。编辑后,我不小心将Path=添加到路径字符串的开头。使用这样一个格式不正确的路径变量,我无法在命令行上运行XCopy(没有找到命令或文件),Visual Studio拒绝运行构建后步骤,并引用代码9009的错误。

XCopy通常位于c:\ windows \ system32。一旦Path环境变量允许XCopy在DOS提示符下得到解析,Visual Studio就很好地构建了我的解决方案。