Our TFS build server is at version 2012 and I was trying it to compile the C#6 and C#7 code and opt in per project basis. I followed simple steps in c-sharp-6-0-tfs-builds. Sample solution with a single MVC web project worked just fine. Another solution with multiple project worked as well but I noticed in the logs that one of the projects used v4.0.30319\Csc.exe
instead of packages\Microsoft.Net.Compilers.2.0.0-rc4\build\..\tools\csc.exe
. Another solution (MVC Web) that I would like to move to latest version also worked partially i.e. one project (simple class library) compiled fine while the MVC Web project failed.
I have added some debugging statements to track the MSBuild variables and here are the two sets of output from the two projects withing same solution. Solutions compile just fine locally (in VS2015). The msbuild arguments include /tv:14.0 /p:GenerateBuildInfoConfigFile=false /p:VisualStudioVersion=14.0
. I have tried various combinations of no argument, only VisualStudioVersion and so on.
This project is a class library and MSBuild uses the compiler within Microsoft.Net.Compilers package
DebugWriteVariousVariables:
BeforeTargets: CoreResGen
UseSharedCompilation : false
MSBuildThisFileDirectory : C:\Builds\2\MyApp\Sources\MyApp.ServiceFacade\
MSBuildToolsVersion : 14.0
BuildingProject : true
VisualStudioVersion : 14.0
VSToolsPath :
MSBuildBinPath : C:\Program Files (x86)\MSBuild\14.0\bin\amd64
MSBuildExtensionsPath32 : C:\Program Files (x86)\MSBuild
CscToolPath : C:\Builds\2\MyApp\packages\Microsoft.Net.Compilers.2.0.0-rc4\build\..\tools
CscToolExe : csc.exe
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
C:\Builds\2\MyApp\Sources\MyApp\packages\Microsoft.Net.Compilers.2.0.0-rc4\build\..\tools\csc.exe /noconfig /nowarn:1701,1702 ...
This project is MVC Web and MSBuild doesn't use the compiler within Microsoft.Net.Compilers package
DebugWriteVariousVariables:
BeforeTargets: CoreResGen
UseSharedCompilation :
MSBuildThisFileDirectory : C:\Builds\2\MyApp\Sources\MyApp\
MSBuildToolsVersion : 14.0
BuildingProject : true
VisualStudioVersion : 14.0
VSToolsPath : C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0
MSBuildBinPath : C:\Program Files (x86)\MSBuild\14.0\bin\amd64
MSBuildExtensionsPath32 : C:\Program Files (x86)\MSBuild
CscToolPath : C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
CscToolExe :
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 ...
I can see that CscToolPath
is set incorrectly. I have read the content of Microsoft.Net.Compilers.props
but I an unable to see why this is happening. I have read the contents of .csproj files and compared those. The only obvious difference in terms of building the projects seems to be following two includes
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
I can add more debugging statements if needed. What else could I do to troubleshoot and resolve this?