Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

244
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda