How to create custom clean (post-clean) event in Visual Studio 2008?(如何在 Visual Studio 2008 中创建自定义清理(清理后)事件?)
问题描述
在我们的构建过程中,对于每个项目,我们使用构建后事件将我们的可执行文件复制到单独的部署目录中.这很有效,但问题是我们在执行清理解决方案/清理项目后遇到了陈旧文件的问题.我想设置一个清理"事件来删除复制的文件,而 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
我想找到的是在清理项目时执行任意命令行的某种方法.
What I'd like to find is some way to execute an arbitrary command line when the project is cleaned.
推荐答案
您可以在 csproj 文件中使用 MSBuild 目标语法.例如
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 将作为一个 xml 文件出现在 IDE 中,其中包含有关元素和属性的智能感知.太棒了!)
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!)
自定义目标的完整列表是 此处.
A full list of custom Targets is here.
这篇关于如何在 Visual Studio 2008 中创建自定义清理(清理后)事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Visual Studio 2008 中创建自定义清理(清理后)事件?
基础教程推荐
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
