内容纲要
.NET Core 项目添加条件编译变量,可在 .csproj 中加上
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
</PropertyGroup>
表名条件变量在 Debug 还是 Release 条件下使用。
然后使用 DefineConstants
定义条件:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
文章评论
在项目编译前或编译后执行命令:
利害
https://docs.microsoft.com/zh-cn/visualstudio/msbuild/msbuild-conditions?view=vs-2019