Automatic copy files to output during application building(在应用程序构建期间自动复制文件到输出)
问题描述
C# 项目中的文件有Copy to Output Directory 属性.但是在 VC++ 项目中它是不存在的.我知道,我可以在 VC++ 中使用 Build events 并在那里编写类似
There is Copy to Output Directory property for files in C# projects. But in VC++ projects it is absent. I know, that I can use Build events in VC++ and write there something like
xcopy /y /d %(FullPath) $(OutDir)
有没有办法避免使用 CMD(和其他脚本方法)?在这种情况下,msbuild 可以提供帮助吗?
Is there a way to avoid the use of CMD (and other scripting methods)? Can msbuild do something to help in this case?
推荐答案
这取决于您使用的 Visual Studio 版本.Visual Studio 2008 中的 VC++ 项目文件格式不是 MSBuild,因此在 PostBuildStep 中使用 xcopy 是一个不错的选择.
It depends on what version of Visual Studio you are using. Format of VC++ project file in Visual Studio 2008 is not MSBuild and so using xcopy in PostBuildStep is a good choice.
Visual Studio 2010 中的 VC++ 项目具有 MSBuild 格式.因此,就有了 MSBuild Copy 任务的功能.
VC++ project in Visual Studio 2010 has MSBuild format. Thus, there is functionality of MSBuild Copy task.
以下是示例:
<Copy
SourceFiles="%(FullPath)"
DestinationFolder="$(OutDir)"
/>
如果目标目录不存在,则自动创建
If the destination directory does not exist, it is created automatically
MSDN Copy 任务参考位于此处
An MSDN Copy task reference is here
这篇关于在应用程序构建期间自动复制文件到输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在应用程序构建期间自动复制文件到输出
基础教程推荐
- CString 到 char* 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
