【发布时间】:2010-12-31 07:30:40
【问题描述】:
我正在尝试让我的 Web 应用程序在执行发布构建时自动发布。我正在使用 _CopyWebApplication 目标执行此操作。我将以下内容添加到我的 .csproj 文件中:
<!-- 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。
感谢任何想法。
【问题讨论】: