问题描述
在Web上的其他地方,您可以找到有关使用类似的东西从命令行在VS 2005-2008 IDE中模拟Publish功能的建议(希望我不会弄混语法!)
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:\inetpub\wwwroot\ 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中使用发布"时,应按原样复制此文件,而上述_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?
编辑4/21/2010:
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.
让我还指定,我们正在寻找命令行中可用的解决方案,以便我们可以将类似Publish的命令与自定义构建选项一起自动化,并可能在将来自动进行部署.
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目录中的文件,而StageBin是一个Property,代表发布站点目录中bin文件夹.到目前为止,它似乎可以正常工作.
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文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!