Reputation: 8049
Somewhat new to MSBuild. I have a folder for robots.txt
that uses the configuration
to copy one of the files to the project's root folder. This is working as expected. However, when I want to run Debug
it can't find the file, b/c obviously I don't need one for debugging. Instead of adding this dummy file, I wanted to exclude it from the build process if the configuration
is one or the other listed, as so:
<Target Name="AfterBuild">
<Copy SourceFiles="Web.temp.config" DestinationFiles="Web.config" OverwriteReadOnlyFiles="True" />
<Delete Files="Web.temp.config" />
<Copy SourceFiles="$(ProjectDir)Content\robots\robots.$(Configuration).txt" Condition="$(Configuration)==Staging" DestinationFiles="robots.txt" OverwriteReadOnlyFiles="True" />
<Copy SourceFiles="$(ProjectDir)Content\robots\robots.$(Configuration).txt" Condition="$(Configuration)==Production" DestinationFiles="robots.txt" OverwriteReadOnlyFiles="True" />
</Target>
You can see above that I have (2) separate <Copy>
elements that are doing the same thing (regarding the robots.txt
files). Can I use an "OR" clause in this? And if so, how? Is there a better way to go about doing this?
Desired approach:
<Copy SourceFiles="$(ProjectDir)Content\robots\robots.$(Configuration).txt" Condition="$(Configuration)==Production || $(Configuration)==Staging" DestinationFiles="robots.txt" OverwriteReadOnlyFiles="True" />
Upvotes: 0
Views: 197
Reputation: 38775
The MSbuild "or clause" is written as Or
not as ||
, otherwise your approach seems fine to me. (fwiw, I'm really not that versed in MSBuild.)
Also, the way I write conditions (though that may be partially cargo cult) is Condition="'$(Bla)' == 'Value'"
, i.e. I quote the values in the condition.
From your q text you also might try Condition="'$(Configuration)' != 'Debug'"
?
Upvotes: 1