开发者

Can I add a custom "task" to the post-build event of multiple Visual Studio projects?

开发者 https://www.devze.com 2023-02-08 02:13 出处:网络
I have a VS2010 solution with four projects in it. I have a semi-complex command line that I want to run which uses Visual Studio build event macros.

I have a VS2010 solution with four projects in it.

I have a semi-complex command line that I want to run which uses Visual Studio build event macros.

This command line is currently in the post-build event of each project - however the command line is identical in each project, and I'd like to try to keep things DRY.

Is there a way to eliminate the repetition here, somehow set开发者_如何转开发ting up my command line, with macros, as a task somewhere and just call that task for each project?


I dont know if exists any way to link post-build events of different projects, but if you want to get the same effect you have to focus on having at all the .csproj files the same <PropertyGroup> tag, like this:

<PropertyGroup>
    <PostBuildEvent> YOUR COMMAND (With Macros or not) </PostBuildEvent>
</PropertyGroup>

So, you can build a small application that inserts at every .csproj file those tags with the desired command.

Hope helps!

EDIT:

Another (hardly) possibility its to develop your own task inheriting from Task, codig the Execute() method as you wish an then, linking the .dll file at the .csproj

  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
0

精彩评论

暂无评论...
验证码 换一张
取 消