Skip to content

Commit

Permalink
feat(build): bundle vcredist
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed May 12, 2023
1 parent c84e08a commit 7f4392b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const versionNode = '16.19.1'
export const versionYarn = '3.5.0'

export const versionWebView2 = '1.0.1343.22'
export const versionMSVC = '14.34.31931'
export const versionAppimagetool = '13'

export const versionToolsVersioninfo = 'v1.4.0'
Expand Down
18 changes: 14 additions & 4 deletions packages/build/tasks/pack/unfold.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { series } from 'gulp'
import mkdirp from 'mkdirp'
import fs from 'node:fs/promises'
import { join } from 'node:path'
import { sleep } from '../../utils/common'
import { zip } from '../../utils/compress'
import { exists } from '../../utils/fs'
import { versionMSVC } from '../../utils/config'
import { dir } from '../../utils/path'
import { exec } from '../../utils/spawn'

Expand Down Expand Up @@ -32,17 +33,26 @@ export const packUnfoldDataCopy = async () => {
recursive: true,
})

// Copy Edge/WV2 setup for Windows
if (await exists(dir('buildCache', 'MicrosoftEdgeSetup.exe')))
if (process.platform === 'win32') {
// Copy Edge/WV2 setup
await fs.copyFile(
dir('buildCache', 'MicrosoftEdgeSetup.exe'),
dir('buildUnfoldBinary', 'MicrosoftEdgeSetup.exe')
)
if (await exists(dir('buildCache', 'Webview2Setup.exe')))
await fs.copyFile(
dir('buildCache', 'Webview2Setup.exe'),
dir('buildUnfoldBinary', 'Webview2Setup.exe')
)

// Copy VCRedist
await fs.copyFile(
join(
process.env['PROGRAMFILES']!,
`Microsoft Visual Studio/2022/Enterprise/VC/Redist/MSVC/${versionMSVC}/MergeModules/Microsoft_VC143_CRT_x64.msm`
),
dir('buildUnfoldBinary', 'Microsoft_VC143_CRT_x64.msm')
)
}
}

export const packUnfoldDataZip = async () => {
Expand Down
18 changes: 18 additions & 0 deletions packages/build/templates/msi/index.wxs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
/>
</Component>

<Merge
Id="ComponentVCRedist"
SourceFile="SourceDir\Microsoft_VC143_CRT_x64.msm"
Language="0"
/>

<Directory Id="DirectoryInstallBinary" Name="bin">
<Component
Id="ComponentDirectoryInstallBinary"
Expand Down Expand Up @@ -225,6 +231,18 @@
<ComponentRef Id="ComponentDirectoryProgramMenuFolder" />
</Feature>

<Feature
Id="FeatureVCRedist"
Title="Visual C++ Runtime"
Description="Visual C++ runtime. Required for Koishi Desktop Shell."
Level="1"
Absent="disallow"
InstallDefault="local"
AllowAdvertise="no"
>
<MergeRef Id="ComponentVCRedist" />
</Feature>

<Feature
Id="FeatureDesktopIcon"
Title="Desktop Icon"
Expand Down

0 comments on commit 7f4392b

Please sign in to comment.