Giter VIP home page Giter VIP logo

go-msi's Introduction

Sponsor

go-msi

Appveyor Status

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

This tool is part of the go-github-release workflow

Find a demo program here

TOC

Install

Check the release page!

Go

go get github.com/mh-cbon/go-msi

Bintray

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

Chocolatey

choco install go-msi

linux rpm/deb repository

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

linux rpm/deb standalone 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

Usage

Requirements

  • A windows machine (see here for an appveyor file, see here for unix friendly users)
  • wix >= 3.10 (may work on older release, but it is untested, feel free to report)
  • you must add wix bin to your PATH
  • use check-env sub command to get a report.

Workflow

For simple cases,

  • Create a wix.json file like this one
  • Apply it guids with go-msi set-guid, you must do it once only for each app.
  • Run go-msi make --msi your_program.msi --version 0.0.2

configuration file

wix.json file describe the desired packaging rules between your sources and the resulting msi file.

Check the demo json file

Post an issue if it is not self-explanatory.

Always double check the documentation and SO when you face a difficulty with heat, candle, light

If you wonder why INSTALLDIR, [INSTALLDIR], this is part of wix rules, please check their documentation.

License file

Take care to the license file, it must be an rtf file, it must be encoded with Windows1252 charset.

I have provided some tools to help with that matter.

Personnalization

wix templates

For simplicity a default install flow is provided, which you can find here

You can create a new one for your own personalization, you should only take care to reproduce the go templating already defined for files, directories, environment variables, license and shortcuts.

I guess most of your changes will be about the WixUI_HK.wxs file.

Cli

$ go-msi -h
NAME:
   go-msi - Easy msi pakage for Go

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 guids in 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
$ go-msi check-env -h
NAME:
   go-msi check-env - Provide a report about your environment setup

USAGE:
   go-msi check-env [arguments...]
$ go-msi check-json -h
NAME:
   go-msi check-json - Check the JSON wix manifest

USAGE:
   go-msi check-json [command options] [arguments...]

OPTIONS:
   --path value, -p value  Path to the wix manifest file (default: "wix.json")
$ go-msi set-guid -h
NAME:
   go-msi set-guid - Sets appropriate guids in your wix manifest

USAGE:
   go-msi set-guid [command options] [arguments...]

OPTIONS:
   --path value, -p value  Path to the wix manifest file (default: "wix.json")
   --force, -f             Force update the guids
$ go-msi make -h
NAME:
   go-msi make - All-in-one command to make MSI files

USAGE:
   go-msi make [command options] [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)
$ go-msi choco -h
NAME:
   go-msi choco - Generate a chocolatey package of your msi files

USAGE:
   go-msi choco [command options] [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)
$ go-msi generate-templates -h
NAME:
   go-msi generate-templates - Generate wix templates

