带有Web.config转换的_CopyWebApplication [英] _CopyWebApplication with web.config transformations

查看:99
本文介绍了带有Web.config转换的_CopyWebApplication的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让我的Web应用程序在执行发布版本时自动发布.我正在使用_CopyWebApplication目标执行此操作.我在.csproj文件中添加了以下内容:

I am trying to have my web application automatically Publish when a Release build is performed. I'm doing this using the _CopyWebApplication target. I added the following to my .csproj file:

  <!-- Automatically Publish in Release build. -->
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
  <Target Name="AfterBuild">
    <RemoveDir Directories="$(ProjectDir)..\Output\MyWeb" ContinueOnError="true" />
    <MSBuild Projects="MyWeb.csproj" Properties="Configuration=Release;WebProjectOutputDir=$(ProjectDir)..\Output\MyWeb;OutDir=$(ProjectDir)bin\" Targets="ResolveReferences;_CopyWebApplication" />
  </Target>

这有效,但是有一个问题.此输出与使用Visual Studio中的发布"菜单项时生成的输出之间的区别在于,当使用MSBuild方法时,Web.Release.config转换未应用于Web.config文件.而是复制了Web.config,Web.Release.config和Web.Debug.config.

This works but with one issue. The difference between this output, and the output generated when using the Publish menu item in Visual Studio, is that the Web.Release.config transformation is not applied to the Web.config file when using the MSBuild method. Instead, Web.config, Web.Release.config, and Web.Debug.config are all copied.

任何想法都值得赞赏.

推荐答案

为此,我一直把头撞在墙上.在浏览完MSBuild目标之后,我遇到了一些非常不透明"的东西.

I've been hitting my head against the wall for this. After hiking through the MSBuild targets I've come across something very "opaque".

长话短说:尝试使用新的_WPPCopyWebApplication.它可以在我的机器上工作.由于遗留原因,旧的_CopyWebApplication不支持转换.这就是我要做的:

Long story short: Try using the new _WPPCopyWebApplication. It works on my machine. The old _CopyWebApplication does not support transformations for legacy reasons. This is what I do:

msbuild /t:Rebuild /p:OutDir=..\publish\;Configuration=Release;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False MvcApplication1\MvcApplication1.csproj

# UseWPP_CopyWebApplication = true requires PipelineDependsOnBuild = false

长话短说

看看VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets.错了在第70行中找到_CopyWebApplication.注释为:

Have a look at VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets. It's so wrong. Find _CopyWebApplication in line 70. The comment is:

原始的_CopyWebApplication现在已成为旧版,您仍然可以通过将$( UseWPP_CopyWebApplication )设置为 true 来使用它. 默认情况下,它现在更改为在Microsoft.Web.Publish.targets中使用_WPPCopyWebApplication目标.它允许利用web.config trsnaformation. [所有原文如此]

The original _CopyWebApplication is now a Legacy, you can still use it by setting $(UseWPP_CopyWebApplication) to true. By default, it now change to use _WPPCopyWebApplication target in Microsoft.Web.Publish.targets. It allow to leverage the web.config trsnaformation. [all sic]

哦,哦. UseWPP_CopyWebApplication默认为false(第27行),如果您不想破坏现有的_CopyWebApplication,这是有意义的.因此,将其设置为true实际上将使用VS 2010中引入的新WPP内容.与调用隐藏"目标相比,我更喜欢这样做.

Uh oh. UseWPP_CopyWebApplication defaults to false (line 27) which makes sense if you don't want to break the existing _CopyWebApplication. So setting it to true will actually use the new WPP stuff introduced to VS 2010. I prefer this over calling a "hidden" target.

这篇关于带有Web.config转换的_CopyWebApplication的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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