VS2010如何在项目中包含文件,在构建或发布过程中自动将其复制到构建输出目录 [英] VS2010 How to include files in project, to copy them to build output directory automatically during build or publish

查看:297
本文介绍了VS2010如何在项目中包含文件,在构建或发布过程中自动将其复制到构建输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任务是形成Visual Studio 2010项目,以便在任何构建或发布过程中应将某些foo.exe实用程序复制到输出(bin)目录.

Task is to form Visual Studio 2010 project so, that during any build or publish some foo.exe utility should be copied to output (bin) directory.

我很早就在.csproj(MSBuild文件)中创建了PostBuildEvent任务:

Early I have made PostBuildEvent task in .csproj (MSBuild-file):

<PropertyGroup>
  <PostBuildEvent>
    Copy "$(SolutionDir)Tools\foo.exe" "$(ProjectDir)$(OutDir)foo.exe"
  </PostBuildEvent>
</PropertyGroup>

但这不是普遍的.发布期间(Visual Studio 2010)foo.exe出现在bin目录中,但未复制到输出发布目录中.也许我所做的一切完全错误,并且存在标准机制将文件包含在项目中,以便以后在构建或发布期间复制到bin?

But this is not universal. During publishing (Visual Studio 2010) foo.exe appears in bin directory, but is not copied to output publish directory. Maybe I do everything completely wrong and there is standard mechanism to include files in projects to be later, during build or publish, copied to bin?

推荐答案

有,并且不依赖于构建后事件.

There is and it is not dependent on post build events.

将文件添加到项目中,然后在文件属性中,在复制到输出目录"下,选择始终复制"或如果更新则复制".

Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".

请参见 MSDN .

这篇关于VS2010如何在项目中包含文件,在构建或发布过程中自动将其复制到构建输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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