USAGE:
   go-msi generate-templates [command options] [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
$ go-msi to-windows -h
NAME:
   go-msi to-windows - Write Windows1252 encoded file

USAGE:
   go-msi to-windows [command options] [arguments...]

OPTIONS:
   --src value, -s value  Path to an UTF-8 encoded file
   --out value, -o value  Path to the ANSI generated file
$ go-msi to-rtf -h
NAME:
   go-msi to-rtf - Write RTF formatted file

USAGE:
   go-msi to-rtf [command options] [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 charset
$ 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 [command options] [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
$ 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 [command options] [arguments...]

OPTIONS:
   --out value, -o value  Directory path to the generated wix cmd file (default: "/tmp/go-msi773158361")

Recipes

Appveyor

Please check this

Unix like

Please check this

Release the project

gump patch -d # check
gump patch # bump

History

CHANGELOG

Credits

A big big thanks to

go-msi's People

Contributors

mh-cbon avatar solvingj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-msi's Issues

Confusing Error When --msi option not specified

The error message is:

The filename, directory name, or volume label syntax is incorrect

Would be better to give a specific error when this required parameter is missing. This is very minor.

cmd -o delete file

cmd run go-msi make --msi YOUR_PRODUCT_NAME.msi --version YOUR_VERSION -s ./path/to/*.wsx -o D:/

delete my D:/ all file damn

product.wxs(136) : error LGHT0094 - Issue with Template

I read the documentation surrounding the use of

CustomAction:WixBroadcastEnvironmentChange

I also looked through about 10 different reports of errors surrounding "error LGHT0094".

I still can't figure out how to fix the error.

I cloned the mh-cbon/go-msi repository and I get the same error I'm getting on my own repository:

C:\Users\me\git-c\go-msi>go-msi make --msi go-github-release-test.msi --version 0.0.1 --arch 386

C:\Users\me\AppData\Local\Temp\go-msi037630771>heat dir ..\..\..\..\git-c\go-msi\templates -nologo -cg AppFiles0 -gg -g1 -srd -sfrag -template fragment -dr APPDIR0 -var var.SourceDir0 -out AppFiles0.wxs

C:\Users\me\AppData\Local\Temp\go-msi037630771>candle -arch x86 -dSourceDir0=..\..\..\..\git-c\go-msi\templates AppFiles0.wxs LicenseAgreementDlg_HK.wxs WixUI_HK.wxs product.wxs
Microsoft (R) Windows Installer Xml Compiler version 3.5.2519.0
Copyright (C) Microsoft Corporation. All rights reserved.

AppFiles0.wxs
LicenseAgreementDlg_HK.wxs
WixUI_HK.wxs
product.wxs

C:\Users\me\AppData\Local\Temp\go-msi037630771>light -ext WixUIExtension -ext WixUtilExtension -sacl -spdb  -out ..\..\..\..\git-c\go-msi\go-github-release-test.msi AppFiles0.wixobj LicenseAgreementDlg_HK.wixobj WixUI_HK.wixobj product.wixobj
Microsoft (R) Windows Installer Xml Linker version 3.5.2519.0
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Users\me\AppData\Local\Temp\go-msi037630771\product.wxs(121) : error LGHT0094 : Unresolved reference to symbol 'CustomAction:WixBroadcastEnvironmentChange' in section 'Product:*'.
exit status 94

write end-to-end tests

The project needs end-to-end testing suite.

Until now the project is tested manually
following the instructions available here
https://github.com/mh-cbon/go-msi/tree/master/demo
Problems, it s all manual, it takes times, it s boring,
but still needed from time to time.

The automated test should reproduce in some ways
the commands defined into the demo README,
add assertions at various steps to ensure the integrity.

The commands to setup the vagrant runtime
and those to execute the tests are to be split
and put into different tools at the disposal of the developer.

The tests must run on a cloud platform like appveyor.

For a developer, the test procedure should be able to support
a one time setup, multiple tests run.

I guess a go program is more suitable to execute the tests,
it will be a bit unnatural to have all those commands into a go file,
but the test writing capabilities will be greatly improved.

Rel: can't make <absolute MSI path> relative to <relative --out path>

Seems unmaintained so I guess I'm on my own but may as well post anyway:

go-msi make
        --src=./distribution/windows/templates
        --path=./distribution/windows/wix.json
        --msi=./dist/windows/Appname.msi
        --out=./dist/windows/temp
        --version={{.VERSION}}
        --license=LICENSE
Rel: can't make D:\Work\appname\dist\windows\Appname.msi relative to ./dist/windows/temp

Looks broken, no paths work in the config even if they are absolute.

document hooks usage

Follow #11

Add documentation to describe hooks.

  • What are hook phases
  • How to write the commands (a bat, a one-line)
  • How to define phases
  • What happen on failure

choco: add checksum

relates to http://us8.campaign-archive1.com/?u=86a6d80146a0da7f2223712e4&id=f2fe8dbe6b

TBD

in chocolateyInstall.ps1

update the call to Install-ChocolateyInstallPackage add parameters to check the sum

  [-Checksum <String>] 
  [-ChecksumType <String>]

https://chocolatey.org/docs/helpers-install-chocolatey-package

TODO

  • add fn to compute sha1 checksum of a given path
  • update chocomanifest to add a new field holding the checksum value
  • update chocolateyInstall.ps1 to add the new parameters
  • update chocoMake to compute the checksum set it on the manifest

FYI

osx ?

all the work on packaging and releasing is awesome, and i would like ot help.

I am wondering about OSX.
Have a look at this
https://github.com/murlokswarm/macpack
It can make a OSX app and gen the Plist.
What i find really interesting is that they have a OS agnostic schema description, so it can be used for all OS's.

I am also working on making url schemes work for apps so that devs can link up apps to listen for other urls and also send urls. Allows composition.
They just put in the their first version of it for OSX.
https://github.com/murlokswarm/mac/commit/82cfcdae33ec9aeb04eaade142098ef7b9c7a2f2

go-msi does not incorporate recent breaking API changes to go-uuid

I get a build error while trying to go get:

$ go get github.com/mh-cbon/go-msi
# github.com/mh-cbon/go-msi/manifest
C:\Users\shabb\go\src\github.com\mh-cbon\go-msi\manifest\index.go:152:35: multiple-value uuid.NewV4() in single-value context
C:\Users\shabb\go\src\github.com\mh-cbon\go-msi\manifest\index.go:156:34: multiple-value uuid.NewV4() in single-value context
C:\Users\shabb\go\src\github.com\mh-cbon\go-msi\manifest\index.go:160:32: multiple-value uuid.NewV4() in single-value context
C:\Users\shabb\go\src\github.com\mh-cbon\go-msi\manifest\index.go:164:38: multiple-value uuid.NewV4() in single-value context

Project status?

@mh-cbon what is the status of this project?
I have numerous fixes and enhancements in my fork which I can make PRs for, are you interested?

Thanks!

add option to force update guid

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

USAGE:
   go-msi set-guid [command options] [arguments...]

OPTIONS:
   --path value, -p value  Path to the wix manifest file (default: "wix.json")

I should be able to do go-msi set-guid --force to force update, currently i have,

$ go-msi set-guid
The manifest was not updated
The file is saved on disk
go-msi set-guid --force
Incorrect Usage: flag provided but not defined: -force

discussion/ generate appx packages

From xoviat/subzero#30:

With the desktop bridge it is possible to bring existing (PyInstaller) generated apps to the windows store. It should be possible to create a bdist_appx command the inherits from the bdist_msi command to create an appx package that can then be signed. In fact, generation should be simpler for appx than for MSI installers.

Of course, if we do it here then more people will benefit from this functionality. I might submit a pull request if I have time.

How to build a wix.json

Hello,

Sorry to create an issue about this, but there is very little guidance here on how to really create an msi from scratch using go-msi.

I've managed to do something, but I am not sure how to edit wix.json for example to add an icon.

Repository is 55 MB - Binaries in the repo somewhere

Not a big deal but i was downloading on a slow connection and surprised to find out the repository was so big. I don't know if there's any easy way to delete files out of git history, but it would be good for the repo if you found a way.

Add support for windows services

In many (or at least some) cases, golang binaries will work as a daemons executing 24/7

It would be great if the manifest was extended to define services. These services would be started automatically upon installation and stopped/removed on uninstallation.

Alternatively, we do this manually, but for that we need #2

choco lack of description and documentation in the package

choco admin review comment,

If you also could add add some more description of the software that would be great.

Need to dig all the choco / msi things to see what is possible to do and how. I guess a translate of the MD to some (horrible) rtf (windows encoded) file could make the job.

Wix 4 Support?

Does this project have or plan to support Wix 4 (released at the beginning of April)?

document service setup

Following #11 Add documentation to explain how a service can be created.

  • how to write the program to handle windows service in go
  • how to install / uninstall the service via the msi

Requesting clarity on generate-templates usage

Go-msi comes with some default templates in the program directory, but it also allows the user to provide a custom "src" template, and a custom "out" template. It's just not clear to me how the generator uses the source template to generate a new template. Maybe it's because I've not used wix before.

I thought I would take the wix templates provided, edit them manually, and add the modified versions to my repository (just like one does with wix.json). It's just confusing to me to use a template generator to generate new templates based on existing templates. And then do i still have to manually edit the generated templates? Any additional explanation would help. Thanks!

The help for go-msi is below.

USAGE:
   go-msi generate-templates [command options] [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: "C:\\Program Files\\go-msi\\templates")
   --out value, -o value      Directory path to the generated wix templates files (default: "C:\\Users\\me\\AppData\\Local\\Temp\\go-msi806034671")
   --version value            The version of your program
   --license value, -l value  Path to the license file

MSI Repair Option

The created MSI has a repair option. However, the repair option doesn't seem to do anything.

Is there a way to disable the repair option?
Can repair run the install hooks?
Is there a repair hooks I can use ?

Thanks

add support for pre/post inst/un scripts

like rpm/debian package does,

it would be a good thing to provide native support
for those scripts during install/uninstall operations of the package.

TBD

In the manifest, 4 new fields should be provided.
They target some cmd (powershell?) files.
When the package is built, somehow they are integrated in the result so that when the package is run, they are executed appropriately.

TODO

  • Update manifest to add those 4 fields
  • Include those files to the produced msi package
  • Update wix flow files to detect, declare and run those scripts as expected

FYI

Multiple verbose warnings when invoking wix

I get a loooot of these (one per dll or exe) when building my installer:

heat.exe : warning HEAT5150 : Could not harvest data from a file that was expected to be a SelfReg DLL: C:\utf8_and_sjis2004.dll. If this file does not support SelfReg you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: Unable to load file: C:\utf8_and_sjis2004.dll, error: 193

Quite a few of these as well:

C:\Users\appveyor\AppData\Local\Temp\1\go-msi634627459\AppFiles0.wxs(163) : warning LGHT1076 : ICE60: The file fil39C897E7C60A51E43542B8ED7A098F12 is not a Font, and its version is not a companion file reference. It should have a language specified in the Language column.

the executable file does not get into the msi

this is part of my wix.json

  "files": {
    "guid": "378896D8-6749-4821-870A-44CBBB791D0C",
    "items": [
      "service.exe"
    ]
  },
  "directories": [
    "assets"
  ]

service.exe located in the same directory as wix.json, there is one text file in the assets subdirectory. I create an msi, then install this msi, in the directory where the installation was made there is a text file from the assets subdirectory, but there is no exe file. I tried to specify an absolute path in json to files, it didn't help

Windows Installer XML Toolset Linker version 3.11.2.4516

Default Destination Folder

Is there a way to set the default destination folder for the installation of files?

The app that I'm packaging has an expected location that is not in program files. I didn't write the app and can't change that expectation.

Thanks

Travis Windows example

I see an example of use in AppVeyor, but none for Travis Windows.

I think it would be good to provide such example, as the usage of Travis Windows is increasing.

And they are using Git Bash by default, which makes the installation process a little bit different, like a mix of bash and Windows.

`go get github.com/mh-cbon/go-msi` fails.

Error log:

C:\Users\MarvinJWendt>go get github.com/mh-cbon/go-msi
# github.com/mh-cbon/go-msi/manifest
go\src\github.com\mh-cbon\go-msi\manifest\index.go:152:35: multiple-value uuid.NewV4() in single-value context
go\src\github.com\mh-cbon\go-msi\manifest\index.go:156:34: multiple-value uuid.NewV4() in single-value context
go\src\github.com\mh-cbon\go-msi\manifest\index.go:160:32: multiple-value uuid.NewV4() in single-value context
go\src\github.com\mh-cbon\go-msi\manifest\index.go:164:38: multiple-value uuid.NewV4() in single-value context
go\src\github.com\mh-cbon\go-msi\manifest\index.go:251:40: cannot use v.Major() (type uint64) as type int64 in argument to strconv.FormatInt
go\src\github.com\mh-cbon\go-msi\manifest\index.go:252:46: cannot use v.Minor() (type uint64) as type int64 in argument to strconv.FormatInt
go\src\github.com\mh-cbon\go-msi\manifest\index.go:253:46: cannot use v.Patch() (type uint64) as type int64 in argument to strconv.FormatInt

go version go1.14.4 windows/amd64

C:\Users\MarvinJWendt>go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\MarvinJWendt\AppData\Local\go-build
set GOENV=C:\Users\MarvinJWendt\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\MarvinJWendt\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\MARVIN~1\AppData\Local\Temp\go-build157197990=/tmp/go-build -gno-record-gcc-switches

go mod + arm64 windows

>go mod init github.com/mh-cbon/go-msi
go: creating new go.mod: module github.com/mh-cbon/go-msi
go: downloading github.com/Masterminds/semver v1.2.2
go: copying requirements from glide.lock
go: to add module requirements and sums:
        go mod tidy

C:\Downloads\go-msi-1.0.2>go mod tidy

gox -osarch="windows/arm64" 

go-msi-1.0.2-go-mod.zip

can likewise out others

go-msi_windows_arm64.exe is produced.

https://dl.google.com/go/go1.18.windows-arm64.zip is out...

https://www.pcguide.com/windows-11/how-to/install-on-raspberry-pi-4/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.