Chris Gessler
Chris Gessler

Reputation: 23113

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

I recently built a new TFS 2018 (update 3) server and added the Visual Studio Build Tools (v15.7.1). After creating a very simple C# project, the server build fails with Error MSB6006: "csc.exe" exited with code 1. I turned on debugging and discovered the error

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)

My project does not reference this library and I have Code Analysis turned off at the project level so I think this is an issue with the VS Build Tools. Does anyone know of a work-around or a way to fix this issue?

I also noticed a newer version of VS Build Tools (v15.8). I have not tried updating the build server yet because the high complexity of generating an offline package, zipping, uploading, etc. but will be my next effort if a short term fix cannot be found.

Basically, our new server is dead without a solution so I'm hoping someone has a answer here, otherwise, I may end up scrapping this all together for something more reliable.

Upvotes: 2

Views: 9763

Answers (1)

Chris Gessler
Chris Gessler

Reputation: 23113

Appears to be a bug in version 15.7.1. It's unclear if any other versions were affected by this bug, but upgrading to VS Build Tools to 15.8.2 resolved the issue.

To discover the underlying issue of Error MSB6006: “csc.exe” exited with code 1, set the following flag in the MSBuild arguments:

/v:diag

This will produce something similar to the following:

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)

Upvotes: 3

Related Questions