在 Web 上的其他地方,您可以找到有关使用类似方法从命令行模拟 VS 2005-2008 IDE 中的发布功能的建议(我希望我没有弄乱语法!):
msbuild /t:ResolveReferences;_CopyWebApplication /p:BuildingProject=true;OutDir=C:\inetpub\wwwroot\ blah.csproj
现在,它看起来像.dll 的副本很好。但是,应用程序需要将某些配置文件和模板文件复制到 bin 文件夹才能运行。例如,NHibernate 配置文件在 blah.csproj 中显示为:
<None Include="blah.cfg.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
在 IDE 中使用 Publish 时,会按应有的方式复制此文件,但上述 _CopyWebApplication 目标不会。我需要在构建脚本中复制该文件。这是 _CopyWebApplication 所需的行为吗?关于如何解决这个问题有什么建议吗?
编辑 4/21/2010:
让我澄清一下,我们(目前)仅限于 VS 2005 和 VS 2008 项目,并且我们的构建脚本是为 MSBuild 3.x 编写的。我们还没有准备好迁移到 VS 2010。
我还要指出的是,我们正在寻找一种可从命令行使用的解决方案,以便我们可以自动化类似发布的命令以及自定义构建选项,并可能自动化部署路。
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
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>
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?
EDIT 4/21/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.
发布评论
评论(3)
这只是一个解决方法。
在用于发布网站的构建脚本中,在 Web 项目本身上运行 MSBuild 来发布它 (Targets="ResolveReferences;_CopyWebApplication") 后,我添加了一个复制操作:
其中 ProjectBinFiles 是一个 Item,表示源目录,StageBin 是一个属性,表示已发布站点目录中的 bin 文件夹。到目前为止,它似乎有效。
This is just a workaround.
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:
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.
我也有类似的问题。我认为答案是使用 MSDeploy。现在正在调查它,但可能提供所需的功能......
I was having a similar issue as well. I think the answer is using MSDeploy. Investigating it now, but may provide functionality required...
我在 VS 2012 中遇到了同样的问题,并最终通过对需要复制的任何文件执行以下操作来修复它:
I had this same issue in VS 2012 and eventually fixed it by doing the following to any files which needed to be copied: