在应用程序构建期间自动复制文件以输出 [英] Automatic copy files to output during application building

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

问题描述

C# 项目中的文件有复制到输出目录 属性.但在 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

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

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