WiX-将基于环境的已编译的web.config复制到网站根目录 [英] WiX - Copy compiled web.config based on environment to website root

查看:68
本文介绍了WiX-将基于环境的已编译的web.config复制到网站根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为WiX安装的一部分,我将所有经过转换/编译的web.config文件复制到安装目录.编译后的web.config的名称格式为web.{ENV} .config.在安装UI中,我创建了一个自定义对话框",在其中解析ENV并填充一个组合框,以便用户可以选择我们要部署到的环境.此comboBox设置属性ENV.

As a part of my WiX installation, I am copying all the transformed/compiled web.config files to the install directory. The names of the compiled web.config are in format web.{ENV}.config. In my install UI I created a Custom Dialog where I parse the ENV and populate a combobox so that the user can select the environment to which we deploy to. This comboBox sets a Property ENV.

我需要了解如何使用此属性将已安装的配置文件复制到网站根目录.

I need to understand how i could use this property to copy the installed config files to the website root.

更新:@Rob_Mensching-您的解决方案有效,但是,在编译时WiX迫使我为每个此类组件创建一个GUID.有什么办法可以避免吗?问题是我将通过对wxs文件运行XSLT来生成这段代码,而wss文件是通过热量生成的.而且我无法使用XSLT生成GUID(或者可以吗?)

Update: @Rob_Mensching - your solution works, however, on compilation WiX forces me to have a GUID created for each such component. Is there a way I could avoid it? The thing is i am going to generate this piece of code by running XSLT on my wxs file which gets generated using heat; and there is no way I could generate a GUID using XSLT (or can I?)

这是我的代码现在的样子:

This is how my code looks now:

<ComponentGroup Id='web.config' Directory='CONFIGLOCATION'>
  <Component Id='CopyWebConfigForDev1' Guid='{F207C26A-5D9C-4F19-96A3-D818BB226EFC}' >
    <Condition>ENV="Dev1"</Condition>
    <CopyFile Id='CopyDev1Config' FileId='fil9C4CFE42035F1A63180142352CF441BC' DestinationDirectory='CONFIGLOCATION' DestinationName='web.config'/>
  </Component>
  <Component Id='CopyWebConfigForQA1' Guid='{F207C26A-5D9C-4F19-96A3-D818BB226EFC}' >
    <Condition>ENV="QA1"</Condition>
    <CopyFile Id='CopyQA1Config' FileId='fil12F8B50F03F1BD91A579F6B6CE7195DF' DestinationDirectory='CONFIGLOCATION' DestinationName='web.config'/>
  </Component>
</ComponentGroup>

推荐答案

在Rob提供的代码的帮助下,经过更多的研究,我发现了如何避免在没有安装文件夹的情况下为每个组件提供Guid的方法.一个标准文件夹.只需为要在其中安装组件的自定义目录指定ComponentGuidGenerationSeed.您指定此属性的目录不必是您打算在其中安装组件的位置的直接父目录.这是我的目录结构现在的样子:

With help from the code that Rob provided and after some more research i found out how to avoid having to provide the Guid to each component if your installation folder is not a standard folder. Simply specify the ComponentGuidGenerationSeed for the Custom Directory under which you are trying to install the component to. The directory where you specify this attribute need not be the immediate parent directory of the location where you intend to install the component. This is how my directory structure now looks:

<Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="INETPUBFOLDER" Name="inetpub">
        <Directory Id="WWWROOTFOLDER" Name="wwwroot" ComponentGuidGenerationSeed="PUT-YOUR-GUID">
          <Directory Id="CONFIGLOCATION" Name="$(var.PublishLocation)" />
          <Directory Id="INSTALLLOCATION" Name="$(var.PublishLocation)" >
            <Directory Id="APPFOLDER" Name="bin" />
            <Directory Id="MyProject.Web.Content" />
            <Directory Id="CONFIGSFOLDER" Name="Configs">
              <Directory Id="WEBFOLDER" Name="Web">
                <Directory Id="WEBCONFIGFILES" />
              </Directory>
              <Directory Id="NLOGFOLDER" Name="NLog">
                <Directory Id="NLOGCONFIGFILES" />
              </Directory>
            </Directory>
          </Directory>
        </Directory>
      </Directory>
    </Directory>

这是我现在收集并经过xml转换的wxs文件的外观:

This is how now my harvested and xml transformed wxs file looks:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="WEBCONFIGFILES">
            <Component Id="cmp9CAF0D4A0C62775945002986D1D99926" Guid="PUT-YOUR-GUID">
                <File Id="fil9C4CFE42035F1A63180142352CF441BC" KeyPath="yes" Source="$(var.WebConfigFilesDir)\Web.Dev1.config" />
            </Component>
            <Component Id="cmpB5117E2029EA9A7CC3AFC247EA4483AD" Guid="PUT-YOUR-GUID">
                <File Id="fil0F80FEAFAD0333C3B74BB742C4FE118C" KeyPath="yes" Source="$(var.WebConfigFilesDir)\Web.Prod.config" />
            </Component>
            <Component Id="cmp340743041F12BBE6C7C40D4351407D08" Guid="PUT-YOUR-GUID">
                <File Id="fil12F8B50F03F1BD91A579F6B6CE7195DF" KeyPath="yes" Source="$(var.WebConfigFilesDir)\Web.QA1.config" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="WebConfigFiles">
            <ComponentRef Id="cmp9CAF0D4A0C62775945002986D1D99926" />
            <ComponentRef Id="cmpB5117E2029EA9A7CC3AFC247EA4483AD" />
            <ComponentRef Id="cmp340743041F12BBE6C7C40D4351407D08" />
        </ComponentGroup>
    </Fragment>
    <Fragment>
        <UI Id="EnvironmentComboBox">
            <ComboBox Property="ENV">
                <ListItem Value="Dev1" Text="Dev1" />
                <ListItem Value="Prod" Text="Prod" />
                <ListItem Value="QA1" Text="QA1" />
            </ComboBox>
        </UI>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="web.config" Directory="CONFIGLOCATION">
            <Component Id="cmpWebConfigForDev1">
                <Condition>ENV="Dev1"</Condition>
                <File Id="CopyDev1Config" Source="$(var.WebConfigFilesDir)\Web.Dev1.config" Name="web.config" />
            </Component>
            <Component Id="cmpWebConfigForProd">
                <Condition>ENV="Prod"</Condition>
                <File Id="CopyProdConfig" Source="$(var.WebConfigFilesDir)\Web.Prod.config" Name="web.config" />
            </Component>
            <Component Id="cmpWebConfigForQA1">
                <Condition>ENV="QA1"</Condition>
                <File Id="CopyQA1Config" Source="$(var.WebConfigFilesDir)\Web.QA1.config" Name="web.config" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

在以上文件中,收获工具仅生成前两个片段.接下来的两个包含UI/ComboBox定义和WebconfigFiles的ComponentGroup的片段是使用XML转换通过从第一个片段中的File元素中读取信息来创建的.

In the above file only the first two fragments are generated by the harvest tool. The next two fragments containing the UI/ComboBox Definition and ComponentGroup for WebconfigFiles are created using XML transform by reading the information from File elements in the first Fragment.

这篇关于WiX-将基于环境的已编译的web.config复制到网站根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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