Hi, I’m @Luo Zhu

This article was first published on luo Zhu’s official website

This article synchronizes in the public account “luo Zhu early teahouse”, reprint please contact the author.

Creation is not easy, form a habit, quality three even!

The GO-MSI package helps developers generate MSI packages for GO projects.

This tool is part of the Go-Github – Release Workflow.

You can see more examples here.

The installation

Go

go get github.com/mh-cbon/go-msi
Copy the code

binary

choco source add -n=mh-cbon -s="https://api.bintray.com/nuget/mh-cbon/choco"
choco install go-msi
Copy the code

Chocolatey

choco install go-msi
Copy the code

Linux RPM/deb warehouse

wget -O - https://raw.githubusercontent.com/mh-cbon/latest/master/bintray.sh \
| GH=mh-cbon/go-msi sh -xe
# or
curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/bintray.sh \
| GH=mh-cbon/go-msi sh -xe
Copy the code

Linux RPM /deb independent package

curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh \
| GH=mh-cbon/go-msi sh -xe
# or
wget -q -O - --no-check-certificate \
https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh \
| GH=mh-cbon/go-msi sh -xe
Copy the code

use

The required environment

  • A windows machine (see here for an appveyor file, see here for unix friendly users)
  • For Windows users check this out, for Unix users check this out
  • Wix > = 3.10
  • Add wiX binary location to yourPATH
  • usecheck-envSubcommand to get the report

workflow

A simple example:

  • Create a similarthis 的 wix.jsonfile
  • You have to use it for every applicationgo-msi set-guidTo set the GUID.
  • runGo-msi make --msi your_program. Msi --version 0.0.2

The configuration file

The wix.json file describes the packaging rules between your source code and the generated MSI file.

See the demo JSON file

If not, submit an ISSEUE

Be sure to read documentation and StackOverflow carefully when you run into problems

  • Wixtoolset.org/documentati…
  • Stackoverflow.com/questions/t…

If you want to know what INSTALLDIR, [INSTALLDIR] is, which is part of the WiX rules, check out their documentation.

The certificate file

Note the license file, which must be an RTF file and must be encoded in Windows1252charset. I’ve provided some tools to help solve this problem.

Wix template

For simplicity, we have provided a default installation process that you can view here

You can create a new one for your own personalization. You just need to pay attention to recreating the existing GO template. Defines “files”, “directories”, “environment variables”, “licenses”, and “shortcuts”.

I think most of your changes are to the Wixui_Hk.wXS file.

Cli

go-msi -h

NAME:
   go-msi - Easy msi pakage forGo USAGE: go-msi < CMD > <options> VERSION: 0.0.0 COMMANDS: check-json Check the JSON wix manifest check-env Provide a report about your environment setup set-guid Sets appropriate  guidsin your wix manifest
     generate-templates  Generate wix templates
     to-windows          Write Windows1252 encoded file
     to-rtf              Write RTF formatted file
     gen-wix-cmd         Generate a batch file of Wix commands to run
     run-wix-cmd         Run the batch file of Wix commands
     make                All-in-one command to make MSI files
     choco               Generate a chocolatey package of your msi files
     help, h             Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version
Copy the code

go-msi check-env -h

NAME:
   go-msi check-env - Provide a report about your environment setup

USAGE:
   go-msi check-env [arguments...]
Copy the code

go-msi check-json -h

NAME:
   go-msi check-json - Check the JSON wix manifest

USAGE:
   go-msi check-json [commandoptions] [arguments...]  OPTIONS: --path value, -p value Path to the wix manifest file (default:"wix.json")
Copy the code

go-msi set-guid -h

NAME:
   go-msi set-guid - Sets appropriate guids in your wix manifest

USAGE:
   go-msi set-guid [commandoptions] [arguments...]  OPTIONS: --path value, -p value Path to the wix manifest file (default:"wix.json")
   --force, -f             Force update the guids
Copy the code

go-msi make -h

NAME:
   go-msi make - All-in-one command to make MSI files

USAGE:
   go-msi make [commandoptions] [arguments...]  OPTIONS: --path value, -p value Path to the wix manifest file (default:"wix.json")
   --src value, -s value      Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates")
   --out value, -o value      Directory path to the generated wix cmd file (default: "/tmp/go-msi645264968")
   --arch value, -a value     A target architecture, amd64 or 386 (ia64 is not handled)
   --msi value, -m value      Path to write resulting msi file to
   --version value            The version of your program
   --license value, -l value  Path to the license file
   --keep, -k                 Keep output directory containing build files (useful for debug)
Copy the code

go-msi choco -h

NAME:
   go-msi choco - Generate a chocolatey package of your msi files

USAGE:
   go-msi choco [commandoptions] [arguments...]  OPTIONS: --path value, -p value Path to the wix manifest file (default:"wix.json")
   --src value, -s value            Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates/choco")
   --version value                  The version of your program
   --out value, -o value            Directory path to the generated chocolatey build file (default: "/tmp/go-msi697894350")
   --input value, -i value          Path to the msi file to package into the chocolatey package
   --changelog-cmd value, -c value  A command to generate the content of the changlog in the package
   --keep, -k                       Keep output directory containing build files (useful for debug)
Copy the code

go-msi generate-templates -h

NAME:
   go-msi generate-templates - Generate wix templates

USAGE:
   go-msi generate-templates [commandoptions] [arguments...]  OPTIONS: --path value, -p value Path to the wix manifest file (default:"wix.json")
   --src value, -s value      Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates")
   --out value, -o value      Directory path to the generated wix templates files (default: "/tmp/go-msi522345138")
   --version value            The version of your program
   --license value, -l value  Path to the license file
Copy the code

go-msi to-windows -h

NAME:
   go-msi to-windows - Write Windows1252 encoded file

USAGE:
   go-msi to-windows [commandoptions] [arguments...]  OPTIONS: --src value, -s value Path to an UTF-8 encoded file --out value, -o value Path to the ANSI generated fileCopy the code

go-msi to-rtf -h

NAME:
   go-msi to-rtf - Write RTF formatted file

USAGE:
   go-msi to-rtf [commandoptions] [arguments...]  OPTIONS: --src value, -s value Path to a text file --out value, -o value Path to the RTF generated file --reencode, -e Also re encode UTF-8 to Windows1252 charsetCopy the code

go-msi gen-wix-cmd -h

NAME:
   go-msi gen-wix-cmd - Generate a batch file of Wix commands to run

USAGE:
   go-msi gen-wix-cmd [commandoptions] [arguments...]  OPTIONS: --path value, -p value Path to the wix manifest file (default:"wix.json")
   --src value, -s value   Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates")
   --out value, -o value   Directory path to the generated wix cmd file (default: "/tmp/go-msi844736928")
   --arch value, -a value  A target architecture, amd64 or 386 (ia64 is not handled)
   --msi value, -m value   Path to write resulting msi file to
Copy the code

go-msi run-wix-cmd -h

NAME:
   go-msi run-wix-cmd - Run the batch file of Wix commands

USAGE:
   go-msi run-wix-cmd [commandoptions] [arguments...]  OPTIONS: --out value, -o value Directory path to the generated wix cmd file (default:"/tmp/go-msi773158361")
Copy the code