Search code examples
c#csxcsi

I need a CSharp script (.csx) runner, like csi.exe, for a build agent machine


I'm writing .csx build scripts. On my local machine I run them with CSharp interactive from visual studio or via C:\Program Files (x86)\MSBuild\14.0\bin\csi.exe. I've tried running .csx scripts on a TeamCity build agent machine (agent machines perform actual build tasks like compilation), which has Microsoft Built Tools 2015 installed. Surprisingly, there was no csi.exe in MSBuild folders.

I'm looking for a way to install csi.exe or a compatible standalone .csx runner on my build agent machines. The options found in Google, like https://github.com/cake-build/cake , all seem to have their distinct flavor of scripts or lots of additional functionality, whereas I'm looking for a csi.exe clone ideally.


Solution

  • Solution turned out to be easy: Roslyn NuGet package contains csi.exe. It will be located at packages\microsoft.net.compilers.2.4.0\tools\csi.exe.

    One thing to note - installation script for the package changes .csproj file to use the compiler provided by the package. This is likely not what you want, so make sure to roll-back such changes if they are made during installation.