问题
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