Running Roslyn on a Build Server
If like the majority of people you shy away from installing a full blown copy of Visual Studio on your build server (for whatever reason) but you’d like to use it to compile using Roslyn then this can be achieved by following the advice given on this StackOverflow post. The steps I took were as follows:
-
Install the Roslyn End User Preview on the machine you use for developing.
-
Locate the following folder
%userprofile%\AppData\Local\Microsoft\MSBuild\12.0
-
Copy the file
Microsoft.CSharp.Roslyn.targets
from\Microsoft.CSharp.targets\ImportAfter into C:\Program Files (x86)\MSBuild\12.0
on the build server into similarly named folders -
Open up the file
Microsoft.CSharp.Roslyn.targets
and locate the element namedRoslynToolPath
and make a note of it’s value. This is the location of the compiler on your development machine. -
Copy the contents of the folder containing the compiler onto the build server and place it them in a folder that is accessible from the security context under which the build process will be running.
-
Replace the
RoslynToolPath
in theMicrosoft.CSharp.Roslyn.targets
file on the build server with the path into which you have just copied the compiler. -
Repeat for
Microsoft.VisualBasic.Roslyn.targets
if you want to build VB.NET using Roslyn too.