Visual Studio: Run C++ Project Post-Build Event Even If Project Is Up-To-Date

Visual Studio: Run C++ project Post-Build Event even if project is up-to-date

You can use the Custom Build Step property page to set up a batch file to run. This runs if the File specified in the Outputs setting is not found, or is out-of-date. Simply specify some non-existent file there, and the custom build step will always run. It will run even if your project is up-to-date, since the Output file is never found.

Visual Studio add pre-build event that always runs (C# project)

Here's the solution. Define this property in your project file:

<PropertyGroup>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>

PreBuildStep will then execute every time, regardless of whether the project is or isn't up to date.

It seems that Visual Studio is bypassing normal up-to-date checks of MSBuild and using some sort of custom check that is faster, but has a side effect of breaking customized build targets.

Post-Build Event Works With one Project But Not the Other

You should normalize all your arguments, so they don't contain outer quotes.

Then you can use them in a reliable way.

The syntax set "variable=%~1" avoids outer quotes in the variable itself.

set "TargetDir=%~1"
set "VersionNumber=%~2"
set "TargetFileName=%~3"
set "TargetName=%~4"
SET "productionpath=Z:\IT Support App\"
set "dateStamp=%DATE:~0,2%%DATE:~3,2%%DATE:~6,4%"

MOVE "Z:\IT App\%TargetFileName%" "Z:\IT App\_archive\%TargetName%.%dateStamp%-%VersionNumber%"
XCOPY "%TargetFileName%" "Z:\IT App"

How to run Visual Studio post-build events for debug build only

Pre- and Post-Build Events run as a batch script. You can do a conditional statement on $(ConfigurationName).

For instance

if $(ConfigurationName) == Debug xcopy something somewhere


Related Topics



Leave a reply



Submit