Skip to content

Commit

Permalink
Add Microsoft Visual C++ Redistributable installation support
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Nov 9, 2024
1 parent 29ac0ea commit af3374f
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 19 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ jobs:
# & "C:\Program Files (x86)\WiX Toolset v3.11\bin\heat.exe" dir target\wix\gtk4 -gg -sfrag -template:fragment -out target\wix\gtk4.wxs -cg GTK -dr GTK
cargo wix --target ${{ matrix.build.target }} --profile production --no-build --nocapture
# Create bundle with Microsoft Visual C++ Redistributable in it
Remove-Item target\wix\space-acres.wixobj -Confirm:$false
cargo wix --profile release --no-build --nocapture --include res\windows\wix\bundle.wxs -C -ext -C WixBalExtension
Remove-Item target\wix\gtk4 -Recurse -Confirm:$false -ErrorAction SilentlyContinue
if: runner.os == 'Windows'
Expand All @@ -333,7 +336,7 @@ jobs:
dotnet tool install --global AzureSignTool
(Get-ChildItem -Path target\wix -Include space-acres-*.msi -Recurse) | ForEach-Object {
(Get-ChildItem -Path target\wix -Include space-acres-*.exe -Recurse) | ForEach-Object {
Write("Signing $($_)");
AzureSignTool sign --azure-key-vault-url "${{ secrets.AZURE_KEY_VAULT_URI }}" --azure-key-vault-client-id "${{ secrets.AZURE_CLIENT_ID }}" --azure-key-vault-client-secret "${{ secrets.AZURE_CLIENT_SECRET }}" --azure-key-vault-tenant-id "${{ secrets.AZURE_TENANT_ID }}" --azure-key-vault-certificate "${{ secrets.AZURE_CERT_NAME }}" --file-digest sha512 --timestamp-rfc3161 http://timestamp.digicert.com -v $($_);
Expand Down Expand Up @@ -433,7 +436,7 @@ jobs:
with:
name: installer-${{ matrix.build.suffix }}
path: |
target/wix/*.msi
target/wix/*.exe
if-no-files-found: error
if: runner.os == 'Windows'

Expand All @@ -442,6 +445,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["target/wix/*.msi"]'
asset_paths: '["target/wix/*.exe"]'
if: runner.os == 'Windows' && github.event_name == 'push' && github.ref_type == 'tag'

92 changes: 92 additions & 0 deletions res/windows/wix/bundle.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version='1.0' encoding='windows-1252'?>
<!--
The "cargo wix" subcommand provides a variety of predefined variables available
for customization of this template. The values for each variable are set at
installer creation time. The following variables are available:
TargetTriple = The rustc target triple name.
TargetEnv = The rustc target environment. This is typically either
"msvc" or "gnu" depending on the toolchain downloaded and
installed.
TargetVendor = The rustc target vendor. This is typically "pc", but Rust
does support other vendors, like "uwp".
CargoTargetBinDir = The complete path to the directory containing the
binaries (exes) to include. The default would be
"target\release\". If an explicit rustc target triple is
used, i.e. cross-compiling, then the default path would
be "target\<CARGO_TARGET>\<CARGO_PROFILE>",
where "<CARGO_TARGET>" is replaced with the "CargoTarget"
variable value and "<CARGO_PROFILE>" is replaced with the
value from the "CargoProfile" variable. This can also
be overridden manually with the "target-bin-dir" flag.
CargoTargetDir = The path to the directory for the build artifacts, i.e.
"target".
CargoProfile = The cargo profile used to build the binaries
(usually "debug" or "release").
Version = The version for the installer. The default is the
"Major.Minor.Fix" semantic versioning number of the Rust
package.
-->

<?if $(var.Platform) = "x64" ?>
<?define Arch = "x86_64" ?>
<?else ?>
<?define Arch = "arm64" ?>
<?endif ?>

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
xmlns:bal='http://schemas.microsoft.com/wix/BalExtension'
xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
<Bundle
Name='Space Acres'
IconSourceFile='res\windows\space-acres.ico'
UpgradeCode='ba3cd06f-3967-4bdf-ae00-aa538249fd5a'
Manufacturer='Nazar Mokrynskyi'
Version='$(var.Version)'>
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense" >
<bal:WixStandardBootstrapperApplication
LicenseUrl=""
LogoFile="res\windows\wix\icon.png"
SuppressOptionsUI="yes"
/>
</BootstrapperApplicationRef>

<!-- Microsoft Visual C++ 2015-2022 Redistributable (x64) runtime msi package version -->
<util:ProductSearch
Id="VCRedistVersionFound"
Result="version"
Variable="VCRedistVersionFound"
UpgradeCode="36F68A90-239C-34DF-B58C-64B30153CE35" />

<!-- Microsoft Visual C++ 2015-2022 Redistributable version -->
<Variable Name="VCRedistVersionDesired" Type="version" Value="14.40.33816.0" />

<Chain>
<MsiPackage
Id="SpaceAcres"
Compressed="yes"
SourceFile="$(var.CargoTargetDir)\wix\space-acres-$(var.Version)-$(var.Arch).msi"
DisplayInternalUI="yes"
Visible="no"
/>

<ExePackage
Id="vc_redist.x64.exe"
Name="vc_redist.x64.14.40.33816.0.exe"
Cache="no"
Compressed="no"
PerMachine="yes"
Permanent="yes"
DetectCondition="VCRedistVersionFound >= VCRedistVersionDesired"
DownloadUrl="https://download.visualstudio.microsoft.com/download/pr/368cc6bf-087b-49f9-93e6-ab05b70a58e0/814E9DA5EC5E5D6A8FA701999D1FC3BADDF7F3ADC528E202590E9B1CB73E4A11/VC_redist.x64.exe"
InstallCommand="/install /passive /norestart" >
<RemotePayload
ProductName="Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33816"
Description="Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33816"
Version="14.40.33816.0"
Hash="ba92a00f0f55dcae85c1bbd098efe606bd080b3c"
Size="25502344" />
</ExePackage>
</Chain>
</Bundle>
</Wix>
Binary file added res/windows/wix/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 0 additions & 16 deletions res/windows/wix/space-acres.wxs
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
<?xml version='1.0' encoding='windows-1252'?>
<!--
Copyright (C) 2017 Christopher R. Field.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--
The "cargo wix" subcommand provides a variety of predefined variables available
for customization of this template. The values for each variable are set at
Expand Down

0 comments on commit af3374f

Please sign in to comment.