我有一个带有一些代码的项目。我想确定是否使用了 RyuJIT,如果是,则RyuJIT
另写LegacyJIT
。
我写的:
#if RuyJIT
Console.WriteLine("RyuJIT");
#else
Console.WriteLine("LegacyJIT");
#endif
然后我试图定义一个常数。所以我.csproj
在记事本中打开我的并写下以下内容:
<PropertyGroup>
<DefineConstants Condition=" $(TargetFrameworkVersion.Replace('v', '')) >= 4.6 ">RyuJIT</DefineConstants>
</PropertyGroup>
但它不起作用:没有定义常量,因此总是为任何目标框架编译第二行。我究竟做错了什么?如何在构建之间共享这个常量?