在应用程序构建期间自动复制文件到输出

2023-03-08C/C++开发问题
1

本文介绍了在应用程序构建期间自动复制文件到输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

这篇关于在应用程序构建期间自动复制文件到输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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