MSBuild 目标 _CopyWebApplication 不会将所有必要的文件复制到 bin 文件夹 [英] MSBuild target _CopyWebApplication does not copy all necessary files to the bin folder

查看:22
本文介绍了MSBuild 目标 _CopyWebApplication 不会将所有必要的文件复制到 bin 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Web 的其他地方,您可以找到有关使用类似的东西从命令行模拟 VS 2005-2008 IDE 中的发布功能的建议(我希望我没有弄错语法!):

Elsewhere on the Web, you can find recommendations on using something like this to simulate the Publish feature in the VS 2005-2008 IDE from a command-line (I hope I did not goof up the syntax!):

msbuild /t:ResolveReferences;_CopyWebApplication /p:BuildingProject=true;OutDir=C:inetpubwwwroot blah.csproj

现在,.dll 的副本看起来不错.但是,应用程序需要将某些配置文件和模板文件复制到 bin 文件夹中.例如,一个 NHibernate 配置文件在 blah.csproj 中显示为:

Now, it looks like the .dll's copy fine. However, there are certain configuration files and template files that are copied to the bin folder which are needed for the app to work. For example, an NHibernate configuration file shows up in blah.csproj as:

<None Include="blah.cfg.xml">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

虽然在 IDE 中使用 Publish 会按原样复制此文件,但上述 _CopyWebApplication 目标不会.我需要将此文件复制到构建脚本中.这是 _CopyWebApplication 所需的行为吗?有关如何解决此问题的任何建议?

While using Publish from within the IDE copies this file as it should, the aforementioned _CopyWebApplication target does not. I need this file to be copied in the build script. Is this desired behavior for _CopyWebApplication? Any recommendations on how to fix this?

2010 年 4 月 21 日

EDIT 4/21/2010:

让我澄清一下,我们(目前)仅限于 VS 2005 和 VS 2008 项目,并且我们的构建脚本是为 MSBuild 3.x 编写的.我们还没有准备好迁移到 VS 2010.

Let me clarify that we are limited (for now) to VS 2005 and VS 2008 projects, and that our build scripts are written for MSBuild 3.x. We are not yet ready to move to VS 2010.

我还要说明一下,我们正在寻找可在命令行中使用的解决方案,以便我们可以自动执行类似发布的命令以及自定义构建选项,并可能在未来自动执行部署.

Let me also specify that we are looking for a solution available from within a command line so that we can automate a Publish-like command along with custom build options, and possibly automate deployments down the road.

推荐答案

这只是一种解决方法.

在发布网站的构建脚本中,在Web项目本身上运行MSBuild进行发布(Targets="ResolveReferences;_CopyWebApplication")后,我添加了复制操作:

In the build script for publishing Web sites, after running MSBuild on the Web project itself to publish it (Targets="ResolveReferences;_CopyWebApplication"), I added a copy operation:

<Copy SourceFiles="@(ProjectBinFiles)" DestinationFolder="$(StageBin)\%(ProjectBinFiles.RecursiveDir)" />

其中 ProjectBinFiles 是表示源目录中 bin 目录中文件的 Item,StageBin 是表示已发布站点目录中 bin 文件夹的 Property.到目前为止,它似乎有效.

where ProjectBinFiles is an Item representing the files in the bin directory in the source directory, and StageBin is a Property representing the bin folder in the published site's directory. So far, it seems to work.

这篇关于MSBuild 目标 _CopyWebApplication 不会将所有必要的文件复制到 bin 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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