.NET Core 项目添加条件编译变量

2020年11月23日 3988点热度 1人点赞 3条评论
内容纲要

.NET Core 项目添加条件编译变量,可在 .csproj 中加上

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
  </PropertyGroup>

表名条件变量在 Debug 还是 Release 条件下使用。

然后使用 DefineConstants 定义条件:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DefineConstants>TRACE</DefineConstants>
  </PropertyGroup>

痴者工良

高级程序员劝退师

文章评论

  • 痴者工良

    在项目编译前或编译后执行命令:

        <Target Name="ClientBuild" BeforeTargets="BeforeBuild">
            <Exec WorkingDirectory="ClientApp" Command="npm install"/>
            <Exec WorkingDirectory="ClientApp" Command="npm run build"/>
        </Target>
    

    2022年8月3日
  • 痴者工良

    利害

    2021年3月9日