因此,我已经安装了 VS 2010,并且正在为 TeamCity 构建集成修改 MSBuild 脚本。除了一个例外,一切都运行良好。
我如何告诉 MSBuild 我想要应用发布构建时创建的 Web.config 转换文件...
我有以下内容,可以生成已编译的网站,但它会将 Web.config、Web.Debug.config 和 Web.Release.config 文件(全部 3 个)输出到已编译的输出目录。在工作室中,当我执行发布到文件系统时,它将进行转换并仅输出经过适当更改的 Web.config...
<Target Name="CompileWeb">
<MSBuild Projects="myproj.csproj" Properties="Configuration=Release;" />
</Target>
<Target Name="PublishWeb" DependsOnTargets="CompileWeb">
<MSBuild Projects="myproj.csproj"
Targets="ResolveReferences;_CopyWebApplication"
Properties="WebProjectOutputDir=$(OutputFolder)$(WebOutputFolder);
OutDir=$(TempOutputFolder)$(WebOutputFolder)\;Configuration=Release;" />
</Target>
任何帮助都会很棒..!
我知道这可以通过其他方式完成,但如果可能的话我想使用新的 VS 2010 方式来完成此操作
我一直在寻找类似的信息,但没有找到,所以我在 Visual Studio 2010 和 MSBuild 4.0 附带的 .targets 文件中进行了一些挖掘。我认为这是寻找执行转换的 MSBuild 任务的最佳位置。
据我所知,使用了以下 MSBuild 任务:
<Project ToolsVersion="4.0"
DefaultTargets="Deploy"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<PropertyGroup>
<ProjectPath>C:\Path to Project\Here</ProjectPath>
<DeployPath>C:\Path to Deploy\There</DeployPath>
<TransformInputFile>$(ProjectPath)\Web.config</TransformInputFile>
<TransformFile>$(ProjectPath)\Web.$(Configuration).config</TransformFile>
<TransformOutputFile>$(DeployPath)\Web.config</TransformOutputFile>
<StackTraceEnabled>False</StackTraceEnabled>
</PropertyGroup>
<Target Name="Transform">
<TransformXml Source="$(TransformInputFile)"
Transform="$(TransformFile)"
Destination="$(TransformOutputFile)"
Condition="some condition here"
StackTrace="$(StackTraceEnabled)" />
</Target>
</Project>
我已经测试了上述内容并可以确认它有效。您可能需要稍微调整结构以更好地适应您的构建脚本。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)