如何在Visual Studio 2008中创建自定义清理(后清理)事件? [英] How to create custom clean (post-clean) event in Visual Studio 2008?

查看:319
本文介绍了如何在Visual Studio 2008中创建自定义清理(后清理)事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的构建过程中,对于每个项目,我们使用Post Build事件将我们的可执行文件复制到单独的部署目录中。这只是peachy,但问题是,我们在执行清洁解决方案/清洁项目后遇到过时的文件的问题。我想设置一个Clean事件,删除复制的文件,Visual Studio 2008似乎不提供在项目属性页中的选项。

In our build process, for each project we use Post Build events to copy our executable files into a separate deployment directory. That works just peachy, but the problem is that we run into problems with stale files after performing a Clean Solution/Clean Project. I'd like to set up a "Clean" event that deletes the copied file and Visual Studio 2008 does not seem to provide an option in the project properties page.

它具有:

Build Events:
   Pre-Build Event
   Pre-Link Event
   Post-Build Event
Custom Build Step
   General

推荐答案

您可以使用MSBuild目标语法来执行任何命令行。 csproj文件。
例如

You can use the MSBuild target syntax in your csproj file. e.g

  <Target Name="AfterClean">
    <Delete Files="$(OutDir)\$(TargetName).exe" ContinueOnError="true" />
  </Target>

在MSBuild中描述的Visual Studio IDE中直接编辑.csproj文件有一个整洁的方法团队博客,但这是我的第一篇文章,所以我只能包括一个超链接。
(简要地说:卸载项目,然后右键单击它以查看条目编辑[项目] .csproj...您的csproj将在IDE中作为一个xml文件与元素和属性intellisense 。Wonderful!)

There is a neat way to edit your .csproj file directly in the Visual Studio IDE described in the MSBuild team blog, but this is my first post so I can only include one hyperlink. (briefly: Unload the project, then right-click on it to see the entry "Edit [project].csproj" ... your csproj will come up in the IDE as an xml file with intellisense on elements and attributes. Wonderful!)

自定义目标的完整列表在这里:http://blogs.msdn.com/b/msbuild/archive/2005/11/23/496396.aspx

A full list of custom Targets is here: http://blogs.msdn.com/b/msbuild/archive/2005/11/23/496396.aspx

这篇关于如何在Visual Studio 2008中创建自定义清理(后清理)事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