18

I'm trialing the new features of C# 6.0 within Visual Studio 2015 CTP and my project is failing to build in TFS 2013 and Visual Studio Online.

I understand that Visual Studio uses the new Roslyn compiler, which replaces the native .NET one, and the TFS build agent therefore is unable to compile.

My question is how do I install Roslyn on the build agent (and within Visual Studio Online) and tell the build agent to use this compiler over native?

Ed Blankenship
  • 5,177
  • 1
  • 29
  • 31
Chris Pickford
  • 7,759
  • 4
  • 41
  • 65
  • You probably can't install anything on VS online. – i3arnon Feb 02 '15 at 22:13
  • I read somewhere I can spin up an Azure VM to host a build agent. This still leaves me scratching my head on how to get it to use Roslyn. – Chris Pickford Feb 02 '15 at 22:17
  • Then you probably can point the agent to build with your VS 2015 CTP tools ([I know it can be done in TeamCity](http://stackoverflow.com/a/19351747/885318)) – i3arnon Feb 02 '15 at 22:21

3 Answers3

12

For the compilation step, you have a couple of options:

  1. You can reference the Microsoft.Net.Compilers NuGet package on a per-project basis to use that version of the compilers.
  2. You can install the Microsoft Build Tools package that is part of the VS 2015 CTP package without installing all of VS.

However, as @MrHinsh notes, these approaches may leave you missing other parts of your toolchain.

Kevin Pilch
  • 11,179
  • 1
  • 36
  • 39
3

If you create an Azure VM with Server 2012 r2 and install Visual Studio 2015 CTP and TFS 2013 Build you can connect it to VSO.

You should then be able to complete your build and it will automatically use the new compiler.

While you can just install the compilers there is more to building than just compiling. You will likely very quickly need other features of Visual Studio, like Unit Testing, to execute as part of your build. Your build agent should reflect your developer standard workstation. If your Devs need it then the agent likley needs it.

Note: Visual Studio is licensed to individuals and not by machine. There is no license needed to run it on a build agent. Indeed as long as you have a single licence registered to your or of a particular level, say Ultimate, then you can install that on every build server.

  • 1
    Right, the Roslyn compilers are installed by the build tools MSI that are part of VS2015, but can be installed separately. Alternatively, you an change the compilers on a per project basis using http://www-1.nuget.org/packages/Microsoft.Net.Compilers/ – Kevin Pilch Feb 03 '15 at 03:13
  • You do NOT have to install Visual Studio to get the C# and VB compilers in VS2013 or VS2015. The Build tools package is designed for installation on build machines without a VS license. – Kevin Pilch Feb 03 '15 at 16:40
  • 1) you don't need a VS licence to install VS on a build server. Your licence covers it. 2) compiling is just one part of building. You should be running tests and packaging at the least. – MrHinsh - Martin Hinshelwood Feb 03 '15 at 18:52
  • @KevinPilch-Bisson Thanks for your NuGet suggestion, this seems to get the project to compile on the build agent! If you'd like to add this as an answer I will accept. I do however now have issues when it tries to run the unit tests - `Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Utilities, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.` – Chris Pickford Feb 03 '15 at 20:29
  • Now install Visual Studio. – MrHinsh - Martin Hinshelwood Feb 04 '15 at 07:51
  • 1) You can either install the 2015 build tools or VS2015. I did both 2) You need to use a different build definition that uses the new tools - I used TfvcTemplate.12.xaml - see http://stackoverflow.com/questions/32659106/tfs-2013-building-net-4-6-c-sharp-6-0?rq=1 – Quango Sep 28 '15 at 09:01
0

Used /tv:14.0 /p:GenerateBuildInfoConfigFile=false /p:VisualStudioVersion=14.0 in MSBuild arguments in Process section of BuildTemplate.

Jiří Zídek
  • 354
  • 2
  • 6
  • 1
    Tested this configuration and it does not work. You need to use a different build definition - see http://stackoverflow.com/questions/32659106/tfs-2013-building-net-4-6-c-sharp-6-0?rq=1 – Quango Sep 28 '15 at 09:01
  • with TfvcTemplate.12.xaml the /tv:14.0 Parameter is enough. see http://stackoverflow.com/a/32662291/1196586 – gReX Oct 20 '15 at 14:00