在 Teamcity 构建步骤中应用 web.config 转换
Apply a web.config transform within a Teamcity Build Step
我正在尝试 运行 team city 上的 MSBuild 任务,该任务也会转换 web.casper.config
文件。
我已经尝试了各种开关,但无法做到这一点。这很可能意味着有不同的方法可以达到我想要的结果(比如发布)。
我试过了:-
/t:TransformWebConfig
/p:TransformWebConfig=true
基本上我想
- 将 website.csproj 构建到自定义目录中
- 然后在 web.casper.config
上应用 web.config 转换
有人能帮忙吗?
似乎可行的一件事(不确定它是否是最好的方法)是在网站的 csproj 文件上添加一个 before/after 构建事件,例如
<Target Name="BeforeBuild">
<Copy SourceFiles="Web.config" DestinationFiles="Web.temp.config"
OverwriteReadOnlyFiles="True" />
<TransformXml Source="Web.temp.config" Transform="Web.$(Configuration).config"
Destination="Web.config" />
</Target>
<Target Name="AfterBuild">
<Copy SourceFiles="Web.temp.config" DestinationFiles="Web.config"
OverwriteReadOnlyFiles="True" />
<Delete Files="Web.temp.config" />
</Target>
这基本上是将web.config复制到web.temp.config,然后使用casper配置进行转换。
Source from SO
我正在尝试 运行 team city 上的 MSBuild 任务,该任务也会转换 web.casper.config
文件。
我已经尝试了各种开关,但无法做到这一点。这很可能意味着有不同的方法可以达到我想要的结果(比如发布)。
我试过了:-
/t:TransformWebConfig
/p:TransformWebConfig=true
基本上我想 - 将 website.csproj 构建到自定义目录中 - 然后在 web.casper.config
上应用 web.config 转换有人能帮忙吗?
似乎可行的一件事(不确定它是否是最好的方法)是在网站的 csproj 文件上添加一个 before/after 构建事件,例如
<Target Name="BeforeBuild">
<Copy SourceFiles="Web.config" DestinationFiles="Web.temp.config"
OverwriteReadOnlyFiles="True" />
<TransformXml Source="Web.temp.config" Transform="Web.$(Configuration).config"
Destination="Web.config" />
</Target>
<Target Name="AfterBuild">
<Copy SourceFiles="Web.temp.config" DestinationFiles="Web.config"
OverwriteReadOnlyFiles="True" />
<Delete Files="Web.temp.config" />
</Target>
这基本上是将web.config复制到web.temp.config,然后使用casper配置进行转换。
Source from SO