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

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

问题描述

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

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

<PostBuildEvent>复制$(SolutionDir)Toolsfoo.exe"$(ProjectDir)$(OutDir)foo.exe"</PostBuildEvent></PropertyGroup>

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

解决方案

存在且不依赖于构建后事件.

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

请参阅 MSDN.>

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.

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

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

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".

See MSDN.

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

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