DEV Community

loading...

Create a .msi file for go program

abdfnx profile image abdfn ・Updated on ・2 min read

Hi everyone, long time no write anything, but I had a lot of projects and stresses to study, but now, we'll create a .msi file for go program

Pre-requisites

What's we'll use?

Package go-msi helps to generate MSI package for a Go project.

installation

by go

go get github.com/mh-cbon/go-msi
Enter fullscreen mode Exit fullscreen mode

by Chocolatey

choco install go-msi
Enter fullscreen mode Exit fullscreen mode

for more, visit https://mh-cbon.github.io/go-msi/#install

ok, now let's create a simple go file msi.go

package main

import "fmt"

func main() {
  fmt.Println("Gen MSI File")
}
Enter fullscreen mode Exit fullscreen mode

build it

go build
Enter fullscreen mode Exit fullscreen mode

wix.json

to create a .msi file, we need wix.json

{
  "product": "YOUR_PRODUCT_NAME",
  "company": "YOUR_COMPANY_NAME",
  "license": "LICENSE",
  "upgrade-code": "",
  "files": {
    "guid": "",
    "items": [
      "path/to/msi.exe",
    ]
  },
  "env": {
    "guid": "",
    "vars": [
      {
        "name": "PATH",
        "value": "[INSTALLDIR]",
        "permanent": "no",
        "system": "no",
        "action": "set",
        "part": "last"
      }
    ]
  },
  "shortcuts": {},
  "choco": {
    "description": "YOUR_DESC",
    "project-url": "YOUR_PROJECT_URL",
    "tags": "TAGS YOU NEED",
    "license-url": "YOUR_LICENSE_URL"
  }
}
Enter fullscreen mode Exit fullscreen mode

our guid props are empty, run this command

go-msi set-guid
Enter fullscreen mode Exit fullscreen mode

Create Interfaces

we'll create three user interfaces

  1. License Agreement Page
  2. WiX UI
  3. Product Page

now create three files

  • LicenseAgreementDlg_HK.wsx
  • product.wsx
  • WixUI_HK.wsx

download these files here

put these files in folder, like templates folder

Generate

I highly recommend git bash for this step

go-msi make --msi YOUR_PRODUCT_NAME.msi --version YOUR_VERSION -s ./path/to/*.wsx
Enter fullscreen mode Exit fullscreen mode

now you can test your msi file

πŸ‘‹

Discussion (0)

pic
Editor guide