【发布时间】:2019-11-15 09:26:57
【问题描述】:
受blog 的启发,我尝试这样实现:
<DefineConstants Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">Windows</DefineConstants>
<DefineConstants Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">POSIX</DefineConstants>
但我收到此错误:
The function "IsOSPlatform" on type "System.Runtime.InteropServices.RuntimeInformation" is not available for execution as an MSBuild property function
有没有办法解决这个问题?没有这两条 DefineConstants 行,项目就可以完美加载。
【问题讨论】:
-
你为什么不按照博客的实际建议使用
设置? -
我累了,它给了我同样的错误。问题是
System.Runtime.InteropServices.RuntimeInformation不可用 -
看起来您正在使用旧版本的 MSBuild 进行构建。您使用的是哪个环境?当前的 msbuild 和工具版本是 16
-
我正在使用
mono。也许与它有关? -
哪个版本的单声道?
标签: c# linux .net-core csproj conditional-compilation