2016-12-06 4 views
0

Hy everyone、 HeatとXslTransformファイルを使ってWixを使っています。 作成したUIダイアログを使用して、私のApp.config connectionStringをカスタマイズしたいと思います。したがって、私はXMLFILEコピーを追加するには、以下のようにXSL変換を使用します。[Harvest]一致したコンポーネントのGuidを取得してXslの属性に設定する方法

<xsl:template match="wix:Component[wix:File[@Source='$(var.SourceDir)\App.config']]"> 
<xsl:copy> 
    <xsl:apply-templates select="node() | @*" /> 
    <util:XmlFile Id="UpdateBaseAddress" 
    Action="setValue" 
    File="[I want to put here my auto generated ID for the App.config File Component]" 
    SelectionLanguage="XPath" 
    Permanent="yes" 
    ElementPath="/configuration/connectionStrings/" 
    Name="connectionString" Value="[DatabaseConnectionString]" > 
    </util:XmlFile> 
</xsl:copy> 
</xsl:template> 

私は大成功せずに多くの方法を試してみました。一致するファイルIDを 'File'属性に設定する方法はありますか? ありがとうございます。

答えて

0

コンポーネントIDを入力する必要はありません。 File属性には、MSIコンポーネントIDではなく、物理ファイルへのパスが必要です。ここでは(ないXmlFileが、XmlConfig要素とが)同じようなことを達成する方法のWiXのスニペットは次のとおりです。ここで注意すべき事柄の

<Component Id="ConnectionStringChanges" Guid="{GUID-GOES-HERE}" Directory="App_Config"> 
    <CreateFolder/> 
    <Condition>NOT Installed</Condition> 
    <util:XmlConfig Id="ConnectionStringChange" ElementPath="connectionStrings/add[\[]@name='core'[\]]" 
        File="[!ConnectionStrings.config]" Name="connectionString" Action="create" Node="value" On="install" 
        PreserveModifiedDate="yes" Value="user id=[SQL_SERVER_CONFIG_USER];password=[SQL_SERVER_CONFIG_PASSWORD];Data Source=[SQL_SERVER];Database=[DBPREFIX]Core_DB" /> 
    </Component> 

カップル:

<Component>要素のDirectory属性をすることができConnectionStringChangesコンポーネントを右の<Directory>要素の下にネストする場合は省略されます。 ConnectionStrings.configファイル限り

<xsl:template match="wix:DirectoryRef/wix:Directory[@Name='App_Config']"> 
    <xsl:element name="Directory" xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <xsl:attribute name="Id">App_Config</xsl:attribute> 
    <xsl:attribute name="Name"> 
     <xsl:value-of select="@Name"/> 
    </xsl:attribute> 
    <xsl:apply-templates /> 
    </xsl:element> 

:ディレクトリ構造が熱で自動生成された場合は、カスタム1でApp_Configフォルダの自動生成IDを置き換えるために、このXSLスニペットを使用することができます宣言はまた、自動生成され、あなたは\[!ConnectionStrings.config\] syntaxでファイルを参照できるようにするには同様のトリックを適用する必要があります。

<xsl:template match="wix:DirectoryRef/wix:Directory[@Name='App_Config']/wix:Component[wix:File[@Source='$(var.Source)\App_Config\ConnectionStrings.config']]"> 
    <xsl:copy> 
    <xsl:copy-of select="@*"/> 
    <xsl:attribute name="NeverOverwrite">yes</xsl:attribute> 
    <xsl:element name="File" xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
     <xsl:attribute name="Id">ConnectionStrings.config</xsl:attribute> 
     <xsl:copy-of select="wix:File/@KeyPath | wix:File/@Source"/> 
    </xsl:element> 
    </xsl:copy> 

希望します。

+0

ご回答いただきありがとうございます。 しかし私はかなり混乱しています。私はアプリケーションのルートに収穫されたApp.configファイルを持っています。 ユーザーがウィザードで変更したのは、次のとおりです。 makertoo

関連する問題