Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda