1

Is it possible to make a portable scriptcs?

I want to write a script and fire it from console/bat file on another machine (with the same OS). I imagine this should look like:

SomeKindOfScriptCsExecutor.exe myscript.csx -param1 -param2

or

MyCompiledScriptAndExportedTo.exe -param1 -param2

Reason: I want to execute scriptcs from Azure WebJobs.

piotrwest
  • 2,098
  • 23
  • 35

2 Answers2

2

As far as I know, you don't need to install anything to use scriptcs.

You can get it via Chocolatey, but you can also get it as a zip file. If you want to use that specific Chocolatey version, just change .nupkg to .zip and you will be able to extract the package.

This allows to run it as:

scriptcs.exe yourScript.xcs

So it can be executed from .cmd or .bat file as:

call scriptcs.exe yourScript.xcs

Note that:

  • at this point, scriptcs does not use the latest version of "Roslyn", so it doesn't have the new C# 6 features
  • for now it is not possible to create a executable file from .xcs file, therefore there is no possibility to run it as MyCompiledScriptAndExportedTo.exe -param1 -param2. See first full discussion and second full discussion
piotrwest
  • 2,098
  • 23
  • 35
Paulo Morgado
  • 14,111
  • 3
  • 31
  • 59
1

Yes you can put all the scriptcs binaries into the bin folder, or a sub-folderand easily deploy them with your webjob. You can also have your webjob pull down our scriptcs.hosting nuget package and run the script directly from your .NET webjob if you prefer. Learn more about hosting here

As to the question of C# 6.0, if you grab our MyGet feed (choco install scriptcs -pre -source https://www.myget.org/F/scriptcsnightly/ ) or clone our dev branch we have updated Roslyn to RC2 which includes full dynamic / async and many of the C# 6.0 features.

Glenn Block
  • 8,463
  • 1
  • 32
  • 34