csproj工程文件中有很多xml格式的属性,比如PropertyGroup、ItemGroup,某些属性操作默认是全部的或者是当前编译条件的而已,当我们想指定某些属性只在某个编译条件下发生时就可以通过以下xml属性来指定:

Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" 或者 Condition=" '$(Configuration)' == 'Debug' "

例如,Release和Debug都附带有xml注释文档,则这样解决:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <DocumentationFile>bin\Release\netstandard2.0\XXXX.xml</DocumentationFile>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DocumentationFile>bin\Debug\netstandard2.0\XXXX.xml</DocumentationFile>
  </PropertyGroup>

再例如,你Debug运行需要包含项目文件,即“复制到输出目录”为“如果较新则复制”/“始终复制”,但是Release或发布到生产环境时又不希望包含进去(不包含狗血、乌龙的迭代事件就少了),可以这样做:

<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <None Update="Assets\Xxxx.key">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
</ItemGroup>

 

相关文章:

  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-09-22
  • 2022-02-27
  • 2022-03-04
猜你喜欢
  • 2022-12-23
  • 2021-10-23
  • 2021-11-05
  • 2022-01-26
  • 2022-02-09
相关资源
相似解决方案