2

I have a project with some code. I want to determine is RyuJIT is used and if so then write RyuJIT otherwise LegacyJIT.

I write:

#if RuyJIT
            Console.WriteLine("RyuJIT");
#else
            Console.WriteLine("LegacyJIT");
#endif

then I'm trying to define a constant. So i open my .csproj in notepad and write following:

  <PropertyGroup>
    <DefineConstants Condition=" $(TargetFrameworkVersion.Replace('v', '')) &gt;= 4.6 ">RyuJIT</DefineConstants>
  </PropertyGroup>

But it doesn't work: constant is not defined thus second line is always compiled for any target framework. What am I doing wrong? How can I share this constant between builds?

Alex Zhukovskiy
  • 9,565
  • 11
  • 75
  • 151

1 Answers1

0

Solved with Choose node. Additionaly, now I'm able to reference .Net 4.6-only dlls.

  <Choose>
    <When Condition=" $(TargetFrameworkVersion.Replace('v', '')) &gt;= 4.6 ">
      <ItemGroup>
        <Reference Include="System.Numerics" />
        <Reference Include="System.Numerics.Vectors, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <HintPath>..\packages\System.Numerics.Vectors.4.1.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
          <Private>True</Private>
        </Reference>
      </ItemGroup>
      <PropertyGroup>
        <DefineConstants>SIMD</DefineConstants>
      </PropertyGroup>
    </When>
  </Choose>

I replaced RyuJIT with SIMD because it's more suitable

Alex Zhukovskiy
  • 9,565
  • 11
  • 75
  • 151