我正在尝试在Release构建时自动发布我的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>
这个方法可以使用,但存在一个问题。使用 MSBuild 方法时生成的输出与使用 Visual Studio 的“发布”菜单项生成的输出之间的区别在于,Web.Release.config 转换未应用于 Web.config 文件。 相反,复制了 Web.config、Web.Release.config 和 Web.Debug.config。
欢迎任何想法。
/p:OutDir=..\publish\
重定向构建输出文件时,这也有助于解决编译TypeScript文件的问题。 - Kris McGinnes