user3799698
user3799698

Reputation: 91

MSBuild Target that always runs when clicking build in VS2013

I want to run a target whenever you click build for the project in VS2013. I tried several ways including changing the DefaultTargets of the project to something custom and then have the custom target call my target and then Build. However, the problem is that it only works once. If I run it again, it doesn't seem to run anything.

Is there anyway to do this?

Upvotes: 1

Views: 1694

Answers (2)

user3799698
user3799698

Reputation: 91

I came up with a solution. My major problem was that VS2013 was no longer checking if the files didn't change. I needed to add this to my project file.

   <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>

In my particular case this was a webapp project. There are probably simpler ways, but what I wound up with was this.

I change DefaultTargets in the tag to "CustomBuild"

Then, I created a target like this.

  <Target Name="CustomBuild">
    <CallTarget Targets="<my custom target>" />
    <CallTarget Targets="Build" />
  </Target>

Now, everytime I click build it will run <my custom target>

Upvotes: 6

vmg
vmg

Reputation: 10566

In Visual Studio, open project properties, go to Build Events section and set post-build even command, and select "Always" from the "Run the post-build event:" drop down.

enter image description here

Upvotes: 0

Related Questions