当前位置: 移动技术网 > IT编程>开发语言>.net > 工程文件csproj使用编译条件指定属性

工程文件csproj使用编译条件指定属性

2019年03月29日  | 移动技术网IT编程  | 我要评论

东成西就高清下载,z55次列车,鹿晗 消防员

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>

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网