_CopyWebApplication 与 web.config 转换 [英] _CopyWebApplication with web.config transformations

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

问题描述

我正在尝试让我的 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)MicrosoftVisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets" />
  <Target Name="AfterBuild">
    <RemoveDir Directories="$(ProjectDir)..OutputMyWeb" ContinueOnError="true" />
    <MSBuild Projects="MyWeb.csproj" Properties="Configuration=Release;WebProjectOutputDir=$(ProjectDir)..OutputMyWeb;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 MvcApplication1MvcApplication1.csproj

# UseWPP_CopyWebApplication = true requires PipelineDependsOnBuild = false

长篇大论:

查看 VisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets.大错特错.在第70行找到_CopyWebApplication.注释为:

Have a look at VisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets. It's so wrong. Find _CopyWebApplication in line 70. The comment is:

原来的 _CopyWebApplication 现在是 Legacy,您仍然可以通过将 $(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.

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

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