I believe the true answer is to use $(TargetDir)
vs $(ProjectDir)$(OutDir)
in "copy To". You don't want to have a mention of $(ProjectDir)
on right side. What if your output is outside of your project folder, may be even different computer. Plus, instead of changing project file in project XML, you can just open properties and in "build events" add this single event
if $(ConfigurationName) == dev copy /y "$(ProjectDir)GLicense_dev" "$(TargetDir)GLicense"
if $(ConfigurationName) == stage copy /y "$(ProjectDir)GLicense_stage" "$(TargetDir)GLicense"
if $(ConfigurationName) == prod copy /y "$(ProjectDir)GLicense_prod" "$(TargetDir)GLicense"
Another way (and this is true Visual Studio solution because it eliminates CMD/Batch coding. The downside in your case, you have 3 different files with the same name in 3 different folders), add your 3 files to a project as content in 3 different folders but file name - same (GLicense
). And pick "Copy Always" in build action. Then in project file XML add Condition=" '$(Configuration)' == 'dev'
on the file itself rather than property group
<None Include="dev\GLicense" Condition=" '$(Configuration)' == 'dev'>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="stage\GLicense" Condition=" '$(Configuration)' == 'stage'>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="prod\GLicense" Condition=" '$(Configuration)' == 'prod'>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>