Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

csx

csi

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.

like image 498
Ivan Koshelev Avatar asked Nov 17 '17 21:11

Ivan Koshelev


People also ask

Can you run C# as a script?

Scripting engineC# can be used as a scripting language using the compiler services from Roslyn. This has existed since Visual Studio 2015 Update 1. Canonically C# script files have been written with a . csx extension.

Where is CSI exe?

c:\Program Files (x86)\Microsoft Web Tools\Packages\Microsoft. Net. Compilers. X.Y.Z\tools\csi.exe.

What is CSX C#?

Developer file written in Visual C# Script, a C# API developed by Microsoft under the codename The Roslyn Project; used for developing components in C# that can run on-demand as scripts with the Roslyn framework. The Roslyn program that runs CSX files as scripts is named rcsi.exe.


1 Answers

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.

like image 74
Ivan Koshelev Avatar answered Oct 03 '22 17:10

Ivan Koshelev