TFS 2018 构建失败,出现错误 MSB6006:"csc.exe" 退出,代码为 1

TFS 2018 build failing with Error MSB6006: "csc.exe" exited with code 1

我最近构建了一个新的 TFS 2018(更新 3)服务器并添加了 Visual Studio 构建工具 (v15.7.1)。创建一个非常简单的 C# 项目后,服务器构建失败并显示错误 MSB6006:"csc.exe" 已退出,代码为 1。我打开调试并发现了错误

Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (TaskId:32)

我的项目没有引用这个库,我在项目级别关闭了代码分析,所以我认为这是 VS 构建工具的问题。有谁知道解决此问题的解决方法或方法?

我还注意到更新版本的 VS Build Tools (v15.8)。我还没有尝试更新构建服务器,因为生成离线包、压缩、上传等的复杂性很高,但如果找不到短期修复,我将进行下一次努力。

基本上,我们的新服务器在没有解决方案的情况下已经死了,所以我希望这里有人能给出答案,否则,我可能最终会为了更可靠的东西而放弃这一切。

似乎是版本 15.7.1 中的错误。目前尚不清楚是否有任何其他版本受到此错误的影响,但将 VS Build Tools 升级到 15.8.2 解决了该问题。

要发现错误 MSB6006 的根本问题:“csc.exe”以代码 1 退出,请在 MSBuild 参数中设置以下标志:

/v:diag

这将产生类似于以下内容的结果:

2018-08-29T21:07:25.0630293Z                      Task Parameter:WarningLevel=4 (TaskId:23)
2018-08-29T21:07:25.0630927Z                      C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Net.Http.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.Linq.dll" /debug:pdbonly /filealign:512 /optimize+ /out:obj\Release\Epay.Common.Core.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /utf8output Extensions\ObjectExtensions.cs Properties\AssemblyInfo.cs "C:\Windows\TEMP\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" (TaskId:23)
2018-08-29T21:07:25.0631621Z                      Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\Roslyn (TaskId:23)
2018-08-29T21:07:25.5959306Z 16:07:24.786     6>CoreCompile: (TargetId:111)
2018-08-29T21:07:25.5959917Z                      Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (TaskId:63)
2018-08-29T21:07:25.6127920Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(52,5): Error MSB6006: "csc.exe" exited with code 1.
2018-08-29T21:07:25.6128554Z 16:07:25.608     6>C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(52,5): error MSB6006: "csc.exe" exited with code 1. [D:\TfsData\BA01\_work\s\Epay.Common\Security\Security.csproj]
2018-08-29T21:07:25.6141937Z                      Output Item(s): CscCommandLineArgs= (TaskId:63)
2018-08-29T21:07:25.6143738Z                    Done executing task "Csc" -- FAILED. (TaskId:63)