Bill Kotsias
Bill Kotsias

Reputation: 3368

Cumulative Custom Build Steps in Visual Studio

Is it possible to have cumulative custom build steps in Visual Studio?

What I want to do is have a

if not exist "$(OutDir)" mkdir "$(OutDir)"

as a custom step for ALL configurations (current and possible future ones)

But for a specific configuration (say Deploy) I want to ADDITIONALLY do this

xcopy "$(ProjectDir)..\Resources" "$(OutDir)" /D /E /I /F /Y

Is this possible? I have tried adding a property sheet in Deploy with the xcopy command, but the All Configurations "custom build step" property (with the mkdir command) seems to completely overshadow the xcopy one!

Upvotes: 1

Views: 142

Answers (2)

Bill Kotsias
Bill Kotsias

Reputation: 3368

It seems that you need to have a %(Command) added at the end of EVERY commands list to make the commands inheritable.

Answer found here: https://stackoverflow.com/a/22749337/113718

Having to add an extra "command" feels very hackish, if there is another, better solution, please share.

Upvotes: 0

stijn
stijn

Reputation: 35901

Alternative solution: you can easily have this functionality by using for instance

<Target Name="MyTarget" BeforeTargets="BscMake">
  <Exec Command="xcopy ..."/>
</Target>`

That will run right before BscMake, which is when a custom build step with default options also runs. Or you could also use AfterTargets="CustomBuildStep" to make it run after your CustomBuildStep, etc. Note this method also makes it easy to add more steps without interfering with others.

Upvotes: 1

Related Questions