Failed to open XML file - Wix unable to update appsettings.json

冷暖自知 提交于 2019-12-04 06:18:18

问题


I am using Wix to create MSI installers. My requirement is to pass parameters while installing msi from the command line and update' theappsettings.json` with the values passed.

To achieve this, I have added below property and component.

  <Property Id="ApplicationLog.pathFormat" />


  <Component Id="config" Guid="*">
    <File Id="appconfig" Source="$(var.BasePath)\appsettings.json" KeyPath="yes" Vital="yes"/>
    <util:XmlFile 
      Id="_pathFormat_" File="$(var.BasePath)\appsettings.json"  
      Action="setValue" 
      Name="pathFormat" Value="[pathFormat]" 
      ElementPath="/ApplicationLog/Serilog/WriteTo/Args/"
      Sequence='1' />
  </Component>

I have passed the values as follow while installing

C:\work\Installer\bin\Debug>MyService-Debug-x86.msi pathFormat="value1"

But I get below error

Failed to open XML file ....\Installer\bin\Debug\netcoreapp2.1\win-x86\publish\appsettings.json. system error -2147024786

Additional Information

There was ICE30 error,

ICE30: The target file 'l-racj8d.jso|appsettings.json' is installed in '[ProgramFilesFolder]\MyService\' by two different components on an LFN system: 'config' and 'cmpF82FCA80BBAF44D285C97F10993DEEE6'.

Which resolved by changing the ICE validation-> Suppress ICE validation

But why installer unable to open the json app settings? I am running the installer in administrator mode.

Update

I have changed $(var.BasePath) to '[INSTALLDIR]'

  <Component Id='config' Guid='*'>
    <File Id='jsonconfig' Source='[INSTALLDIR]appsettings.json' KeyPath="yes" Vital="yes"/>
    <util:XmlFile Id='xpathFormat' File='[INSTALLDIR]appsettings.json'
                  Action='setValue' Name='pathFormat' Value='[ApplicationLog.pathFormat]'
                  ElementPath='/ApplicationLog/Serilog/WriteTo/Args/' Sequence='1' />
  </Component>

But I am getting

The system cannot find the file '[INSTALLDIR]appsettings.json'.

Is it because appsettings.json is not yet copied to [INSTALLDIR]?? If yes, then how to achieve this?

来源:https://stackoverflow.com/questions/57264361/failed-to-open-xml-file-wix-unable-to-update-appsettings-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!