受此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
行,该项目将完美加载。