22
votes

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)
4
Do you have the .NET Framework 4.6RC installed on the Build server?jessehouwing
no do I need to ? the solution is working with .net 4.5, and the .net 4.6 RC is a in place upgrade potentialy breaking other stuff on the Serverquadroid
Try /p:VisualStudioVersion=14.0 as the MSBuild arguments.Daniel Mann
@DanielMann error remains.quadroid
Any success on this? I'm having the same problem (TFS build 2013, .NET Framework 4.6) and this MoFo doesn't use C#6 compiler anyway.picrap

4 Answers

17
votes

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.

5
votes

Try using either

/p:VisualStudioVersion=14.0

or

/tv:14 

In your build arguments

2
votes

The answer by Jiří Zídek is correct but it was missing one crucial detail. I had to do the following to get things working on TFS 2012 Update 2:

  1. install Visual Studio 2015 on the build server
  2. set the MSBuild Arguments in the build definition to /p:VisualStudioVersion=14.0 (i.e. Visual Studio 2015 mode)
  3. in each project that uses C# 6 syntax, install the NuGet package Microsoft.Net.Compilers install-package Microsoft.Net.Compilers

It was #3 that made the difference for me.

0
votes

For those of you using TFS 2012 and VS 2017 bypassing 2015, you can follow my answer on enter link description here

TFS 2012 and VS 2017 continuous integration build