WIX安装程序中的配置转换 [英] Config transformation in WIX setup

查看:69
本文介绍了WIX安装程序中的配置转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WIX为我的Web应用程序创建一个MSI设置.这是正确的.我唯一不起作用的是启用标准Web应用程序发布方法的配置转换.

I'm creating a MSI setup with WIX for my Web Application. This works correct. The only thing that I don't get to work is to enabling the config transformation of the standard web application publish method.

我了解您可以为现有目标文件添加using标签.我试图将TransformXml添加到WIX安装程序的项目文件中的AfterBuild Target中,但这不起作用.

I understand that you can add the using tag for existing target files. I try'ed to add the TransformXml to the AfterBuild Target in the project file of the WIX installer but that doesn't work.

<TransformXml Source="Web.Config" Transform="Web.$(Configuration).config" Destination="Web.Config" />

有人可以帮助我吗?

我为此创建了一个名为 WebApplicationWix

I created a test project for this called WebApplicationWix

推荐答案

在您的示例项目中我没有看到任何有关TransformXml的提示.

I didn't see any mention of TransformXml in your example project.

您需要与此类似的代码:

You need code similar to this:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile">
  <CallTarget Targets="TransformWebConfiguration" Condition="Exists('web.$(Configuration).config')"/>
</Target>

<Target Name="TransformWebConfiguration">
  <!-- Generate transformed web configuration -->
  <TransformXml Source="web.config" Destination="web.transformed.config" Transform="web.$(Configuration).config" />
</Target>

一些注意事项:

  1. 在UsingTask元素中检查指向Microsoft.Web.Publishing.Tasks.dll的路径(更改为您的Visual Studio版本)
  2. 在您的示例中,源和目标是相同的;您应该确保目标位置是另一个文件,这样就不会出现文件锁定问题,也不会覆盖您尝试使用转换后的文件进行转换的web.config.
  3. 在Visual Studio 2010中,TransformXml存在文件锁定问题,因此,如果您使用的是2010,请特别注意.

这篇关于WIX安装程序中的配置转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