place WebView2Loader in root resources to guarantee NSIS extraction alongside executable

This commit is contained in:
2026-08-22 21:36:42 -07:00
parent 2f5efe45c4
commit 8f99096bfb
5 changed files with 63 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "vyla-home",
"version": "1.1.1",
"version": "1.1.2",
"description": "Vyla Home Desktop App Launcher",
"main": "main.js",
"scripts": {
@@ -54,4 +54,4 @@
"installerHeaderIcon": "build/icon.ico"
}
}
}
}

View File

@@ -156,10 +156,10 @@ async function main() {
console.log('Ensuring bundled Node.js runtime...');
await ensureBundledNode();
console.log('Compiling Windows Tauri installer locally...');
await ensureWebView2Loader();
execSync('npm run build', {
stdio: 'inherit',
env: Object.assign({}, process.env, { WEBVIEW2_STATIC_LIB: '1' })
stdio: 'inherit'
});
const nsisDir = path.join(__dirname, 'src-tauri/target/release/bundle/nsis');
@@ -238,6 +238,59 @@ function ensureBundledNode() {
});
}
function ensureWebView2Loader() {
const releaseDir = path.join(__dirname, 'src-tauri', 'target', 'release');
const rootDllPath = path.join(__dirname, 'src-tauri', 'WebView2Loader.dll');
fs.mkdirSync(releaseDir, { recursive: true });
const targetDllPath = path.join(releaseDir, 'WebView2Loader.dll');
if (fs.existsSync(rootDllPath) && fs.existsSync(targetDllPath)) {
return Promise.resolve();
}
const AdmZip = require('adm-zip');
const tempNupkg = path.join(__dirname, 'temp-wv2.zip');
const nupkgUrl = 'https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/1.0.2903.40';
return new Promise((resolve, reject) => {
const fileStream = fs.createWriteStream(tempNupkg);
const request = (url) => {
https.get(url, (res) => {
if (res.statusCode === 301 || res.statusCode === 302) {
return request(res.headers.location);
}
res.pipe(fileStream);
fileStream.on('finish', () => {
fileStream.close();
try {
const zip = new AdmZip(tempNupkg);
const zipEntries = zip.getEntries();
const dllEntry = zipEntries.find(e =>
e.entryName.includes('x64/WebView2Loader.dll') ||
e.entryName.includes('x64\\WebView2Loader.dll')
);
if (dllEntry) {
const buffer = dllEntry.getData();
fs.writeFileSync(targetDllPath, buffer);
fs.writeFileSync(rootDllPath, buffer);
}
try { fs.unlinkSync(tempNupkg); } catch (_) { }
resolve();
} catch (e) {
try { fs.unlinkSync(tempNupkg); } catch (_) { }
reject(e);
}
});
}).on('error', (err) => {
try { fs.unlinkSync(tempNupkg); } catch (_) { }
reject(err);
});
};
request(nupkgUrl);
});
}
main().catch(err => {
console.error('Release failed:', err.message);
process.exit(1);

2
src-tauri/Cargo.lock generated
View File

@@ -4222,7 +4222,7 @@ dependencies = [
[[package]]
name = "vyla-home"
version = "1.1.1"
version = "1.1.2"
dependencies = [
"serde",
"serde_json",

View File

@@ -1,6 +1,6 @@
[package]
name = "vyla-home"
version = "1.1.1"
version = "1.1.2"
description = "Vyla Home Desktop App Launcher"
edition = "2021"

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Vyla Home",
"version": "1.1.1",
"version": "1.1.2",
"identifier": "com.vyla.home",
"build": {
"frontendDist": "../ui"
@@ -28,6 +28,7 @@
}
},
"resources": [
"WebView2Loader.dll",
"../bin/*",
"../main.js",
"../service-manager.js",
@@ -39,4 +40,4 @@
"../node_modules/**/*"
]
}
}
}