Billy ONeal
Billy ONeal

Reputation: 106530

How can I have MSBuild always mark a target out of date on build?

I have some unit tests in a Google Test project. I want to run these tests as part of my msbuild script. I've added the following to my vcxproj file:

<Target Name="AfterBuild">
  <Exec Command="&quot;$(TargetPath)&quot;"
        IgnoreExitCode="true"
        IgnoreStandardErrorWarningFormat="true"
        CustomWarningRegularExpression=": error:"/>
</Target>

Unfortunately, since there are no inputs or outputs for Exec, it only runs once, and never causes the vcxproj itself to be marked out of date.

How can I force this Exec to always be out of date (so that it runs every build)?

Upvotes: 2

Views: 308

Answers (1)

dkrikun
dkrikun

Reputation: 1328

You can add DependsOnTargetsattribute w/ dependency on the vcxproj that contains code to be tested. That way, each time the code is updated and built, your unit tests will execute.

Upvotes: 1

Related Questions