Skip to content

Commit 0cbf662

Browse files
author
jld3103
authored
Merge pull request #176 from go-flutter-desktop/fix/windows-msi-files-not-included
Fix some files not being included in windows-msi
2 parents fef9cfc + af8014f commit 0cbf662

File tree

7 files changed

+33
-63
lines changed

7 files changed

+33
-63
lines changed

assets/packaging/windows-msi/app.wxs.tmpl

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
<Directory Id="TARGETDIR" Name="SourceDir">
77
<Directory Id="ProgramFilesFolder">
88
<Directory Id="APPLICATIONROOTDIRECTORY" Name="{{.applicationName}}">
9-
<Directory Id="ASSETSDIRECTORY" Name="assets"/>
10-
<Directory Id="FLUTTERASSETSDIRECTORY" Name="flutter_assets">
11-
<?include directories.wxi ?>
12-
</Directory>
9+
<?include directories.wxi ?>
1310
</Directory>
1411
</Directory>
1512
<Directory Id="ProgramMenuFolder">
@@ -18,25 +15,6 @@
1815
</Directory>
1916
<Icon Id="ShortcutIcon" SourceFile="build{{.pathSeparator}}assets{{.pathSeparator}}icon.ico"/>
2017
<Property Id="ARPPRODUCTICON" Value="ShortcutIcon"/>
21-
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
22-
<Component Id="{{.executableName}}.exe" Guid="*">
23-
<File Id="{{.executableName}}.exe" Source="build{{.pathSeparator}}{{.executableName}}.exe" KeyPath="yes"/>
24-
</Component>
25-
<Component Id="flutter_engine.dll" Guid="*">
26-
<File Id="flutter_engine.dll" Source="build{{.pathSeparator}}flutter_engine.dll" KeyPath="yes"/>
27-
</Component>
28-
<Component Id="icudtl.dat" Guid="*">
29-
<File Id="icudtl.dat" Source="build{{.pathSeparator}}icudtl.dat" KeyPath="yes"/>
30-
</Component>
31-
</DirectoryRef>
32-
<DirectoryRef Id="ASSETSDIRECTORY">
33-
<Component Id="icon.png" Guid="*">
34-
<File Id="icon.png" Source="build{{.pathSeparator}}assets{{.pathSeparator}}icon.png" KeyPath="yes"/>
35-
</Component>
36-
<Component Id="icon.ico" Guid="*">
37-
<File Id="icon.ico" Source="build{{.pathSeparator}}assets{{.pathSeparator}}icon.ico" KeyPath="yes"/>
38-
</Component>
39-
</DirectoryRef>
4018
<?include directory_refs.wxi ?>
4119
<DirectoryRef Id="ApplicationProgramsFolder">
4220
<Component Id="ApplicationShortcut" Guid="*">
@@ -51,10 +29,6 @@
5129
</Component>
5230
</DirectoryRef>
5331
<Feature Id="MainApplication" Title="{{.applicationName}}" Level="1">
54-
<ComponentRef Id="{{.executableName}}.exe"/>
55-
<ComponentRef Id="flutter_engine.dll"/>
56-
<ComponentRef Id="icudtl.dat"/>
57-
<ComponentRef Id="icon.png"/>
5832
<ComponentRef Id="ApplicationShortcut"/>
5933
<?include component_refs.wxi ?>
6034
</Feature>

cmd/build.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ func initBuildParameters(targetOS string, defaultBuildOrRunMode build.Mode) {
281281
}
282282

