C# 竹子不会为任何自定义生成配置转换Web.config文件
以下是场景: 我有一个网站,它有一个web.config文件以及许多其他特定于环境的配置文件,如web.Staging.config/web.Release.config/web.OnPrem.config 现在,我已经在我的网站项目的csproj文件中配置了BeforeBuild目标:C# 竹子不会为任何自定义生成配置转换Web.config文件,c#,.net,web-config,bamboo,web.config-transform,C#,.net,Web Config,Bamboo,Web.config Transform,以下是场景: 我有一个网站,它有一个web.config文件以及许多其他特定于环境的配置文件,如web.Staging.config/web.Release.config/web.OnPrem.config 现在,我已经在我的网站项目的csproj文件中配置了BeforeBuild目标: <Target Name="BeforeBuild"> <TransformXml Source="Web.config" Transform="Web.$(Configuration
<Target Name="BeforeBuild">
<TransformXml Source="Web.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
</Target>
我在这里遗漏了什么?因为您一次只能为一个活动配置生成,无论您生成的配置是将被替换到$(配置)变量中的配置 我通常做的是:
<?xml version="1.0" encoding="utf-8"?>
<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"/>
<Target Name="Transform">
<TransformXml Source="$(TransformInputFile)"
Transform="$(TransformFile)"
Destination="$(TransformOutputFile)"
StackTrace="$(StackTraceEnabled)" />
</Target>
</Project>
Msbuild.exe /target:Transform "/property:TransformInputFile=path\to\Web.config;TransformFile=path\to\Web.Staging.config;TransformOutputFile=path\to\artefacts\Web.Staging.config" MSBuild.xml
Msbuild.exe /target:Transform "/property:TransformInputFile=path\to\Web.config;TransformFile=path\to\Web.Release.config;TransformOutputFile=path\to\artefacts\Web.Release.config" MSBuild.xml
<?xml version="1.0" encoding="utf-8"?>
<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"/>
<Target Name="Transform">
<TransformXml Source="$(TransformInputFile)"
Transform="$(TransformFile)"
Destination="$(TransformOutputFile)"
StackTrace="$(StackTraceEnabled)" />
</Target>
</Project>