Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
How to know if .fsx script being run by .NETCore/.NET5 or by legacy framework?

My .fsx scripts are kind of old so they only work with .NET4.x, which means I need to run them with the fsharpi command in macOS.

Now I'm thinking to start migrating them to dotnet fsi; however, ideally I can find a way to run them in both ways for a while, in a transition period.

So I was hoping that, inside them, I could do some kind of conditional code like this:

#if NET5_0
System.Console.WriteLine "we're running in dotnet fsi, yay"
#else
System.Console.WriteLine "we're running with fsharpi, legacy"
#endif

But it doesn't work, surprisingly (and I say surprisingly because the define NET5_0 is being mentioned in many documentation pages). Any other idea of how I could detect this?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think System.Environment.Version will give you the info you need:

if System.Environment.Version.Major >= 5 then
    System.Console.WriteLine "we're running in dotnet fsi, yay"
else
    System.Console.WriteLine "we're running with fsharpi, legacy"

It looks like NET5_0 is only defined for C#.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!