283283
// hover.yaml file needs to be set before accessing config.GetConfig()
284-
if buildOrRunHoverFlavor == "" {
285-
config.SetDefaultHoverYamlFile()
286-
} else {
284+
if buildOrRunHoverFlavor != "" {
287285
config.SetHoverFlavor(buildOrRunHoverFlavor)
288286
}
289287

cmd/packaging/windows-msi.go

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package packaging
22

33
import (
4-
"crypto/rand"
54
"crypto/sha1"
65
"encoding/hex"
76
"fmt"
@@ -14,6 +13,7 @@ import (
1413
"strings"
1514

1615
ico "github.com/Kodeworks/golang-image-ico"
16+
"github.com/google/uuid"
1717

1818
"github.com/go-flutter-desktop/hover/internal/log"
1919
)
@@ -102,14 +102,11 @@ var WindowsMsiTask = &packagingTask{
102102
},
103103
},
104104
generateInitFiles: func(packageName, path string) {
105-
b := make([]byte, 16)
106-
_, err := rand.Read(b)
107-
if err != nil {
108-
log.Errorf("Failed to generate GUID: %v", err)
109-
os.Exit(1)
110-
}
111-
upgradeCode := strings.ToUpper(fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]))
112-
err = ioutil.WriteFile(filepath.Join(path, "upgrade-code.txt"), []byte(fmt.Sprintf("%s\n# This GUID is your upgrade code and ensures that you can properly update your app.\n# Don't change it.", upgradeCode)), 0755)
105+
err := ioutil.WriteFile(
106+
filepath.Join(path, "upgrade-code.txt"),
107+
[]byte(fmt.Sprintf("%s\n# This GUID is your upgrade code and ensures that you can properly update your app.\n# Don't change it.", uuid.New())),
108+
0755,
109+
)
113110
if err != nil {
114111
log.Errorf("Failed to create `upgrade-code.txt` file: %v", err)
115112
os.Exit(1)
@@ -165,7 +162,7 @@ var WindowsMsiTask = &packagingTask{
165162
directoriesFileContent = append(directoriesFileContent, "<Include>")
166163
directoryRefsFileContent = append(directoryRefsFileContent, "<Include>")
167164
componentRefsFileContent = append(componentRefsFileContent, "<Include>")
168-
windowsMsiProcessFiles(filepath.Join(tmpPath, "build", "flutter_assets"))
165+
windowsMsiProcessFiles(filepath.Join(tmpPath, "build"))
169166
directoriesFileContent = append(directoriesFileContent, "</Include>")
170167
directoryRefsFileContent = append(directoryRefsFileContent, "</Include>")
171168
componentRefsFileContent = append(componentRefsFileContent, "</Include>")
@@ -216,11 +213,11 @@ func windowsMsiProcessFiles(path string) {
216213

217214
for _, f := range files {
218215
p := filepath.Join(path, f.Name())
219-
relativePath := strings.Split(strings.Split(p, "flutter_assets"+pathSeparator)[1], pathSeparator)
216+
relativePath := strings.Split(strings.Split(p, "build"+pathSeparator)[1], pathSeparator)
220217
id := hashSha1(strings.Join(relativePath, ""))
221218
if f.IsDir() {
222219
directoriesFileContent = append(directoriesFileContent,
223-
fmt.Sprintf(`<Directory Id="FLUTTERASSETSDIRECTORY_%s" Name="%s">`, id, f.Name()),
220+
fmt.Sprintf(`<Directory Id="APPLICATIONROOTDIRECTORY_%s" Name="%s">`, id, f.Name()),
224221
)
225222
windowsMsiProcessFiles(p)
226223
directoriesFileContent = append(directoriesFileContent,
@@ -229,22 +226,22 @@ func windowsMsiProcessFiles(path string) {
229226
} else {
230227
if len(relativePath) > 1 {
231228
directoryRefsFileContent = append(directoryRefsFileContent,
232-
fmt.Sprintf(`<DirectoryRef Id="FLUTTERASSETSDIRECTORY_%s">`, hashSha1(strings.Join(relativePath[:len(relativePath)-1], ""))),
229+
fmt.Sprintf(`<DirectoryRef Id="APPLICATIONROOTDIRECTORY_%s">`, hashSha1(strings.Join(relativePath[:len(relativePath)-1], ""))),
233230
)
234231
} else {
235232
directoryRefsFileContent = append(directoryRefsFileContent,
236-
`<DirectoryRef Id="FLUTTERASSETSDIRECTORY">`,
233+
`<DirectoryRef Id="APPLICATIONROOTDIRECTORY">`,
237234
)
238235
}
239-
fileSource := filepath.Join("build", "flutter_assets", strings.Join(relativePath, pathSeparator))
236+
fileSource := filepath.Join("build", strings.Join(relativePath, pathSeparator))
240237
directoryRefsFileContent = append(directoryRefsFileContent,
241-
fmt.Sprintf(`<Component Id="flutter_assets_%s" Guid="*">`, id),
242-
fmt.Sprintf(`<File Id="flutter_assets_%s" Source="%s" KeyPath="yes"/>`, id, fileSource),
238+
fmt.Sprintf(`<Component Id="build_%s" Guid="%s">`, id, uuid.New()),
239+
fmt.Sprintf(`<File Id="build_%s" Source="%s" KeyPath="yes"/>`, id, fileSource),
243240
"</Component>",
244241
"</DirectoryRef>",
245242
)
246243
componentRefsFileContent = append(componentRefsFileContent,
247-
fmt.Sprintf(`<ComponentRef Id="flutter_assets_%s"/>`, id),
244+
fmt.Sprintf(`<ComponentRef Id="build_%s"/>`, id),
248245
)
249246
}
250247
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/daaku/go.zipexe v1.0.1 // indirect
1010
github.com/google/go-github v17.0.0+incompatible // indirect
1111
github.com/google/go-querystring v1.0.0 // indirect
12+
github.com/google/uuid v1.1.2
1213
github.com/hashicorp/go-version v1.2.1
1314
github.com/logrusorgru/aurora v2.0.3+incompatible
1415
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi
7878
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
7979
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
8080
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
81+
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
82+
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
8183
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
8284
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
8385
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=

internal/config/flavor.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ var hoverYaml string
1313

1414
// GetHoverFlavorYaml returns the Hover yaml file
1515
func GetHoverFlavorYaml() string {
16+
if len(hoverYaml) == 0 {
17+
hoverYaml = "hover.yaml"
18+
}
1619
return hoverYaml
1720
}
1821

19-
// SetDefaultFlavorFile sets the default hover.yaml
20-
func SetDefaultHoverYamlFile() {
21-
hoverYaml = "hover.yaml"
22-
}
23-
2422
// SetHoverFlavor sets the user defined hover flavor.
2523
// eg. hover-develop.yaml, hover-staging.yaml, etc.
2624
func SetHoverFlavor(flavor string) {

internal/fileutils/rice-box.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)