c# - TFS 2018 构建失败,错误 MSB6006 : "csc.exe" exited with code 1

标签 c# visual-studio tfs tfsbuild

我最近构建了一个新的 TFS 2018(更新 3)服务器并添加了 Visual Studio 构建工具(v15.7.1)。创建一个非常简单的 C# 项目后,服务器构建失败,并显示 Error MSB6006: "csc.exe"exited with code 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 Studio\2017\BuildTools\MSBuild\15.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 Studio\2017\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 Studio\2017\BuildTools\MSBuild\15.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 Studio\2017\BuildTools\MSBuild\15.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 Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(52,5): error MSB6006: "csc.exe" exited with code 1. [D:\TfsData\BA01\_work\8\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)

关于c# - TFS 2018 构建失败,错误 MSB6006 : "csc.exe" exited with code 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52082106/

相关文章:

tfs - 团队 build 和 Dotfuscator

asp.net - 如何使用 Team Build 部署 ASP.NET Web 应用程序?

c# - c# 中的 Async 和 yield 关键字

c# - 在大量相对较小的文本文档上进行全文搜索的好数据库是什么? (C# 后端)

c++ - 无法在动态链接库中找到过程入口点 clCreateCommandQueueWithProperties

.net - CAT.NET 的现状如何?

c# - 如何检查 ASP.NET Core 3.0 的单元测试中是否记录了错误?

c# - 读取/写入音频/视频文件的元数据

visual-studio - 无法登录 Visual Studio 2017

git - 公开匿名访问本地 TFS2013 git 存储库