C# – Build c# 6.0 on TFS 2012

cmsbuildroslyntfs

How can I build a Visual Studio 2015 solution using C# 6.0 Features at a TFS 2012 without installing Visual Studio 2015 on a build agent (using Microsoft Build Tools 2015 RC)

I Already installed MSBuild Tools but I still get exceptions. How can I Tell my build template to use MSBuild 14 (Only for one project)

And why does my TFS 2012 compile async and await (c# 5.0) without any problems while the BuildAgent only has Visual Studio 2012 installed?

I tried changing the ToolPath of my BuildProcessTemplate to MSBuild/14.0/ but I get a build error:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.CSharp.targets (316): "csc2.exe" exited with code -532462766.

Installing the Microsoft.Net.Compilers 1.0.0-rc2 Compilers gives the same error.

If I compile the project using the command line I get the exact same error / although there is no error on my dev machine when using the command line with the exact same arguments.

This is the Exception I get in the command line:

C:\Program Files (x86)\MSBuild\14.0\bin\csc2.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentro.....
     Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
        at System.Collections.Immutable.SecurePooledObject`1.Use[TCaller](TCaller& caller)
        at System.Collections.Immutable.SortedInt32KeyNode`1.Enumerator.PushLeft(SortedInt32KeyNode`1 node)
        at System.Collections.Immutable.SortedInt32KeyNode`1.Enumerator..ctor(SortedInt32KeyNode`1 root)
        at System.Collections.Immutable.ImmutableDictionary`2.Enumerator..ctor(SortedInt32KeyNode`1 root, Builder builder)
        at Microsoft.CodeAnalysis.RuleSet.GetDiagnosticOptionsFromRulesetFile(Dictionary`2 diagnosticOptions, String resolvedPath, IList`1 diagnosticsOpt, CommonMessageProvider messageProviderOpt)
        at Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Parse(IEnumerable`1 args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.CommonParse(IEnumerable`1 args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CommonCompiler..ctor(CommandLineParser parser, String responseFile, String[] args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CSharp.CSharpCompiler..ctor(CSharpCommandLineParser parser, String responseFile, String[] args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc..ctor(String responseFile, String baseDirectory, String[] args)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(String[] args)
        at Microsoft.CodeAnalysis.BuildTasks.BuildClient.RunWithConsoleOutput(String[] args, RequestLanguage language, Func`2 fallbackCompiler)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc2.Main(String[] args)

Best Answer

I used TFS2013 U5, but it will be same:

  • installed VS2015 RTM on BuildServer machine
  • put this into MSBuild arguments in Process part of BuildTemplate

/tv:14.0 /p:GenerateBuildInfoConfigFile=false /p:VisualStudioVersion=14.0

Both compiling and VS-unit tests are now running OK.

Related Topic