从WIX设置更新app.config? [英] Update app.config from WIX setup?

查看:170
本文介绍了从WIX设置更新app.config?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试Wix 3.6,这是它现在的样子:

 <?xml version =1.0 encoding =UTF-8?> 



 < Directory Id =TARGETDIRName =SourceDir> 
< Directory Id =myappINSTALLDIRName =myapp5Service>
< Component Id =SampleServiceComponentDiskId =1Guid =6f51c0f3-776c-4aec-a200-1f199352c6c3Win64 =yes>
< File Id =myapp5.WindowsService.exeName =myapp5.WindowsService.exeSource =$(var.myapp.WindowsService.TargetDir)\myapp5.WindowsService.exeKeyPath ='yes '/>
...

< ServiceInstall Id =InstallmyappServiceDisplayName =myappServiceName =myapp5.WindowsService.exe描述=myapp 5 Service - Föreffektivare och enklare operationplanering Account =LocalSystemErrorControl =normalStart =autoType =ownProcessVital =yes/>
< ServiceControl Id =ControlmyappServiceName =myapp5.WindowsService.exeStart =installStop =bothRemove =uninstallWait =yes/>
< / Component>
< / Directory>
< / Directory>


< WixVariable Id =WixUIBannerBmpValue =$(var.ProjectDir)\Image\myappTopBanner.bmp/>
< WixVariable Id =WixUIDialogBmpValue =$(var.ProjectDir)\Image\myappDialogBackground.bmp/>

< Property Id =WIXUI_INSTALLDIRValue =myappINSTALLDIR/>
< UIRef Id =WixUI_InstallDir/>

< Feature Id =ProductFeatureTitle =Wix_myapp.WindowsServiceLevel =1>
< ComponentRef Id =SampleServiceComponent/>
< / Feature>
< Media Id =1Cabinet =SampleServiceComponent.cabEmbedCab =yes/>
< / Product>



对话框到Wix设置,其中一个appSetting和一个baseadress(WCF)设置为app.config。这最多在安装之前做,因为它将决定Wix安装的Windows服务的名称。



和exampel将是巨大的!



编辑1:

 < WixVariable Id =WixUIBannerBmpValue =$ .ProjectDir)\Image\myappTopBanner.bmp/> 
< WixVariable Id =WixUIDialogBmpValue =$(var.ProjectDir)\Image\myappDialogBackground.bmp/>

< Property Id =SERVICEADDRESSValue =http:// serviceaddress/>
< Property Id =WIXUI_INSTALLDIRValue =myappINSTALLDIR/>
< UIRef Id =WixUI_InstallDir/>

< util:XmlFile Id =UpdateBaseAddress
Action =setValue
File =$(var.myapp.WindowsService.TargetDir)\myapp5.WindowsService。 exe.config
SelectionLanguage =XPath
Permanent =yes
ElementPath =/ configuration / applicationSettings / ServiceName
Name =baseAddressValue =[SERVICEADDRESS ]/>

< Feature Id =ProductFeatureTitle =Wix_myapp.WindowsServiceLevel =1>
< ComponentRef Id =SampleServiceComponent/>
< / Feature>
< Media Id =1Cabinet =SampleServiceComponent.cabEmbedCab =yes/>
< / Product>

解决方案>

您可以在安装程序项目中添加对WixUtilExtension.dll的引用,然后使用XmlFile更新app.config:

 < Property Id =SERVICEADDRESSValue =http:// serviceaddress/> 

< util:XmlFile Id =UpdateBaseAddress
Action =setValue
File =[DirApplication] $(var.app.config)
SelectionLanguage =XPath
Permanent =yes
ElementPath =/ configuration / applicationSettings / ....
Name =baseAddressValue =[SERVICEADDRESS]/>

请注意,您需要设置目录和.config文件的名称只需使用$(var。 ProjectName .TargetFileName).config 自动为您处理。


I am trying Wix 3.6 and this is how it looks right now :

<?xml version="1.0" encoding="UTF-8"?>

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="myappINSTALLDIR" Name="myapp5Service">
        <Component Id="SampleServiceComponent" DiskId="1" Guid="6f51c0f3-776c-4aec-a200-1f199352c6c3" Win64="yes">
          <File Id="myapp5.WindowsService.exe" Name="myapp5.WindowsService.exe" Source="$(var.myapp.WindowsService.TargetDir)\myapp5.WindowsService.exe" KeyPath='yes'/>
          ...

          <ServiceInstall Id="InstallmyappService" DisplayName="myappService" Name="myapp5.WindowsService.exe" Description="myapp 5 Service - För effektivare och enklare operationsplanering" Account="LocalSystem" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" />
          <ServiceControl Id="ControlmyappService" Name="myapp5.WindowsService.exe" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
        </Component>
    </Directory>
</Directory>


<WixVariable Id="WixUIBannerBmp" Value="$(var.ProjectDir)\Image\myappTopBanner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)\Image\myappDialogBackground.bmp" />

<Property Id="WIXUI_INSTALLDIR" Value="myappINSTALLDIR" />
<UIRef Id="WixUI_InstallDir" />

<Feature Id="ProductFeature" Title="Wix_myapp.WindowsService" Level="1">
  <ComponentRef Id="SampleServiceComponent" />
</Feature>
<Media Id="1" Cabinet="SampleServiceComponent.cab" EmbedCab="yes" />
</Product>

Now I need to add a dialog to the Wix setup where one appSetting and one baseadress(WCF) is set to the app.config. This most be done before the installation becouse it will decide the name of the Windows Service that the Wix is installning.

And exampel would be great!

Edit 1:

    <WixVariable Id="WixUIBannerBmp" Value="$(var.ProjectDir)\Image\myappTopBanner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)\Image\myappDialogBackground.bmp" />

<Property Id="SERVICEADDRESS" Value="http://serviceaddress"/>
<Property Id="WIXUI_INSTALLDIR" Value="myappINSTALLDIR" />
<UIRef Id="WixUI_InstallDir" />

<util:XmlFile Id="UpdateBaseAddress"
  Action="setValue"
  File="$(var.myapp.WindowsService.TargetDir)\myapp5.WindowsService.exe.config"
  SelectionLanguage="XPath"
  Permanent="yes"
  ElementPath="/configuration/applicationSettings/ServiceName"
  Name="baseAddress" Value="[SERVICEADDRESS]" />

<Feature Id="ProductFeature" Title="Wix_myapp.WindowsService" Level="1">
  <ComponentRef Id="SampleServiceComponent" />
</Feature>
<Media Id="1" Cabinet="SampleServiceComponent.cab" EmbedCab="yes" />
</Product>

解决方案

You could add in a reference to the WixUtilExtension.dll to the installer project, then use XmlFile to update the app.config like:

<Property Id="SERVICEADDRESS" Value="http://serviceaddress"/>

<util:XmlFile Id="UpdateBaseAddress" 
  Action="setValue" 
  File="[DirApplication]$(var.app.config)"
  SelectionLanguage="XPath" 
  Permanent="yes"
  ElementPath="/configuration/applicationSettings/...."
  Name="baseAddress" Value="[SERVICEADDRESS]" />

Note that you'll need to set the directory and the name of the .config file (you could just use $(var.ProjectName.TargetFileName).config which should work it out for you automatically

这篇关于从WIX设置更新app.config?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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