Skip to content

Commit a1a1699

Browse files
committed
WinGet (zip)
1 parent 6b067e2 commit a1a1699

File tree

5 files changed

+92
-26
lines changed

5 files changed

+92
-26
lines changed

Wix/1.0.9.0/StefHeyenrath.GitHubReleaseNotes.installer.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
PackageIdentifier: StefHeyenrath.GitHubReleaseNotes
44
PackageVersion: 1.0.9.0
5-
InstallerLocale: en-US
6-
InstallerType: msi
5+
InstallerType: zip
6+
NestedInstallerType: portable
7+
NestedInstallerFiles:
8+
- RelativeFilePath: GitHubReleaseNotes.exe
79
ProductCode: '{32249977-C6C1-40ED-B6A8-7084E69A0E7A}'
8-
ReleaseDate: 2024-02-01
9-
AppsAndFeaturesEntries:
10-
- UpgradeCode: '{C6C9F090-5E9F-4E30-B9D1-43238271456F}'
10+
ReleaseDate: 2024-02-02
1111
Installers:
1212
- Architecture: x64
13-
InstallerUrl: https://github.com/StefH/GitHubReleaseNotes/releases/download/1.0.9.0/Setup.msi
14-
InstallerSha256: 89202CCCCBA257BAFC7376B055E20DFC518759BD22D8E0D518120082FA3D69D1
13+
InstallerUrl: https://github.com/StefH/GitHubReleaseNotes/releases/download/1.0.9.0/GitHubReleaseNotes.zip
14+
InstallerSha256: 26C3558610A7FBAB818C70560B28DF11636057D8DDFEEF0D11D0001A8729F619
1515
ManifestType: installer
1616
ManifestVersion: 1.5.0

Wix/HowTo.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
# HowTo
1+
# HowTo - WinGet
22

33
## Update release
44
Do Chocolatey first
55

66
## Update version
7-
Use LinqPad on `generate guid.linq` to generate + update the product guid and the upgrade guid.
8-
9-
## Build setup
10-
Build setup project
7+
Use LinqPad on `generate guid.linq` to generate the product guid and + update the upgrade guid.
118

129
## Generate yaml
1310
Use LinqPad on `generate files.linq` to generate the 3 yaml files.
1411

1512
## Add yaml
16-
Add the 3 new yaml files to the soluton in the "Wix and winget-pkgs" folder
13+
Add the 3 new yaml files to the soluton in the "winget-pkgs" folder
1714

1815
## Verify : Validate
1916
Do a `winget validate --manifest {version}`
2017

2118
## Upload
22-
Create the new version (tag) and upload setup to https://github.com/StefH/GitHubReleaseNotes/releases
19+
Create the new version (tag) and upload 'zip' to https://github.com/StefH/GitHubReleaseNotes/releases
2320

2421
### Verify Install + Uninstall
2522
Do a `winget install --manifest {version}`
@@ -28,4 +25,17 @@ Do a `winget uninstall --manifest {version}`
2825
## winget-pkgs
2926
Create a PR with the new {version}.yaml in https://github.com/StefH/winget-pkgs
3027

31-
Use the "." key on GitHub StefH/winget-pkgs to start VS Code and create a folder + add yaml.
28+
Use the "." key on GitHub StefH/winget-pkgs to start VS Code and create a folder + add 3 yamls.
29+
30+
31+
32+
--------------------------------
33+
34+
35+
# HowTo - WinGet
36+
37+
## Build setup
38+
Build setup project
39+
40+
## Upload
41+
Upload the wix setup to https://github.com/StefH/GitHubReleaseNotes/releases

Wix/generate files.linq

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ string folder = Path.GetDirectoryName(Util.CurrentQueryPath);
77
string chocolateyFolder = Path.Combine(folder, "../", "Chocolatey", "GithubReleaseNotes");
88
string projectFolder = Path.Combine(chocolateyFolder, "../", "../");
99

