How to parameterize msi file from electron builder

前端 未结 2 505
情书的邮戳
情书的邮戳 2020-12-20 01:02

I\'m trying to create an .msi installer file with electron-builder (version 20.39.0), that can be parameterized during install time. The parameters (e.g. server endpoint) sh

2条回答
  •  鱼传尺愫
    2020-12-20 01:33

    With the help of Stein Åsmul, this is my current solution:

    I took the current WiX template of electron-builder and added an option to write variables to an ini file.

    
    
    ...
    
      
        
        
      
    
    

    The complete template looks like this:

    
    
      
      
      
        
    
        = 601]]>
    
        
        
        
    
        
        
        
        
    
        {{ if (iconPath) { }}
        
        
        {{ } -}}
    
        {{ if (isAssisted || isRunAfterFinish) { }}
        
        {{ } -}}
    
        
        {{ if (isPerMachine) { }}
        
        {{ } else { }}
        
        {{ } -}}
    
        {{ if (isAssisted) { }}
        
        
        
    
        
        {{ } else if (isRunAfterFinish) { }}
        
        
          
        
        {{ } -}}
    
        
          
            
              
                
                
              
            
          
    
          
          {{ if (isCreateDesktopShortcut) { }}
          
          {{ } -}}
    
          
          {{ if (isCreateStartMenuShortcut) { }}
          
          {{ } }}
        
    
        
        
          
        
    
        {{-dirs}}
    
        
          {{-files}}      
        
      
    
    
    

    Using electron-builder@20.39.0, I create the MSI with

    set DEBUG=electron-builder:*
    cp template.xml .\node_modules\app-builder-lib\templates\msi\template.xml
    electron-builder
    

    And then install the MSI with

    MsiExec /i "myapp.msi" MYSERVER=myapp.example.com MYSECONDPROPERTY=helloworld /L*v Install.log
    

    After installation finished, I got the AppConfig.ini in my installdir (%USERPROFILE%\AppData\Local\Programs\MyApp\AppConfig.ini)

    [AppConfig]
    Server="myapp.example.com"
    SecondProp="helloworld"
    

提交回复
热议问题