如何在 Visual Studio 2008 中创建自定义清理(清理后)事件?

2023-12-03C/C++开发问题
4

本文介绍了如何在 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 中创建自定义清理(清理后)事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&amp;()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6