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

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

问题描述

在C#项目中有文件的复制到输出目录属性。但是在VC ++项目中,它不存在。我知道,我可以在VC ++中使用构建事件,并写一些像

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复制任务的功能。

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复制任务参考是此处

An MSDN Copy task reference is here

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

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