Conditional conditional symbol definition in a .csproj file

不问归期 提交于 2019-12-12 04:35:35

问题


I am an experienced C# developer, but a complete beginner when it comes to MSBuild, and now I have a .csproj file containing the following XML snippet:

<Choose>
  <When Condition=" $(UseSimulatedResx) == true ">
    <PropertyGroup>
      <DefineConstants>$(DefineConstants);SIMRESX</DefineConstants>
    </PropertyGroup>
    ... does something else ...
  </When>
</Choose>

Is there way any anyone can explain me how and when the excerpt above should work? Where and when should I issue this UseSimulatedResx?

What I have to do is try to let SIMRESX be a conditional compilation symbol for a project in my solution so as to enable some features of our massive product.

Thank you in advance!


回答1:


The UseSimulatedResx can be set in one of the following ways:

  • as an environment variable
  • as the parameter when invoking msbuild (e.g. /p:UseSimulatedResx=true)
  • in a PropertyGroup (e.g.

    <PropertyGroup> <UseSimulateResx>true</UseSimulateResx> ... </PropertyGroup>

)

If you invoke msbuild with /v:diag (e.g. msbuild myProj.csproj /v:diag) you will get the diagnostic output that shows everything MSBuild does plus all the variable values.



来源:https://stackoverflow.com/questions/42207831/conditional-conditional-symbol-definition-in-a-csproj-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!