3

I am maintaining my user displayed application version numbers in an app.ver file that is deployed with my ASP.NET web app. Before publishing the application, I would like to be able to increment the version number in that file.

How can I hook into MSBuild to run a task that would do this incrementing prior to publishing?

Thanks!

  • 1
    Possibly related: http://stackoverflow.com/questions/12899650/why-does-msbuild-ignore-my-beforepublish-target – Nathan Oct 01 '14 at 19:44

2 Answers2

0

In your web project, add a Target that executes prior to the Publish target using the BeforeTargets target attribute.

<Target Name="PrePublish" BeforeTargets="Publish">
    ...
</Target>
Nicodemeus
  • 4,005
  • 20
  • 23
  • 10
    I tried this. Both BeforeTargets Publish and MSDeployPublish at the end of the .csproj file, neither seem to get called.. – user3325343 Feb 19 '14 at 18:26
0

According to this

<Project>  
    ...  
    <Target Name="BeforePublish">  
        <!-- Insert tasks to run before publish here -->  
    </Target>  
    <Target Name="AfterPublish">  
        <!-- Insert tasks to run after publish here -->  
    </Target>  
</Project>  
Mike Ward
  • 3,211
  • 1
  • 29
  • 42