C#中的程序化构建事件?

Ver*_*cas 1 .net c# build

这对我来说听起来像幻想,但是我可以在我的项目中创建一个类,在项目构建时运行方法或类似的东西吗?是否有接口或抽象类?

Wie*_*sma 5

您的项目文件由MSBuild文件组成,您可以执行以下任何操作:

http://msdn.microsoft.com/en-us/library/7z253716.aspx

基本上,您可以在Visual Studio中"卸载"项目文件,并使用普通文本编辑器进行编辑.

在*.csproj文件(以及其他一些项目类型中)中查找此区域,请注意并非所有项目文件都是MSBuild兼容文件:

 <!-- 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>
  -->
Run Code Online (Sandbox Code Playgroud)

只需在那里添加你的MSBuild任务:)