2

我有一個帶有一些代碼的項目。我想確定是RyuJIT被使用,如果是的話,然後寫RyuJIT,否則LegacyJIT爲Visual Studio中的所有構建定義一個條件常量

我寫:

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

然後我試圖定義一個常數。所以我在記事本中打開我的.csproj和寫入以下內容:

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

但它不工作:常量沒有定義因此第二線被編譯爲任何目標框架。我究竟做錯了什麼?如何在構建之間分享這個常量?

+0

非常寬廣詞「不工作」 :(:(嘗試添加常數,當它_not_ RyuJIT – Jasper

回答

0

Choose節點解決。另外,現在我可以參考.Net 4.6-only dll。

<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> 

我換成RyuJITSIMD,因爲它更適合

相關問題