diff --git a/manifest/index.go b/manifest/index.go index 6335a8f..9787f05 100644 --- a/manifest/index.go +++ b/manifest/index.go @@ -25,6 +25,7 @@ type WixManifest struct { UpgradeCode string `json:"upgrade-code"` Files WixFiles `json:"files,omitempty"` Directories []string `json:"directories,omitempty"` + DirNames []string `json:"-"` RelDirs []string `json:"-"` Env WixEnvList `json:"env,omitempty"` Shortcuts WixShortcuts `json:"shortcuts,omitempty"` @@ -205,6 +206,7 @@ func (wixFile *WixManifest) RewriteFilePaths(out string) error { } } for _, d := range wixFile.Directories { + wixFile.DirNames = append(wixFile.DirNames, cleanDirectoryName(d)) d, err = filepath.Abs(d) if err != nil { return err @@ -230,6 +232,14 @@ func (wixFile *WixManifest) RewriteFilePaths(out string) error { return nil } +// cleanDirectoryName replaces invalid characters in directory names. +func cleanDirectoryName(name string) string { + to := "-" + repl := strings.NewReplacer( + `\`, to, "?", to, "|", to, ">", to, "<", to, ":", to, "/", to, "*", to, `"`, to) + return repl.Replace(name) +} + // Normalize Appropriately fixes some values within the decoded json // It applies defaults values on the wix/msi property to // to generate the msi package. diff --git a/templates/product.wxs b/templates/product.wxs index 072454b..5f3f84e 100644 --- a/templates/product.wxs +++ b/templates/product.wxs @@ -38,8 +38,8 @@ {{end}} {{end}} - {{if gt (.Directories | len) 0}} - {{range $i, $e := .Directories}} + {{if gt (.DirNames | len) 0}} + {{range $i, $e := .DirNames}} {{end}} {{end}}