MSBuild Target that always runs when clicking build in VS2013
Asked Answered
G

2

1

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?

Griffey answered 3/7, 2014 at 0:26 Comment(2)
What language? For c++ for example I doubt this is possible: it seems msbuild is not even invoked when all files are up-to-date, let alone you can run a target. If you don't need project specific things you could write an extension that hooks in the build click event.Canaan
It's a web application project. I answered below.Griffey
G
5

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>

Griffey answered 10/7, 2014 at 10:7 Comment(1)
Since I had to look it up... <DisableFastUpToDateCheck> needs to be in a <PropertyGroup>Javed
D
0

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

Drupelet answered 3/7, 2014 at 0:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.