F# (FSharp) scripts

Hi,

Having nearly 200 DT and 500 projects we start to look for an alternative to powershell.
As we know and use F#, I’ve tried to use F# scripts in octopus.
But it has been a very frustrating experience. Besides a reference to Octopus.tryFindVariable (and 2 more variations) I was unable to find any documentation. (To be honest, I dont know if any sample for c# exists)

Simple (no references) fsx runs - ok.
But when I try to reference type provider I run into problems.
The script that tries to reference nuget packages by “nuget:" fails with:
InstallJson.fsx(1,1): error FS0084: Assembly reference ‘nuget:FSharp.Data’ was not found or is invalid
The script that references my prebuild library with #r "
.dll” fails with runtime errors.
Both versions run without any problem on my local machine (dotnet fsi InstallJson.fsx params)

The questions I’d love to find answered are:
What executes the scripts? What version of FSI? Is it dotnet fsi? Version 5? 4?
Is referencing asseblies from nuget (#r “nuget:…”) supported?
Can I load my own assembiles from package? (#r “Mydll.dll”)
What is that thing You call tryFindVariable on? Preloaded module? Does it have any other methods?

Regards,
Sebastian

Hello Sebastian, welcome!

I’m going to try and answer each of your questions, let me know if you have additional questions or would like clarification:

What executes the scripts? What version of FSI? Is it dotnet fsi? Version 5? 4?

  • It doesn’t use dotnet fsi - it uses the Calamari.win-x64 tool via the Tentacle which contains the older style (full .net framework aka netfx) application - fsi.exe Currently, it looks like version 6.1.670 of the Octopus Tentacle is using version 4.4.0.0 of fsi.exe.

What is that thing You call tryFindVariable on? Preloaded module? Does it have any other methods?

Is referencing asseblies from nuget (#r “nuget:…”) supported?
Can I load my own assembiles from package? (#r “Mydll.dll”)

  • You can reference packages, but there are some limitations - since the Calamari version of fsi is framework, you’ll likely run into issues if your referenced packages are netstandard/netcore compatible only.
  • There is another way to reference packages and use F# in Octopus, but it wouldn’t be as a first class scripting citizen like F# is today. I’d recommend taking a look at this blog which walks through using F# - you can use dotnet fsi as a package, but you’d end up using another scripting language to call your dotnet program once you had it ready.

Thanks for the answers. All clear now.

One more question, though - are there any plans to let us choose which fsi gets to execute the script, similar to the way we can now choose which version of powershell will execute the powershell script?

Regards,

Sebastian

As of right now, that’s not something that’s on the roadmap for F# scripting. However, it has already been raised as an item on our UserVoice site, and you can add your vote and comment there to help better represent the needs for this feature in Octopus going forward.