10-
string exe = Path.Combine(projectFolder, "src", "GitHubReleaseNotes", "bin", "release", "net48", "GitHubReleaseNotes.exe");
10+
string outputFolder = Path.Combine(projectFolder, "src", "GitHubReleaseNotes", "bin", "release", "net48");
11+
string exe = Path.Combine(outputFolder, "GitHubReleaseNotes.exe");
12+
string zip = Path.Combine(outputFolder, "GitHubReleaseNotes.zip");
1113

1214
var doc = new XmlDocument();
1315
doc.Load(Path.Combine(chocolateyFolder, "GitHubReleaseNotes.nuspec"));
1416

1517
string version = doc["package"]["metadata"]["version"].FirstChild.Value;
16-
string msi = Path.Combine(folder, "Setup", "bin", "release", "Setup.msi");
18+
// string msi = Path.Combine(folder, "Setup", "bin", "release", "Setup.msi");
1719

1820
var fi = new FileInfo(exe);
1921
string dateModified = fi.LastWriteTime.ToString("yyyy-MM-dd");
@@ -22,7 +24,7 @@ string CreateSHA256()
2224
{
2325
var crypt = new System.Security.Cryptography.SHA256Managed();
2426
var hash = new System.Text.StringBuilder();
25-
byte[] crypto = crypt.ComputeHash(File.ReadAllBytes(msi));
27+
byte[] crypto = crypt.ComputeHash(File.ReadAllBytes(zip));
2628
foreach (byte theByte in crypto)
2729
{
2830
hash.Append(theByte.ToString("x2"));
@@ -31,23 +33,23 @@ string CreateSHA256()
3133
}
3234

3335
string productCode = $"{{{File.ReadAllText(Path.Combine(folder, "productGuid.txt"))}}}";
34-
string upgradeCode = $"{{{File.ReadAllText(Path.Combine(folder, "upgradeGuid.txt"))}}}";
36+
// string upgradeCode = $"{{{File.ReadAllText(Path.Combine(folder, "upgradeGuid.txt"))}}}";
3537

3638
// StefHeyenrath.GitHubReleaseNotes.installer.yaml
3739
string installerText =
3840
$@"# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.5.0.schema.json
3941
4042
PackageIdentifier: StefHeyenrath.GitHubReleaseNotes
4143
PackageVersion: {version}
42-
InstallerLocale: en-US
43-
InstallerType: msi
44+
InstallerType: zip
45+
NestedInstallerType: portable
46+
NestedInstallerFiles:
47+
- RelativeFilePath: GitHubReleaseNotes.exe
4448
ProductCode: '{productCode}'
4549
ReleaseDate: {dateModified}
46-
AppsAndFeaturesEntries:
47-
- UpgradeCode: '{upgradeCode}'
4850
Installers:
4951
- Architecture: x64
50-
InstallerUrl: https://github.com/StefH/GitHubReleaseNotes/releases/download/{version}/Setup.msi
52+
InstallerUrl: https://github.com/StefH/GitHubReleaseNotes/releases/download/{version}/GitHubReleaseNotes.zip
5153
InstallerSha256: {CreateSHA256()}
5254
ManifestType: installer
5355
ManifestVersion: 1.5.0";

src/GitHubReleaseNotes.sln

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{EC3EE34B
4242
..\Chocolatey\GitHubReleaseNotes\tools\VERIFICATION.txt = ..\Chocolatey\GitHubReleaseNotes\tools\VERIFICATION.txt
4343
EndProjectSection
4444
EndProject
45-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wix and winget-pkgs", "Wix and winget-pkgs", "{1D8E407B-B13C-4377-8D6E-76521411105D}"
45+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "winget-pkgs", "winget-pkgs", "{1D8E407B-B13C-4377-8D6E-76521411105D}"
4646
ProjectSection(SolutionItems) = preProject
4747
..\Wix\generate files.linq = ..\Wix\generate files.linq
4848
..\Wix\generate guid.linq = ..\Wix\generate guid.linq
@@ -64,6 +64,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1.0.9.0", "1.0.9.0", "{CB61
6464
..\Wix\1.0.9.0\StefHeyenrath.GitHubReleaseNotes.yaml = ..\Wix\1.0.9.0\StefHeyenrath.GitHubReleaseNotes.yaml
6565
EndProjectSection
6666
EndProject
67+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wix [not used anymore]", "Wix [not used anymore]", "{E0D35E17-7751-4C7E-BA6E-86F475EA54D9}"
68+
EndProject
6769
Global
6870
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6971
Debug|Any CPU = Debug|Any CPU
@@ -118,7 +120,7 @@ Global
118120
{B6269AAC-170A-43D0-8B9B-579DED3D9A00} = {EF77BB40-C919-4644-81A3-968854FB9B23}
119121
{B6269AAC-170A-43D0-8B9B-579DED3D9A99} = {EF77BB40-C919-4644-81A3-968854FB9B23}
120122
{EC3EE34B-AC6A-4051-90D8-BECA56E110CE} = {13B407F6-F183-4D36-8218-497AF9C05280}
121-
{9456D153-CBDD-470B-9BFF-17C145ED9C24} = {1D8E407B-B13C-4377-8D6E-76521411105D}
123+
{9456D153-CBDD-470B-9BFF-17C145ED9C24} = {E0D35E17-7751-4C7E-BA6E-86F475EA54D9}
122124
{E851802A-C1F1-47BB-8725-1FD1868CC6EB} = {EF77BB40-C919-4644-81A3-968854FB9B23}
123125
{A50D0A88-AC3D-455E-9048-B9BF6E6E2E5F} = {EF77BB40-C919-4644-81A3-968854FB9B23}
124126
{CB61AA1D-6C90-4002-939F-77ABB1830CE4} = {1D8E407B-B13C-4377-8D6E-76521411105D}

src/GitHubReleaseNotes/GitHubReleaseNotes.csproj

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,56 @@
2424
</ProjectReference>
2525
</ItemGroup>
2626

27+
<Target Name="Zip" AfterTargets="Build">
28+
<Zip
29+
SourceFile="$(OutputPath)\$(AssemblyName).exe"
30+
ZipFileName="$(OutputPath)\$(AssemblyName).zip"
31+
/>
32+
</Target>
33+
34+
<UsingTask TaskName="Zip" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
35+
<ParameterGroup>
36+
<SourceFile ParameterType="System.String" Required="true" />
37+
<ZipFileName ParameterType="System.String" Required="true" />
38+
</ParameterGroup>
39+
40+
<Task>
41+
<Reference Include="System.IO.Compression.FileSystem" />
42+
<Using Namespace="System.IO.Compression" />
43+
<Code Type="Fragment" Language="cs">
44+
<![CDATA[
45+
try
46+
{
47+
Log.LogMessage(string.Format("Zipping file {0} to {1}", SourceFile, ZipFileName));
48+
49+
// Temporarily create a directory to hold the file to be zipped
50+
string tempFolder = Path.Combine(Path.GetDirectoryName(SourceFile), Path.GetFileNameWithoutExtension(SourceFile) + "_temp");
51+
Directory.CreateDirectory(tempFolder);
52+
53+
// Copy the source file to the temp directory
54+
string tempFilePath = Path.Combine(tempFolder, Path.GetFileName(SourceFile));
55+
File.Copy(SourceFile, tempFilePath, true);
56+
57+
// Create a zip archive that contains the file in the temp directory
58+
if (File.Exists(ZipFileName))
59+
{
60+
File.Delete(ZipFileName); // Ensure we are creating a new zip file
61+
}
62+
ZipFile.CreateFromDirectory(tempFolder, ZipFileName);
63+
64+
// Clean up the temp directory
65+
Directory.Delete(tempFolder, true);
66+
67+
return true;
68+
}
69+
catch(Exception ex)
70+
{
71+
Log.LogErrorFromException(ex);
72+
return false;
73+
}
74+
]]>
75+
</Code>
76+
</Task>
77+
</UsingTask>
78+
2779
</Project>

0 commit comments

Comments
 (0)