TFS 2012, .NET 4.5 and C# 6
· One min read
So, you want to use C# 6 language features and you’re working on an older project that’s still rocking .NET 4.5. Well, with some caveats, you can.
The new compiler will compile targeting older framework versions. Well that’s all lovely; let’s all go home.
Now. What say you’ve got an old, old build server? It’s TFS 2012 Update 2, creaking away, still glad to alive and kind of wondering why it hasn’t been upgraded or retired. This is where you want to compile .NET 4.5 from C# 6. Well it can be done. Here’s how it’s done:
- Install Visual Studio 2015 on the build server (I’m told this can be achieved using Microsoft Build Tools 2015 but I haven’t tried it myelf so caveat emptor)
- set the
MSBuild Arguments
in the build definition to/p:VisualStudioVersion=14.0
(i.e. Visual Studio 2015 mode)
- in each project that uses C# 6 syntax, install the NuGet package Microsoft.Net.Compilers with a quick
install-package Microsoft.Net.Compilers
That’s it; huzzah! String interpolation here I come…