在使用 csproj 格式,如果需要给不同的平台设置 PlatformTarget 对应平台的值,需要写比较多的代码,本文告诉大家一个简便的方法
使用三句话就完成了平台设置
<PropertyGroup> <PlatformTarget>$(Platform)</PlatformTarget></PropertyGroup>
上面代码和下面代码是相同的
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PlatformTarget>AnyCPU</PlatformTarget> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'"> <PlatformTarget>x86</PlatformTarget> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PlatformTarget>x64</PlatformTarget> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PlatformTarget>AnyCPU</PlatformTarget> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'"> <PlatformTarget>x86</PlatformTarget> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PlatformTarget>x64</PlatformTarget> </PropertyGroup>

本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。 欢迎转载、使用、重新发布,但务必保留文章署名 林德熙 (包含链接: https://blog.lindexi.com ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请与我 联系。