windows-development-sandbox 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +22 -6
- package/config.example.json +17 -0
- package/dist/api.js +2 -1
- package/dist/cli/args.d.ts +20 -0
- package/dist/cli/args.js +35 -3
- package/dist/cli/colors.d.ts +24 -0
- package/dist/cli/colors.js +42 -0
- package/dist/cli/commands/agent-commands.d.ts +6 -0
- package/dist/cli/commands/agent-commands.js +61 -0
- package/dist/cli/commands/context.d.ts +2 -0
- package/dist/cli/commands/context.js +3 -0
- package/dist/cli/commands/data/clean.d.ts +15 -0
- package/dist/cli/commands/data/clean.js +101 -0
- package/dist/cli/commands/data/collect.d.ts +11 -0
- package/dist/cli/commands/data/collect.js +54 -0
- package/dist/cli/commands/data/index.d.ts +4 -0
- package/dist/cli/commands/data/index.js +45 -0
- package/dist/cli/commands/data/remove.d.ts +2 -0
- package/dist/cli/commands/data/remove.js +30 -0
- package/dist/cli/commands/index.d.ts +5 -3
- package/dist/cli/commands/index.js +5 -3
- package/dist/cli/commands/launch.d.ts +26 -2
- package/dist/cli/commands/launch.js +220 -39
- package/dist/cli/commands/maintenance.js +33 -4
- package/dist/cli/commands/project.d.ts +29 -0
- package/dist/cli/commands/project.js +63 -0
- package/dist/cli/commands/projects.d.ts +14 -0
- package/dist/cli/commands/projects.js +146 -0
- package/dist/cli/commands/repair/checks.d.ts +2 -0
- package/dist/cli/commands/{repair.js → repair/checks.js} +19 -181
- package/dist/cli/commands/{repair.d.ts → repair/finders.d.ts} +0 -29
- package/dist/cli/commands/repair/finders.js +108 -0
- package/dist/cli/commands/repair/index.d.ts +12 -0
- package/dist/cli/commands/repair/index.js +61 -0
- package/dist/cli/commands/repair/types.d.ts +26 -0
- package/dist/cli/commands/repair/types.js +3 -0
- package/dist/cli/commands/restart.d.ts +6 -0
- package/dist/cli/commands/restart.js +85 -0
- package/dist/cli/commands/sessions.d.ts +2 -1
- package/dist/cli/commands/sessions.js +189 -45
- package/dist/cli/commands/setup/checks.d.ts +13 -0
- package/dist/cli/commands/setup/checks.js +71 -0
- package/dist/cli/commands/{setup.d.ts → setup/facts.d.ts} +1 -15
- package/dist/cli/commands/setup/facts.js +60 -0
- package/dist/cli/commands/setup/index.d.ts +2 -0
- package/dist/cli/commands/setup/index.js +43 -0
- package/dist/cli/commands/user-config.d.ts +8 -0
- package/dist/cli/commands/user-config.js +41 -0
- package/dist/cli/history.d.ts +11 -0
- package/dist/cli/history.js +21 -0
- package/dist/cli/index.d.ts +7 -1
- package/dist/cli/index.js +38 -13
- package/dist/cli/manifest.d.ts +8 -0
- package/dist/cli/manifest.js +35 -15
- package/dist/cli/menu-multi.d.ts +12 -0
- package/dist/cli/menu-multi.js +82 -0
- package/dist/cli/menu.d.ts +5 -13
- package/dist/cli/menu.js +149 -46
- package/dist/cli/progress.d.ts +9 -0
- package/dist/cli/progress.js +49 -0
- package/dist/cli/settings/edit.d.ts +13 -0
- package/dist/cli/settings/edit.js +19 -0
- package/dist/cli/settings/index.d.ts +8 -0
- package/dist/cli/settings/index.js +131 -0
- package/dist/cli/settings/prompts.d.ts +7 -0
- package/dist/cli/settings/prompts.js +48 -0
- package/dist/cli/settings/schema.d.ts +33 -0
- package/dist/cli/settings/schema.js +29 -0
- package/dist/cli/validate.d.ts +17 -0
- package/dist/cli/validate.js +89 -0
- package/dist/core/config.js +4 -1
- package/dist/core/disk.d.ts +16 -0
- package/dist/core/disk.js +55 -0
- package/dist/core/local-config.d.ts +8 -0
- package/dist/core/local-config.js +18 -5
- package/dist/core/project-policy.d.ts +15 -0
- package/dist/core/project-policy.js +35 -0
- package/dist/core/prompt.d.ts +4 -0
- package/dist/core/prompt.js +15 -0
- package/dist/core/safe-paths.d.ts +4 -0
- package/dist/core/safe-paths.js +37 -0
- package/dist/core/schema/common.d.ts +17 -0
- package/dist/core/schema/common.js +15 -0
- package/dist/core/schema/config.d.ts +594 -0
- package/dist/core/schema/config.js +63 -0
- package/dist/core/schema/databases.d.ts +33 -0
- package/dist/core/schema/databases.js +35 -0
- package/dist/core/schema/harness.d.ts +12 -0
- package/dist/core/schema/harness.js +17 -0
- package/dist/core/schema/json-schema.d.ts +5 -0
- package/dist/core/schema/json-schema.js +25 -0
- package/dist/core/schema/profile.d.ts +27 -0
- package/dist/core/schema/profile.js +29 -0
- package/dist/core/schema/projects.d.ts +9 -0
- package/dist/core/schema/projects.js +11 -0
- package/dist/core/schema/sandbox.d.ts +50 -0
- package/dist/core/schema/sandbox.js +36 -0
- package/dist/core/schema/toolchains.d.ts +93 -0
- package/dist/core/schema/toolchains.js +83 -0
- package/dist/core/schema.d.ts +6 -604
- package/dist/core/schema.js +8 -264
- package/dist/core/types.d.ts +29 -1
- package/dist/core/util.d.ts +7 -0
- package/dist/core/util.js +12 -3
- package/dist/core/workspace.d.ts +0 -5
- package/dist/core/workspace.js +12 -46
- package/dist/guest/boot-env.d.ts +4 -0
- package/dist/guest/boot-env.js +25 -0
- package/dist/guest/cmdline.d.ts +12 -0
- package/dist/guest/cmdline.js +23 -0
- package/dist/guest/daemon/exec.d.ts +5 -0
- package/dist/guest/daemon/exec.js +32 -0
- package/dist/guest/daemon/project.d.ts +14 -0
- package/dist/guest/daemon/project.js +132 -0
- package/dist/guest/daemon/session.d.ts +13 -0
- package/dist/guest/daemon/session.js +139 -0
- package/dist/guest/daemon/shutdown.d.ts +1 -0
- package/dist/guest/daemon/shutdown.js +21 -0
- package/dist/guest/daemon/state.d.ts +17 -0
- package/dist/guest/daemon/state.js +31 -0
- package/dist/guest/daemon.js +8 -141
- package/dist/guest/db.js +18 -3
- package/dist/guest/env.d.ts +2 -0
- package/dist/guest/env.js +4 -2
- package/dist/guest/guide.d.ts +6 -2
- package/dist/guest/guide.js +5 -4
- package/dist/guest/helpers.d.ts +3 -0
- package/dist/guest/helpers.js +26 -0
- package/dist/guest/main.js +17 -7
- package/dist/guest/ports.d.ts +6 -0
- package/dist/guest/ports.js +22 -0
- package/dist/guest/project-context.d.ts +7 -0
- package/dist/guest/project-context.js +10 -0
- package/dist/guest/project-env.d.ts +20 -0
- package/dist/guest/project-env.js +20 -0
- package/dist/guest/project-status.d.ts +5 -0
- package/dist/guest/project-status.js +17 -0
- package/dist/guest/ptyhost.d.ts +0 -18
- package/dist/guest/ptyhost.js +5 -63
- package/dist/guest/setup/agents.d.ts +5 -2
- package/dist/guest/setup/agents.js +22 -8
- package/dist/guest/setup/claude.js +11 -3
- package/dist/guest/setup/environment.d.ts +13 -3
- package/dist/guest/setup/environment.js +14 -10
- package/dist/guest/setup/hooks.d.ts +9 -1
- package/dist/guest/setup/hooks.js +28 -14
- package/dist/guest/toolchains/catalogue.d.ts +4 -0
- package/dist/guest/toolchains/catalogue.js +2 -2
- package/dist/guest/toolchains/cli.js +25 -17
- package/dist/guest/toolchains/common.d.ts +18 -1
- package/dist/guest/toolchains/common.js +34 -11
- package/dist/guest/toolchains/databases/dynamodb.d.ts +8 -0
- package/dist/guest/toolchains/databases/dynamodb.js +52 -0
- package/dist/guest/toolchains/{databases.d.ts → databases/index.d.ts} +2 -3
- package/dist/guest/toolchains/databases/index.js +62 -0
- package/dist/guest/toolchains/databases/mongodb.d.ts +3 -0
- package/dist/guest/toolchains/databases/mongodb.js +31 -0
- package/dist/guest/toolchains/databases/mysql.d.ts +3 -0
- package/dist/guest/toolchains/databases/mysql.js +38 -0
- package/dist/guest/toolchains/databases/postgres.d.ts +5 -0
- package/dist/guest/toolchains/databases/postgres.js +38 -0
- package/dist/guest/toolchains/databases/redis.d.ts +3 -0
- package/dist/guest/toolchains/databases/redis.js +16 -0
- package/dist/guest/toolchains/databases/server.d.ts +14 -0
- package/dist/guest/toolchains/databases/server.js +52 -0
- package/dist/guest/toolchains/git.js +25 -16
- package/dist/guest/toolchains/go.js +1 -1
- package/dist/guest/toolchains/index.d.ts +13 -9
- package/dist/guest/toolchains/index.js +40 -82
- package/dist/guest/toolchains/java.js +5 -5
- package/dist/guest/toolchains/leftovers.d.ts +2 -0
- package/dist/guest/toolchains/leftovers.js +26 -0
- package/dist/guest/toolchains/managers.js +12 -10
- package/dist/guest/toolchains/{binstall.js → native/binstall.js} +6 -9
- package/dist/guest/toolchains/native/cpp.d.ts +4 -0
- package/dist/guest/toolchains/native/cpp.js +38 -0
- package/dist/guest/toolchains/native/dotnet.d.ts +4 -0
- package/dist/guest/toolchains/native/dotnet.js +103 -0
- package/dist/guest/toolchains/native/mesa.d.ts +7 -0
- package/dist/guest/toolchains/native/mesa.js +46 -0
- package/dist/guest/toolchains/native/msvc/environment.d.ts +16 -0
- package/dist/guest/toolchains/native/msvc/environment.js +57 -0
- package/dist/guest/toolchains/native/msvc/index.d.ts +6 -0
- package/dist/guest/toolchains/native/msvc/index.js +48 -0
- package/dist/guest/toolchains/native/msvc/packages.d.ts +6 -0
- package/dist/guest/toolchains/native/msvc/packages.js +156 -0
- package/dist/guest/toolchains/native/msvc/tree.d.ts +15 -0
- package/dist/guest/toolchains/native/msvc/tree.js +21 -0
- package/dist/guest/toolchains/native/rust.d.ts +3 -0
- package/dist/guest/toolchains/native/rust.js +45 -0
- package/dist/guest/toolchains/node.js +26 -6
- package/dist/guest/toolchains/plan.d.ts +22 -0
- package/dist/guest/toolchains/plan.js +96 -0
- package/dist/guest/toolchains/pwsh.js +1 -1
- package/dist/guest/toolchains/python.js +17 -10
- package/dist/guest/toolchains/runtimes.d.ts +2 -0
- package/dist/guest/toolchains/runtimes.js +6 -8
- package/dist/guest/toolchains/scripting/php.d.ts +3 -0
- package/dist/guest/toolchains/scripting/php.js +71 -0
- package/dist/guest/toolchains/scripting/ruby.d.ts +3 -0
- package/dist/guest/toolchains/scripting/ruby.js +47 -0
- package/dist/guest/toolchains/scripting/vcruntime.d.ts +7 -0
- package/dist/guest/toolchains/scripting/vcruntime.js +45 -0
- package/dist/guest/view.js +21 -1
- package/dist/host/accounts.js +14 -5
- package/dist/host/agent-commands.d.ts +25 -0
- package/dist/host/agent-commands.js +145 -0
- package/dist/host/attach.d.ts +17 -0
- package/dist/host/attach.js +69 -0
- package/dist/host/channel.d.ts +23 -22
- package/dist/host/channel.js +66 -84
- package/dist/host/claude-profile.js +7 -3
- package/dist/host/cleanup.js +2 -11
- package/dist/host/database-plan.d.ts +12 -0
- package/dist/host/database-plan.js +52 -0
- package/dist/host/generate.d.ts +4 -12
- package/dist/host/generate.js +48 -135
- package/dist/host/join.d.ts +28 -0
- package/dist/host/join.js +76 -0
- package/dist/host/launch/mappings.d.ts +3 -0
- package/dist/host/launch/mappings.js +50 -0
- package/dist/host/launch/projects.d.ts +15 -0
- package/dist/host/launch/projects.js +56 -0
- package/dist/host/launch/stage.d.ts +11 -0
- package/dist/host/launch/stage.js +66 -0
- package/dist/host/launch/wsb.d.ts +10 -0
- package/dist/host/launch/wsb.js +34 -0
- package/dist/host/pc-scan.d.ts +6 -0
- package/dist/host/pc-scan.js +37 -0
- package/dist/host/platform.d.ts +2 -0
- package/dist/host/platform.js +13 -1
- package/dist/host/project-scan.d.ts +1 -17
- package/dist/host/project-scan.js +2 -86
- package/dist/host/projects.d.ts +100 -0
- package/dist/host/projects.js +147 -0
- package/dist/host/repo-guard.d.ts +15 -2
- package/dist/host/repo-guard.js +103 -12
- package/dist/host/terminal.js +3 -0
- package/dist/host/test-guard.d.ts +6 -0
- package/dist/host/test-guard.js +15 -0
- package/dist/host/window.js +7 -3
- package/dist/host/wsb.d.ts +37 -0
- package/dist/host/wsb.js +101 -0
- package/dist/runtime/daemon.js +10997 -2794
- package/dist/runtime/db.js +6428 -464
- package/dist/runtime/main.js +7359 -1135
- package/dist/runtime/view.js +5922 -47
- package/dist/selftest/accounts.test.d.ts +2 -0
- package/dist/selftest/accounts.test.js +44 -0
- package/dist/selftest/agent-commands.test.d.ts +2 -0
- package/dist/selftest/agent-commands.test.js +47 -0
- package/dist/selftest/channel.test.d.ts +2 -0
- package/dist/selftest/channel.test.js +37 -0
- package/dist/selftest/cli.test.d.ts +2 -2
- package/dist/selftest/cli.test.js +115 -27
- package/dist/selftest/cmdline.test.d.ts +2 -0
- package/dist/selftest/cmdline.test.js +45 -0
- package/dist/selftest/config.test.d.ts +2 -3
- package/dist/selftest/config.test.js +36 -72
- package/dist/selftest/data.test.d.ts +2 -2
- package/dist/selftest/data.test.js +77 -70
- package/dist/selftest/detect.test.d.ts +2 -2
- package/dist/selftest/detect.test.js +54 -38
- package/dist/selftest/fixtures.d.ts +44 -4
- package/dist/selftest/fixtures.js +40 -23
- package/dist/selftest/generate.test.d.ts +2 -0
- package/dist/selftest/generate.test.js +63 -0
- package/dist/selftest/git-access.test.d.ts +2 -0
- package/dist/selftest/git-access.test.js +26 -0
- package/dist/selftest/guest-boot.test.d.ts +2 -0
- package/dist/selftest/guest-boot.test.js +76 -0
- package/dist/selftest/harness.d.ts +44 -7
- package/dist/selftest/harness.js +62 -21
- package/dist/selftest/host-sim.test.d.ts +2 -0
- package/dist/selftest/host-sim.test.js +93 -0
- package/dist/selftest/hostile-input.test.d.ts +2 -0
- package/dist/selftest/hostile-input.test.js +54 -0
- package/dist/selftest/index.d.ts +8 -1
- package/dist/selftest/index.js +134 -35
- package/dist/selftest/links.test.d.ts +2 -0
- package/dist/selftest/links.test.js +50 -0
- package/dist/selftest/live-daemon.test.d.ts +2 -0
- package/dist/selftest/live-daemon.test.js +91 -0
- package/dist/selftest/live-git.test.d.ts +2 -0
- package/dist/selftest/live-git.test.js +60 -0
- package/dist/selftest/live-projects.test.d.ts +2 -0
- package/dist/selftest/live-projects.test.js +127 -0
- package/dist/selftest/live.d.ts +65 -0
- package/dist/selftest/live.js +109 -0
- package/dist/selftest/local-config.test.d.ts +2 -0
- package/dist/selftest/local-config.test.js +107 -0
- package/dist/selftest/mirror.test.d.ts +2 -3
- package/dist/selftest/mirror.test.js +92 -65
- package/dist/selftest/network.test.d.ts +2 -0
- package/dist/selftest/network.test.js +28 -0
- package/dist/selftest/personalization.test.d.ts +2 -0
- package/dist/selftest/personalization.test.js +53 -0
- package/dist/selftest/projects.test.d.ts +2 -0
- package/dist/selftest/projects.test.js +254 -0
- package/dist/selftest/repair.test.d.ts +2 -0
- package/dist/selftest/repair.test.js +42 -0
- package/dist/selftest/repo-guard.test.d.ts +2 -0
- package/dist/selftest/repo-guard.test.js +63 -0
- package/dist/selftest/secrets.test.d.ts +2 -0
- package/dist/selftest/secrets.test.js +71 -0
- package/dist/selftest/setup.test.d.ts +2 -2
- package/dist/selftest/setup.test.js +45 -22
- package/dist/selftest/suite.d.ts +13 -0
- package/dist/selftest/suite.js +1 -0
- package/dist/selftest/sync.test.d.ts +2 -3
- package/dist/selftest/sync.test.js +90 -78
- package/dist/selftest/test-guard.test.d.ts +2 -0
- package/dist/selftest/test-guard.test.js +49 -0
- package/dist/selftest/toolchains.test.d.ts +2 -0
- package/dist/selftest/toolchains.test.js +103 -0
- package/dist/selftest/workspace.test.d.ts +2 -0
- package/dist/selftest/workspace.test.js +53 -0
- package/dist/shared/download.d.ts +3 -1
- package/dist/shared/download.js +19 -4
- package/dist/shared/paths.d.ts +5 -0
- package/dist/shared/paths.js +6 -0
- package/dist/shared/projects.d.ts +53 -0
- package/dist/shared/projects.js +67 -0
- package/dist/shared/rundir.d.ts +10 -1
- package/dist/shared/rundir.js +12 -4
- package/dist/shared/safe-remove.js +11 -0
- package/dist/shared/schema.d.ts +443 -0
- package/dist/shared/schema.js +41 -2
- package/dist/shared/test-guard.d.ts +4 -0
- package/dist/shared/test-guard.js +37 -0
- package/dist/sync/claude-mem.js +3 -1
- package/dist/sync/history.d.ts +23 -12
- package/dist/sync/history.js +52 -20
- package/dist/sync/watcher.d.ts +8 -0
- package/dist/sync/watcher.js +23 -4
- package/package.json +6 -6
- package/sandbox/bootstrap.ps1 +258 -258
- package/sandbox/cpucap.ps1 +51 -0
- package/sandbox/logon.cmd +18 -16
- package/sandbox/openssl.cs +42 -0
- package/sandbox/ptyhost.cs +15 -4
- package/sandbox/trust.cmd +35 -35
- package/schemas/config.schema.json +100 -1
- package/schemas/sandbox-config.schema.json +17 -1
- package/dist/cli/commands/data.d.ts +0 -46
- package/dist/cli/commands/data.js +0 -249
- package/dist/cli/commands/setup.js +0 -152
- package/dist/cli/settings.d.ts +0 -11
- package/dist/cli/settings.js +0 -156
- package/dist/guest/toolchains/databases.js +0 -226
- package/dist/guest/toolchains/msvc.d.ts +0 -10
- package/dist/guest/toolchains/msvc.js +0 -216
- package/dist/guest/toolchains/native.d.ts +0 -12
- package/dist/guest/toolchains/native.js +0 -220
- package/dist/guest/toolchains/scripting.d.ts +0 -10
- package/dist/guest/toolchains/scripting.js +0 -137
- package/dist/selftest/guest.test.d.ts +0 -3
- package/dist/selftest/guest.test.js +0 -61
- package/dist/selftest/helpers.test.d.ts +0 -2
- package/dist/selftest/helpers.test.js +0 -125
- package/dist/selftest/host.test.d.ts +0 -2
- package/dist/selftest/host.test.js +0 -71
- package/dist/selftest/live.test.d.ts +0 -7
- package/dist/selftest/live.test.js +0 -127
- package/dist/selftest/security.test.d.ts +0 -3
- package/dist/selftest/security.test.js +0 -143
- /package/dist/guest/toolchains/{binstall.d.ts → native/binstall.d.ts} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// .NET: the SDK (dotnet-install.ps1), .NET Framework reference assemblies for old-style projects, and .NET Framework 3.5.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { fetchJson, installArchive } from '../../../shared/download.js';
|
|
6
|
+
import { readJsonFile, writeJsonAtomic } from '../../../shared/rundir.js';
|
|
7
|
+
import { safeRemove } from '../../../shared/safe-remove.js';
|
|
8
|
+
import { SYSTEM } from '../../../shared/system.js';
|
|
9
|
+
import { dataDir, dryRun, errMsg, execAsync, execOutput, exists, log, mkdirp, warn } from '../../env.js';
|
|
10
|
+
import { projectWorkspace } from '../../project-context.js';
|
|
11
|
+
import { downloadFile, installOnce, tool } from '../common.js';
|
|
12
|
+
/** tools\dotnet\.agent-sandbox-installed.json: which install keys (channel:8.0, global.json:...) already ran. */
|
|
13
|
+
const DotnetMarker = z.record(z.string(), z.boolean());
|
|
14
|
+
/** .NET SDK channels from config plus whatever the workspace's global.json pins. Installs are remembered in a marker. */
|
|
15
|
+
export const setupDotnet = async (env, config, refresh) => {
|
|
16
|
+
const root = tool('dotnet');
|
|
17
|
+
const marker = path.join(root, '.agent-sandbox-installed.json');
|
|
18
|
+
const script = tool('dotnet-install.ps1');
|
|
19
|
+
if (dryRun) {
|
|
20
|
+
log('(dry run) would provision .NET SDK channels ' + config.channels.join(', '));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// A corrupt or hand-edited marker just means "nothing recorded yet" (the installs are idempotent).
|
|
24
|
+
const recorded = DotnetMarker.safeParse(exists(marker) && !refresh ? readJsonFile(marker) : {});
|
|
25
|
+
const done = recorded.success ? recorded.data : {};
|
|
26
|
+
const globalJson = path.join(projectWorkspace(), 'global.json');
|
|
27
|
+
const installs = [
|
|
28
|
+
...config.channels.map((c) => ['channel:' + c, ['-Channel', c]]),
|
|
29
|
+
...(exists(globalJson) ? [['global.json:' + fs.readFileSync(globalJson, 'utf8').replace(/\s+/g, ''), ['-JSonFile', globalJson]]] : []),
|
|
30
|
+
];
|
|
31
|
+
for (const [key, args] of installs.filter(([k]) => !done[k])) {
|
|
32
|
+
// Fetched every time something is installed (it is small): an interrupted earlier download must not be run.
|
|
33
|
+
await downloadFile('https://dot.net/v1/dotnet-install.ps1', script);
|
|
34
|
+
log('Installing the .NET SDK ' + (key.startsWith('channel:') ? key.slice(8) : 'pinned in global.json') + ' (~250 MB once) ...');
|
|
35
|
+
await execAsync(SYSTEM.powershell(), ['-NoLogo', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', script, ...args, '-InstallDir', root, '-NoPath']);
|
|
36
|
+
done[key] = true;
|
|
37
|
+
writeJsonAtomic(marker, done);
|
|
38
|
+
}
|
|
39
|
+
const home = mkdirp(tool('dotnet-home'));
|
|
40
|
+
Object.assign(env.vars, { DOTNET_ROOT: root, DOTNET_CLI_HOME: home, DOTNET_CLI_TELEMETRY_OPTOUT: '1', DOTNET_NOLOGO: '1', DOTNET_SKIP_FIRST_TIME_EXPERIENCE: '1', NUGET_PACKAGES: tool('nuget', 'packages') });
|
|
41
|
+
env.prepend.push(root, path.join(home, '.dotnet', 'tools'));
|
|
42
|
+
env.summary.push('dotnet: ' + execOutput(path.join(root, 'dotnet.exe'), ['--list-sdks']).split(/\r?\n/).map((l) => l.split(' ')[0]).filter(Boolean).join(', '));
|
|
43
|
+
const dotnet = path.join(root, 'dotnet.exe');
|
|
44
|
+
const dotnetEnv = { env: { ...process.env, ...env.vars, PATH: root + path.delimiter + (process.env.PATH ?? '') } };
|
|
45
|
+
await installOnce(env, 'dotnet workload', config.workloads, (w) => execAsync(dotnet, ['workload', 'install', w, '--skip-manifest-update'], dotnetEnv));
|
|
46
|
+
await installOnce(env, 'dotnet tool', config.tools, (t) => execAsync(dotnet, ['tool', 'install', '--global', t], dotnetEnv));
|
|
47
|
+
await setupFrameworkReferences(env, config.frameworkTargets);
|
|
48
|
+
if (config.netfx35)
|
|
49
|
+
await setupNetFx35(env);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* .NET Framework reference assemblies (the "targeting packs" Visual Studio would install) from NuGet, so net4x projects,
|
|
53
|
+
* old-style .csproj included, build with the SDK's MSBuild. MSBuild reads TargetFrameworkRootPath from the environment.
|
|
54
|
+
* Running .NET Framework 4.8 apps needs nothing: Windows ships it.
|
|
55
|
+
*/
|
|
56
|
+
const setupFrameworkReferences = async (env, targets) => {
|
|
57
|
+
if (!targets.length)
|
|
58
|
+
return;
|
|
59
|
+
const root = tool('netfx-references');
|
|
60
|
+
for (const target of targets) {
|
|
61
|
+
const id = 'microsoft.netframework.referenceassemblies.' + target.toLowerCase();
|
|
62
|
+
const marker = path.join(root, '.installed-' + target.toLowerCase());
|
|
63
|
+
if (exists(marker))
|
|
64
|
+
continue;
|
|
65
|
+
const staging = tool('netfx-references-' + target.toLowerCase());
|
|
66
|
+
try {
|
|
67
|
+
const { versions } = await fetchJson('https://api.nuget.org/v3-flatcontainer/' + id + '/index.json');
|
|
68
|
+
const version = versions.filter((v) => /^\d+(\.\d+)*$/.test(v)).pop();
|
|
69
|
+
if (!version)
|
|
70
|
+
throw new Error('no stable version of ' + id);
|
|
71
|
+
log('Downloading the .NET Framework ' + target + ' reference assemblies (~30 MB once) ...');
|
|
72
|
+
await installArchive('https://api.nuget.org/v3-flatcontainer/' + id + '/' + version + '/' + id + '.' + version + '.nupkg', staging, { fileName: id + '.zip' });
|
|
73
|
+
fs.cpSync(path.join(staging, 'build', '.NETFramework'), path.join(root, '.NETFramework'), { recursive: true });
|
|
74
|
+
fs.writeFileSync(marker, version);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
warn('.NET Framework ' + target + ' reference assemblies could not be installed (projects targeting it will not build): ' + errMsg(e));
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
safeRemove(staging, dataDir);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!exists(path.join(root, '.NETFramework')))
|
|
84
|
+
return;
|
|
85
|
+
env.vars.TargetFrameworkRootPath = root + path.sep;
|
|
86
|
+
env.summary.push('.NET Framework targeting: ' + fs.readdirSync(path.join(root, '.NETFramework')).join(', '));
|
|
87
|
+
};
|
|
88
|
+
/** .NET Framework 3.5 is a Windows feature the sandbox image lacks; DISM fetches it from Windows Update on every boot. */
|
|
89
|
+
const setupNetFx35 = async (env) => {
|
|
90
|
+
if (execOutput(SYSTEM.reg(), ['query', 'HKLM\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v3.5', '/v', 'Install']).includes('0x1')) {
|
|
91
|
+
env.summary.push('.NET Framework 3.5: on');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
log('Enabling .NET Framework 3.5 (downloads from Windows Update, a few minutes) ...');
|
|
95
|
+
try {
|
|
96
|
+
await execAsync(SYSTEM.dism(), ['/Online', '/Enable-Feature', '/FeatureName:NetFx3', '/All', '/NoRestart', '/Quiet'], { stdio: 'ignore' });
|
|
97
|
+
env.summary.push('.NET Framework 3.5: on');
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
warn('.NET Framework 3.5 could not be enabled: ' + errMsg(e));
|
|
101
|
+
env.summary.push('.NET Framework 3.5: FAILED');
|
|
102
|
+
}
|
|
103
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Toolchains } from '../../../core/types.js';
|
|
2
|
+
import { type ToolEnv } from '../common.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mesa 3D for Windows (llvmpipe): OpenGL 4.5 on the CPU when the sandbox has no GPU. Windows only offers OpenGL 1.1 in
|
|
5
|
+
* software, and opengl32.dll cannot be replaced system-wide, so programs pick Mesa up from their own folder.
|
|
6
|
+
*/
|
|
7
|
+
export declare const setupMesa: (env: ToolEnv, config: Toolchains["mesa"]) => Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Mesa for running OpenGL and Vulkan programs without a GPU (llvmpipe, lavapipe).
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { installArchive } from '../../../shared/download.js';
|
|
4
|
+
import { SYSTEM } from '../../../shared/system.js';
|
|
5
|
+
import { dryRun, execAsync, exists, log } from '../../env.js';
|
|
6
|
+
import { arch, installFromGithub, tool } from '../common.js';
|
|
7
|
+
/**
|
|
8
|
+
* Mesa 3D for Windows (llvmpipe): OpenGL 4.5 on the CPU when the sandbox has no GPU. Windows only offers OpenGL 1.1 in
|
|
9
|
+
* software, and opengl32.dll cannot be replaced system-wide, so programs pick Mesa up from their own folder.
|
|
10
|
+
*/
|
|
11
|
+
export const setupMesa = async (env, config) => {
|
|
12
|
+
if (dryRun) {
|
|
13
|
+
log('(dry run) would provision Mesa 3D');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const root = tool('mesa');
|
|
17
|
+
const dir = path.join(root, arch === 'arm64' ? 'arm64' : 'x64');
|
|
18
|
+
if (!exists(path.join(dir, 'opengl32.dll'))) {
|
|
19
|
+
await installFromGithub('pal1000/mesa-dist-win', /^mesa3d-[\d.]+-release-msvc\.7z$/, { dest: root, what: 'Mesa 3D for software OpenGL (~100 MB once)', locate: 'opengl32.dll', up: 1 });
|
|
20
|
+
}
|
|
21
|
+
Object.assign(env.vars, { MESA_DIR: dir, GALLIUM_DRIVER: 'llvmpipe' });
|
|
22
|
+
env.summary.push('mesa (software OpenGL 4.5): copy opengl32.dll + libgallium_wgl.dll from %MESA_DIR% next to a game\'s .exe');
|
|
23
|
+
if (config.vulkan)
|
|
24
|
+
await setupLavapipe(env, dir);
|
|
25
|
+
};
|
|
26
|
+
const VULKAN_RUNTIME = 'https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-runtime-components.zip';
|
|
27
|
+
/**
|
|
28
|
+
* Software Vulkan: Mesa's lavapipe plus the Khronos loader (vulkan-1.dll, from LunarG's runtime components; Windows
|
|
29
|
+
* Sandbox has no Vulkan loader). The loader ignores VK_DRIVER_FILES in elevated processes, and everything in the
|
|
30
|
+
* sandbox runs elevated, so lavapipe is registered where the loader looks (HKLM; the registry is new every boot).
|
|
31
|
+
*/
|
|
32
|
+
const setupLavapipe = async (env, mesaDir) => {
|
|
33
|
+
const icd = path.join(mesaDir, arch === 'arm64' ? 'lvp_icd.aarch64.json' : 'lvp_icd.x86_64.json');
|
|
34
|
+
if (!exists(icd))
|
|
35
|
+
throw new Error('this Mesa build has no lavapipe (' + path.basename(icd) + ')');
|
|
36
|
+
const dir = tool('vulkan');
|
|
37
|
+
if (!exists(path.join(dir, 'vulkan-1.dll'))) {
|
|
38
|
+
log('Downloading the Vulkan loader (~10 MB once) ...');
|
|
39
|
+
// LunarG publishes no checksum for this zip; it comes over HTTPS from LunarG, the Khronos SDK's maintainer.
|
|
40
|
+
// The zip has x86 and x64 folders: only the 64-bit loader (and vulkaninfo) is extracted.
|
|
41
|
+
await installArchive(VULKAN_RUNTIME, dir, { locate: 'vulkan-1.dll', fileName: 'vulkan-runtime.zip', members: ['*/x64/*'] });
|
|
42
|
+
}
|
|
43
|
+
await execAsync(SYSTEM.reg(), ['add', 'HKLM\\SOFTWARE\\Khronos\\Vulkan\\Drivers', '/v', icd, '/t', 'REG_DWORD', '/d', '0', '/f'], { stdio: 'ignore' });
|
|
44
|
+
env.prepend.push(dir);
|
|
45
|
+
env.summary.push('vulkan: lavapipe (software Vulkan 1.4 on the CPU), vulkaninfo on PATH; WGPU_BACKEND=vulkan for wgpu');
|
|
46
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface VcEnv {
|
|
2
|
+
vars: Record<string, string>;
|
|
3
|
+
path: string[];
|
|
4
|
+
}
|
|
5
|
+
/** Variables vcvars64.bat would set for this tree (host x64, target x64). */
|
|
6
|
+
export declare const vcvars: (root: string, msvc: string, sdk: string) => VcEnv;
|
|
7
|
+
/** vcvars64.bat / vcvarsall.bat in the usual place, for scripts that `call` them. */
|
|
8
|
+
export declare const writeVcvars: (env: VcEnv) => void;
|
|
9
|
+
/** vswhere.exe where Visual Studio's installer would put it, answering with this tree. */
|
|
10
|
+
export declare const installVswhere: (msvc: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* cl.exe and link.exe start vctip.exe (Visual Studio's telemetry uploader), which lingers after the build and keeps the
|
|
13
|
+
* folder locked, so `sandbox repair` / `data clean` could not delete tools\msvc. Neither VSCMD_SKIP_SENDTELEMETRY nor
|
|
14
|
+
* the TurnOffSwitch registry value stops it; without the file the compiler simply skips it. Nothing else needs it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const removeTelemetry: (msvc: string) => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// What makes the unpacked tree behave like a Build Tools install: the vcvars environment, vcvars64.bat, vswhere.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { errMsg, mkdirp, warn } from '../../../env.js';
|
|
5
|
+
import { ensureCompiled } from '../../../helpers.js';
|
|
6
|
+
import { hostBin, ROOT } from './tree.js';
|
|
7
|
+
/** Where build tools look for vswhere (local to the sandbox, so it is written each boot). */
|
|
8
|
+
const VSWHERE_DIR = path.join(process.env['ProgramFiles(x86)'] ?? 'C:\\Program Files (x86)', 'Microsoft Visual Studio', 'Installer');
|
|
9
|
+
/** Variables vcvars64.bat would set for this tree (host x64, target x64). */
|
|
10
|
+
export const vcvars = (root, msvc, sdk) => {
|
|
11
|
+
const vc = path.join(root, 'VC', 'Tools', 'MSVC', msvc);
|
|
12
|
+
const kits = path.join(root, 'Windows Kits', '10');
|
|
13
|
+
const inc = (...p) => path.join(kits, 'Include', sdk, ...p);
|
|
14
|
+
const lib = (...p) => path.join(kits, 'Lib', sdk, ...p);
|
|
15
|
+
return {
|
|
16
|
+
vars: {
|
|
17
|
+
VSINSTALLDIR: root + '\\', VCINSTALLDIR: path.join(root, 'VC') + '\\', VCToolsInstallDir: vc + '\\', VCToolsVersion: msvc, VisualStudioVersion: '17.0',
|
|
18
|
+
WindowsSdkDir: kits + '\\', WindowsSDKVersion: sdk + '\\', WindowsSDKLibVersion: sdk + '\\', UniversalCRTSdkDir: kits + '\\', UCRTVersion: sdk,
|
|
19
|
+
VSCMD_ARG_HOST_ARCH: 'x64', VSCMD_ARG_TGT_ARCH: 'x64', Platform: 'x64',
|
|
20
|
+
INCLUDE: [path.join(vc, 'include'), inc('ucrt'), inc('shared'), inc('um'), inc('winrt'), inc('cppwinrt')].join(';'),
|
|
21
|
+
LIB: [path.join(vc, 'lib', 'x64'), lib('ucrt', 'x64'), lib('um', 'x64')].join(';'),
|
|
22
|
+
LIBPATH: [path.join(vc, 'lib', 'x64'), path.join(vc, 'lib', 'x86', 'store', 'references')].join(';'),
|
|
23
|
+
},
|
|
24
|
+
path: [path.join(vc, 'bin', 'Hostx64', 'x64'), path.join(kits, 'bin', sdk, 'x64')],
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** vcvars64.bat / vcvarsall.bat in the usual place, for scripts that `call` them. */
|
|
28
|
+
export const writeVcvars = (env) => {
|
|
29
|
+
const dir = mkdirp(path.join(ROOT, 'VC', 'Auxiliary', 'Build'));
|
|
30
|
+
const lines = [
|
|
31
|
+
'@echo off', 'rem Written by Windows Development Sandbox for its portable MSVC (host x64, target x64).',
|
|
32
|
+
...Object.entries(env.vars).map(([k, v]) => 'set "' + k + '=' + v + '"'),
|
|
33
|
+
'set "PATH=' + env.path.join(';') + ';%PATH%"', 'exit /b 0',
|
|
34
|
+
];
|
|
35
|
+
fs.writeFileSync(path.join(dir, 'vcvars64.bat'), lines.join('\r\n') + '\r\n');
|
|
36
|
+
fs.writeFileSync(path.join(dir, 'vcvarsall.bat'), ['@echo off', 'rem Only x64 (amd64) is installed.', 'call "%~dp0vcvars64.bat"', 'exit /b %errorlevel%'].join('\r\n') + '\r\n');
|
|
37
|
+
};
|
|
38
|
+
/** vswhere.exe where Visual Studio's installer would put it, answering with this tree. */
|
|
39
|
+
export const installVswhere = (msvc) => {
|
|
40
|
+
mkdirp(VSWHERE_DIR);
|
|
41
|
+
fs.copyFileSync(ensureCompiled('vswhere'), path.join(VSWHERE_DIR, 'vswhere.exe'));
|
|
42
|
+
const [major, minor] = msvc.split('.').slice(2);
|
|
43
|
+
fs.writeFileSync(path.join(VSWHERE_DIR, 'vswhere.json'), JSON.stringify({ installationPath: ROOT, installationVersion: '17.' + (minor ?? '0') + '.0.' + (major ?? '0') }));
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* cl.exe and link.exe start vctip.exe (Visual Studio's telemetry uploader), which lingers after the build and keeps the
|
|
47
|
+
* folder locked, so `sandbox repair` / `data clean` could not delete tools\msvc. Neither VSCMD_SKIP_SENDTELEMETRY nor
|
|
48
|
+
* the TurnOffSwitch registry value stops it; without the file the compiler simply skips it. Nothing else needs it.
|
|
49
|
+
*/
|
|
50
|
+
export const removeTelemetry = (msvc) => {
|
|
51
|
+
try {
|
|
52
|
+
fs.rmSync(hostBin(msvc, 'vctip.exe'), { force: true });
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
warn('Could not remove MSVC\'s telemetry helper (vctip.exe); it may keep tools\\msvc locked: ' + errMsg(e));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Toolchains } from '../../../../core/types.js';
|
|
2
|
+
import type { ToolEnv } from '../../common.js';
|
|
3
|
+
import { type VcEnv } from './environment.js';
|
|
4
|
+
/** The vcvars environment of an installed tree (for steps that run before the agent's environment exists). */
|
|
5
|
+
export declare const installedMsvcEnv: () => VcEnv | null;
|
|
6
|
+
export declare const setupMsvc: (env: ToolEnv, config: Toolchains["msvc"]) => Promise<void>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// MSVC (cl, link) and the Windows SDK without an installer (packages.ts), laid out like a Build Tools install with
|
|
2
|
+
// vcvars64.bat and a vswhere that points at it (environment.ts), so CMake, cargo (msvc host), node-gyp and vcvars-based
|
|
3
|
+
// scripts work. Use is governed by the Visual Studio licence terms: it only installs with toolchains.msvc.acceptLicense.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { writeJsonAtomic } from '../../../../shared/rundir.js';
|
|
7
|
+
import { safeRemove } from '../../../../shared/safe-remove.js';
|
|
8
|
+
import { dryRun, exists, log } from '../../../env.js';
|
|
9
|
+
import { installVswhere, removeTelemetry, vcvars, writeVcvars } from './environment.js';
|
|
10
|
+
import { installPackages } from './packages.js';
|
|
11
|
+
import { hasCompiler, MARKER, readInstalled, ROOT } from './tree.js';
|
|
12
|
+
/** The vcvars environment of an installed tree (for steps that run before the agent's environment exists). */
|
|
13
|
+
export const installedMsvcEnv = () => {
|
|
14
|
+
const done = readInstalled();
|
|
15
|
+
return done && hasCompiler(done.msvc) ? vcvars(ROOT, done.msvc, done.sdk) : null;
|
|
16
|
+
};
|
|
17
|
+
/** Empties tools\msvc for a fresh install, keeping the manifest and the verified downloads of an earlier attempt. */
|
|
18
|
+
const clearTree = () => {
|
|
19
|
+
if (!exists(ROOT))
|
|
20
|
+
return;
|
|
21
|
+
for (const name of fs.readdirSync(ROOT).filter((n) => n !== '.manifest.json' && n !== '.download'))
|
|
22
|
+
safeRemove(path.join(ROOT, name), ROOT);
|
|
23
|
+
};
|
|
24
|
+
export const setupMsvc = async (env, config) => {
|
|
25
|
+
if (!config.acceptLicense) {
|
|
26
|
+
throw new Error('MSVC is installed only with toolchains.msvc.acceptLicense = true: its use is governed by the Visual Studio licence terms (https://visualstudio.microsoft.com/license-terms/), which need a Visual Studio licence');
|
|
27
|
+
}
|
|
28
|
+
if (dryRun) {
|
|
29
|
+
log('(dry run) would provision MSVC ' + config.msvcVersion + ' and Windows SDK ' + config.sdkVersion);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const want = config.msvcVersion + '/' + config.sdkVersion;
|
|
33
|
+
let done = readInstalled();
|
|
34
|
+
if (!done || done.want !== want || !hasCompiler(done.msvc)) {
|
|
35
|
+
log('Installing MSVC and the Windows SDK (~1-2 GB, once; licence accepted in toolchains.msvc.acceptLicense) ...');
|
|
36
|
+
clearTree();
|
|
37
|
+
done = { ...(await installPackages(config)), want };
|
|
38
|
+
// Written last and atomically: without it (an interrupted install) the next boot starts over.
|
|
39
|
+
writeJsonAtomic(MARKER, done);
|
|
40
|
+
}
|
|
41
|
+
removeTelemetry(done.msvc);
|
|
42
|
+
const vc = vcvars(ROOT, done.msvc, done.sdk);
|
|
43
|
+
writeVcvars(vc);
|
|
44
|
+
installVswhere(done.msvc);
|
|
45
|
+
Object.assign(env.vars, vc.vars);
|
|
46
|
+
env.prepend.push(...vc.path);
|
|
47
|
+
env.summary.push('msvc: ' + done.msvc + ', Windows SDK ' + done.sdk + ' (cl, link; vcvars64.bat and vswhere work)');
|
|
48
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Toolchains } from '../../../../core/types.js';
|
|
2
|
+
/** Downloads and unpacks MSVC and the Windows SDK into tools\msvc; resolves with the toolset and SDK folder names. */
|
|
3
|
+
export declare const installPackages: (config: Toolchains["msvc"]) => Promise<{
|
|
4
|
+
msvc: string;
|
|
5
|
+
sdk: string;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Downloads the MSVC compiler and the Windows SDK from Microsoft's Visual Studio channel manifest, the way mmozeiko's
|
|
2
|
+
// portable-msvc.py does: each payload is checked against the manifest's sha256, the compiler is unpacked from its
|
|
3
|
+
// .vsix files, the SDK from its .msi files with `msiexec /a`.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { download, extractArchive, fetchJson } from '../../../../shared/download.js';
|
|
7
|
+
import { safeRemove } from '../../../../shared/safe-remove.js';
|
|
8
|
+
import { system32 } from '../../../../shared/system.js';
|
|
9
|
+
import { execAsync, exists, log, mkdirp } from '../../../env.js';
|
|
10
|
+
import { msiCabs, pickMsvcVersion, pickWindowsSdk } from '../../versions.js';
|
|
11
|
+
import { hostBin, ROOT } from './tree.js';
|
|
12
|
+
const CHANNEL = 'https://aka.ms/vs/17/release/channel';
|
|
13
|
+
const MANIFEST_DAY_MS = 24 * 60 * 60 * 1000;
|
|
14
|
+
/** The compiler's packages (host x64, target x64): tools, resources, CRT headers/libs, ASAN/PGO headers. */
|
|
15
|
+
const MSVC_PARTS = ['tools.hostx64.targetx64.base', 'tools.hostx64.targetx64.res.base', 'crt.headers.base', 'crt.x64.desktop.base', 'crt.x64.store.base', 'crt.source.base', 'asan.headers.base', 'pgo.headers.base'];
|
|
16
|
+
/** Without these the compiler is unusable; the other parts are taken when the manifest has them. */
|
|
17
|
+
const REQUIRED_PARTS = ['tools', 'crt.headers', 'crt.x64.desktop'];
|
|
18
|
+
/** The SDK's .msi files (Desktop + UCRT + Store headers/libs/tools for x64), as in portable-msvc.py. */
|
|
19
|
+
const SDK_MSIS = [
|
|
20
|
+
'Windows SDK for Windows Store Apps Tools-x86_en-us.msi', 'Windows SDK for Windows Store Apps Headers-x86_en-us.msi',
|
|
21
|
+
'Windows SDK for Windows Store Apps Headers OnecoreUap-x86_en-us.msi', 'Windows SDK for Windows Store Apps Libs-x86_en-us.msi',
|
|
22
|
+
'Universal CRT Headers Libraries and Sources-x86_en-us.msi', 'Windows SDK Desktop Headers x86-x86_en-us.msi',
|
|
23
|
+
'Windows SDK Desktop Headers x64-x86_en-us.msi', 'Windows SDK Desktop Libs x64-x86_en-us.msi', 'Windows SDK Desktop Tools x64-x86_en-us.msi',
|
|
24
|
+
];
|
|
25
|
+
/** The VS manifest (~18 MB), cached for a day. */
|
|
26
|
+
const manifest = async () => {
|
|
27
|
+
const cached = path.join(ROOT, '.manifest.json');
|
|
28
|
+
if (exists(cached) && Date.now() - fs.statSync(cached).mtimeMs < MANIFEST_DAY_MS) {
|
|
29
|
+
// A download cut short leaves unreadable JSON: fetch it again instead of failing until the day is over.
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(fs.readFileSync(cached, 'utf8'));
|
|
32
|
+
}
|
|
33
|
+
catch { /* downloaded again below */ }
|
|
34
|
+
}
|
|
35
|
+
const channel = await fetchJson(CHANNEL);
|
|
36
|
+
const item = channel.channelItems.find((i) => i.id === 'Microsoft.VisualStudio.Manifests.VisualStudio')?.payloads?.[0];
|
|
37
|
+
if (!item)
|
|
38
|
+
throw new Error('the Visual Studio channel has no package manifest');
|
|
39
|
+
mkdirp(ROOT);
|
|
40
|
+
// The channel's sha256 for the manifest is not the file's hash (portable-msvc.py does not check it either); the
|
|
41
|
+
// manifest comes over HTTPS from Microsoft, and every package payload it lists IS checked against its own sha256.
|
|
42
|
+
await download(item.url, cached);
|
|
43
|
+
return JSON.parse(fs.readFileSync(cached, 'utf8'));
|
|
44
|
+
};
|
|
45
|
+
/** .vsix contents are percent-encoded file names under Contents/; unpack them into the root, names decoded. */
|
|
46
|
+
const unpackVsix = async (vsix, work) => {
|
|
47
|
+
const out = mkdirp(path.join(work, 'vsix-' + path.basename(vsix)));
|
|
48
|
+
await extractArchive(vsix, out, ['Contents']);
|
|
49
|
+
const decode = (dir) => {
|
|
50
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
51
|
+
const from = path.join(dir, entry.name);
|
|
52
|
+
let name = entry.name;
|
|
53
|
+
try {
|
|
54
|
+
if (name.includes('%'))
|
|
55
|
+
name = decodeURIComponent(name);
|
|
56
|
+
}
|
|
57
|
+
catch { /* not percent-encoded after all */ }
|
|
58
|
+
const to = path.join(dir, name);
|
|
59
|
+
if (to !== from)
|
|
60
|
+
fs.renameSync(from, to);
|
|
61
|
+
if (entry.isDirectory())
|
|
62
|
+
decode(to);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
decode(out);
|
|
66
|
+
fs.cpSync(path.join(out, 'Contents'), ROOT, { recursive: true, force: true });
|
|
67
|
+
safeRemove(out, work);
|
|
68
|
+
};
|
|
69
|
+
/** An administrative install only unpacks files; its verbose log explains a failure (e.g. a path over 260 characters). */
|
|
70
|
+
const unpackMsi = async (msi) => {
|
|
71
|
+
const logFile = msi + '.log';
|
|
72
|
+
try {
|
|
73
|
+
await execAsync(system32('msiexec.exe'), ['/a', msi, '/quiet', '/qn', 'TARGETDIR=' + ROOT, '/l*v', logFile], { stdio: 'ignore' });
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
const lines = exists(logFile) ? fs.readFileSync(logFile, 'utf16le').split(/\r?\n/).filter((l) => /error|return value 3|failed/i.test(l)).slice(-4).join(' | ') : '';
|
|
77
|
+
throw new Error(path.basename(msi) + ' did not unpack: ' + (e instanceof Error ? e.message : String(e)) + (lines ? ' (' + lines.slice(0, 600) + ')' : ''));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/** The manifest's packages by id, with the lookups the installer needs. */
|
|
81
|
+
const catalogue = (m) => {
|
|
82
|
+
const byId = new Map();
|
|
83
|
+
for (const p of m.packages)
|
|
84
|
+
byId.set(p.id.toLowerCase(), [...(byId.get(p.id.toLowerCase()) ?? []), p]);
|
|
85
|
+
return {
|
|
86
|
+
ids: [...byId.keys()],
|
|
87
|
+
pick: (id) => byId.get(id.toLowerCase())?.find((p) => !p.language || p.language === 'en-US'),
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/** Downloads (once, verified) into `work`; a verified file from an earlier attempt is reused. */
|
|
91
|
+
const payloadFetcher = (work) => async (p) => {
|
|
92
|
+
const file = path.join(work, path.basename(p.fileName.replace(/\\/g, '/')));
|
|
93
|
+
if (!exists(file))
|
|
94
|
+
await download(p.url, file, p.sha256);
|
|
95
|
+
return file;
|
|
96
|
+
};
|
|
97
|
+
/** Newest folder under VC\Tools\MSVC that holds a compiler (named after the toolset, 14.44.35207, not the package version). */
|
|
98
|
+
const unpackedToolset = () => {
|
|
99
|
+
const toolsRoot = path.join(ROOT, 'VC', 'Tools', 'MSVC');
|
|
100
|
+
return fs.readdirSync(toolsRoot).filter((d) => exists(hostBin(d, 'cl.exe'))).sort((a, b) => a.localeCompare(b, undefined, { numeric: true })).pop();
|
|
101
|
+
};
|
|
102
|
+
/** Downloads and unpacks MSVC and the Windows SDK into tools\msvc; resolves with the toolset and SDK folder names. */
|
|
103
|
+
export const installPackages = async (config) => {
|
|
104
|
+
const { ids, pick } = catalogue(await manifest());
|
|
105
|
+
const version = pickMsvcVersion(ids, config.msvcVersion);
|
|
106
|
+
if (!version)
|
|
107
|
+
throw new Error('no MSVC ' + config.msvcVersion + ' in the Visual Studio manifest');
|
|
108
|
+
const sdk = pickWindowsSdk(ids, config.sdkVersion);
|
|
109
|
+
if (!sdk)
|
|
110
|
+
throw new Error('no Windows SDK ' + config.sdkVersion + ' in the Visual Studio manifest');
|
|
111
|
+
const work = mkdirp(path.join(ROOT, '.download'));
|
|
112
|
+
const fetchPayload = payloadFetcher(work);
|
|
113
|
+
log('Downloading the MSVC ' + version + ' compiler and C/C++ libraries ...');
|
|
114
|
+
for (const part of MSVC_PARTS) {
|
|
115
|
+
const p = pick('microsoft.vc.' + version + '.' + part);
|
|
116
|
+
if (!p && REQUIRED_PARTS.some((r) => part.startsWith(r)))
|
|
117
|
+
throw new Error('MSVC ' + version + ' has no ' + part);
|
|
118
|
+
for (const payload of p?.payloads ?? [])
|
|
119
|
+
await unpackVsix(await fetchPayload(payload), work);
|
|
120
|
+
}
|
|
121
|
+
for (const payload of pick('microsoft.visualcpp.dia.sdk')?.payloads ?? [])
|
|
122
|
+
await unpackVsix(await fetchPayload(payload), work);
|
|
123
|
+
// The SDK component depends on the package that holds the .msi/.cab payloads (e.g. Win11SDK_10.0.26100).
|
|
124
|
+
const sdkPackage = pick(Object.keys(pick(sdk.componentId)?.dependencies ?? {})[0] ?? '');
|
|
125
|
+
if (!sdkPackage?.payloads)
|
|
126
|
+
throw new Error('the Windows SDK ' + sdk.build + ' package has no payloads');
|
|
127
|
+
log('Downloading the Windows SDK ' + sdk.build + ' (headers, libraries; the biggest part) ...');
|
|
128
|
+
const payload = (name) => sdkPackage.payloads.find((p) => p.fileName.toLowerCase() === ('installers\\' + name).toLowerCase());
|
|
129
|
+
const msis = [];
|
|
130
|
+
for (const name of SDK_MSIS) {
|
|
131
|
+
const p = payload(name);
|
|
132
|
+
if (!p)
|
|
133
|
+
throw new Error('the Windows SDK package has no ' + name);
|
|
134
|
+
const file = await fetchPayload(p);
|
|
135
|
+
msis.push(file);
|
|
136
|
+
for (const cab of msiCabs(fs.readFileSync(file))) {
|
|
137
|
+
const c = payload(cab);
|
|
138
|
+
if (c)
|
|
139
|
+
await fetchPayload(c);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
log('Unpacking the Windows SDK (a few minutes) ...');
|
|
143
|
+
for (const msi of msis)
|
|
144
|
+
await unpackMsi(msi);
|
|
145
|
+
// msiexec /a also copies every .msi into the target; they are not needed.
|
|
146
|
+
for (const name of fs.readdirSync(ROOT).filter((n) => n.toLowerCase().endsWith('.msi')))
|
|
147
|
+
fs.rmSync(path.join(ROOT, name), { force: true });
|
|
148
|
+
safeRemove(work, ROOT);
|
|
149
|
+
const sdkVersion = fs.readdirSync(path.join(ROOT, 'Windows Kits', '10', 'Include')).filter((d) => d.startsWith('10.0.' + sdk.build)).sort().pop();
|
|
150
|
+
if (!sdkVersion)
|
|
151
|
+
throw new Error('the Windows SDK did not unpack (no Include\\10.0.' + sdk.build + '.*)');
|
|
152
|
+
const toolset = unpackedToolset();
|
|
153
|
+
if (!toolset)
|
|
154
|
+
throw new Error('MSVC ' + version + ' did not unpack (no cl.exe under VC\\Tools\\MSVC)');
|
|
155
|
+
return { msvc: toolset, sdk: sdkVersion };
|
|
156
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ROOT: string;
|
|
3
|
+
export declare const MARKER: string;
|
|
4
|
+
export declare const msvcTools: (msvc: string, ...parts: string[]) => string;
|
|
5
|
+
export declare const hostBin: (msvc: string, ...parts: string[]) => string;
|
|
6
|
+
export declare const hasCompiler: (msvc: string) => boolean;
|
|
7
|
+
declare const Installed: z.ZodObject<{
|
|
8
|
+
msvc: z.ZodString;
|
|
9
|
+
sdk: z.ZodString;
|
|
10
|
+
want: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type Installed = z.infer<typeof Installed>;
|
|
13
|
+
/** What the last finished install recorded; null for a missing, unreadable or half-written marker. */
|
|
14
|
+
export declare const readInstalled: () => Installed | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Where the portable MSVC lives (tools\msvc) and what the last finished install recorded about it.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { exists } from '../../../env.js';
|
|
6
|
+
import { tool } from '../../common.js';
|
|
7
|
+
export const ROOT = tool('msvc');
|
|
8
|
+
export const MARKER = path.join(ROOT, '.installed.json');
|
|
9
|
+
export const msvcTools = (msvc, ...parts) => path.join(ROOT, 'VC', 'Tools', 'MSVC', msvc, ...parts);
|
|
10
|
+
export const hostBin = (msvc, ...parts) => msvcTools(msvc, 'bin', 'Hostx64', 'x64', ...parts);
|
|
11
|
+
export const hasCompiler = (msvc) => exists(hostBin(msvc, 'cl.exe'));
|
|
12
|
+
const Installed = z.object({ msvc: z.string().min(1), sdk: z.string().min(1), want: z.string() });
|
|
13
|
+
/** What the last finished install recorded; null for a missing, unreadable or half-written marker. */
|
|
14
|
+
export const readInstalled = () => {
|
|
15
|
+
try {
|
|
16
|
+
return Installed.safeParse(JSON.parse(fs.readFileSync(MARKER, 'utf8'))).data ?? null;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Rust: rustup + cargo, with crates installed prebuilt where possible (binstall.ts).
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { dryRun, execAsync, exists, log } from '../../env.js';
|
|
4
|
+
import { arch, downloadFile, installOnce, tool, versionOf } from '../common.js';
|
|
5
|
+
import { crateInstaller } from './binstall.js';
|
|
6
|
+
import { installedMsvcEnv } from './msvc/index.js';
|
|
7
|
+
export const setupRust = async (env, config, refresh) => {
|
|
8
|
+
const RUSTUP_HOME = tool('rust', 'rustup');
|
|
9
|
+
const CARGO_HOME = tool('rust', 'cargo');
|
|
10
|
+
const rustEnv = { env: { ...process.env, RUSTUP_HOME, CARGO_HOME } };
|
|
11
|
+
const rustup = path.join(CARGO_HOME, 'bin', 'rustup.exe');
|
|
12
|
+
if (dryRun) {
|
|
13
|
+
log('(dry run) would provision Rust ' + config.toolchain + ' (' + config.host + ')');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!exists(rustup)) {
|
|
17
|
+
const init = tool('rust', 'rustup-init.exe');
|
|
18
|
+
log('Installing Rust with rustup (~300 MB once; the toolchain downloads after rustup itself) ...');
|
|
19
|
+
await downloadFile('https://static.rust-lang.org/rustup/dist/' + (arch === 'arm64' ? 'aarch64' : 'x86_64') + '-pc-windows-msvc/rustup-init.exe', init);
|
|
20
|
+
await execAsync(init, ['-y', '--no-modify-path', '--profile', 'default', '--default-host', config.host, '--default-toolchain', config.toolchain], rustEnv);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// The host can change (GNU <-> msvc with toolchains.msvc): install the toolchain for it; a no-op when it is there.
|
|
24
|
+
await execAsync(rustup, ['set', 'default-host', config.host], { ...rustEnv, stdio: 'ignore' });
|
|
25
|
+
await execAsync(rustup, ['toolchain', 'install', config.toolchain, '--profile', 'default', '--no-self-update'], { ...rustEnv, stdio: 'ignore' });
|
|
26
|
+
await execAsync(rustup, ['default', config.toolchain], { ...rustEnv, stdio: 'ignore' });
|
|
27
|
+
if (refresh)
|
|
28
|
+
await execAsync(rustup, ['update'], rustEnv);
|
|
29
|
+
}
|
|
30
|
+
Object.assign(env.vars, { RUSTUP_HOME, CARGO_HOME });
|
|
31
|
+
env.prepend.push(path.join(CARGO_HOME, 'bin'));
|
|
32
|
+
env.summary.push('rust: ' + versionOf(path.join(CARGO_HOME, 'bin', 'rustc.exe'), ['--version'], rustEnv) + ' [' + config.host + ']');
|
|
33
|
+
const toolchainKey = 'rustup@' + config.toolchain;
|
|
34
|
+
await installOnce(env, toolchainKey + ' components', config.components, (c) => execAsync(rustup, ['component', 'add', c], rustEnv));
|
|
35
|
+
await installOnce(env, toolchainKey + ' targets', config.targets, (t) => execAsync(rustup, ['target', 'add', t], rustEnv));
|
|
36
|
+
// cargo install links with MSVC's link.exe (msvc host) or MinGW's gcc (GNU host). Those steps ran first, but their
|
|
37
|
+
// PATH only reaches the agent at the end, so it is put together here.
|
|
38
|
+
const msvc = config.host.endsWith('-msvc') ? installedMsvcEnv() : null;
|
|
39
|
+
const mingw = tool('mingw', 'mingw64', 'bin');
|
|
40
|
+
const cargoEnv = msvc
|
|
41
|
+
? { env: { ...rustEnv.env, ...msvc.vars, PATH: [path.join(CARGO_HOME, 'bin'), ...msvc.path, process.env.PATH ?? ''].join(path.delimiter) } }
|
|
42
|
+
: { env: { ...rustEnv.env, CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: path.join(mingw, 'gcc.exe'), PATH: [path.join(CARGO_HOME, 'bin'), mingw, process.env.PATH ?? ''].join(path.delimiter) } };
|
|
43
|
+
// Prebuilt through cargo-binstall where the crate publishes a Windows build, else compiled (same "cargo" keys as before).
|
|
44
|
+
await installOnce(env, 'cargo', config.crates, crateInstaller(CARGO_HOME, cargoEnv));
|
|
45
|
+
};
|
|
@@ -4,8 +4,10 @@ import fs from 'node:fs';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
6
|
import { fetchJson, githubAsset, installArchive } from '../../shared/download.js';
|
|
7
|
+
import { safeRemove } from '../../shared/safe-remove.js';
|
|
7
8
|
import { copyNode, dryRun, errMsg, execAsync, exists, hostToolsDir, localDir, log, mkdirp, warn } from '../env.js';
|
|
8
9
|
import { arch, installOnce, resolveCached, tool } from './common.js';
|
|
10
|
+
import { duringSession } from '../project-context.js';
|
|
9
11
|
import { pickNodeVersion, pickSpreadVersions } from './versions.js';
|
|
10
12
|
const NVM_HOME = tool('nvm');
|
|
11
13
|
const NVM_SYMLINK = path.join(localDir, 'nodejs');
|
|
@@ -41,7 +43,9 @@ const ensureNvm = async () => {
|
|
|
41
43
|
if (exists(path.join(HOST_NVM, 'nvm.exe'))) {
|
|
42
44
|
log('Copying nvm from this PC ...');
|
|
43
45
|
mkdirp(NVM_HOME);
|
|
44
|
-
|
|
46
|
+
// nvm.exe last: it is what marks the install as done, so an interrupted copy is redone.
|
|
47
|
+
const files = fs.readdirSync(HOST_NVM).filter((f) => /\.(exe|cmd|vbs)$/i.test(f)).sort((a, b) => Number(a.toLowerCase() === 'nvm.exe') - Number(b.toLowerCase() === 'nvm.exe'));
|
|
48
|
+
for (const file of files)
|
|
45
49
|
fs.copyFileSync(path.join(HOST_NVM, file), path.join(NVM_HOME, file));
|
|
46
50
|
return;
|
|
47
51
|
}
|
|
@@ -61,10 +65,15 @@ const installNodeVersion = async (version) => {
|
|
|
61
65
|
copyNode(fromHost, dir);
|
|
62
66
|
return;
|
|
63
67
|
}
|
|
64
|
-
log('
|
|
68
|
+
log('Downloading Node ' + version + ' (~30 MB once) ...');
|
|
65
69
|
mkdirp(NVM_TEMP);
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
let out;
|
|
71
|
+
try {
|
|
72
|
+
out = await nvm(['install', version]);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
safeRemove(NVM_TEMP, NVM_HOME);
|
|
76
|
+
}
|
|
68
77
|
if (!exists(path.join(dir, 'node.exe')))
|
|
69
78
|
throw new Error('nvm install ' + version + ' failed: ' + out.trim().split('\n').slice(-2).join(' '));
|
|
70
79
|
};
|
|
@@ -102,9 +111,15 @@ export const setupNode = async (env, versions, config) => {
|
|
|
102
111
|
warn('Node ' + version + ' from this PC: ' + errMsg(e));
|
|
103
112
|
}
|
|
104
113
|
}
|
|
105
|
-
await activate(main);
|
|
106
114
|
Object.assign(env.vars, { NVM_HOME, NVM_SYMLINK });
|
|
107
|
-
|
|
115
|
+
// At boot, nvm's symlink selects the version. A project added later must not switch it under the sessions already
|
|
116
|
+
// running: its own version's folder goes first on its sessions' PATH instead.
|
|
117
|
+
if (duringSession())
|
|
118
|
+
env.prepend.push(path.join(NVM_HOME, 'v' + main), NVM_HOME, NVM_SYMLINK);
|
|
119
|
+
else {
|
|
120
|
+
await activate(main);
|
|
121
|
+
env.prepend.push(NVM_HOME, NVM_SYMLINK);
|
|
122
|
+
}
|
|
108
123
|
env.summary.push('node: ' + main + ' (from ' + versions.node.source + ', switch with nvm use)');
|
|
109
124
|
await packageManagers(env, config, main);
|
|
110
125
|
};
|
|
@@ -122,6 +137,11 @@ const packageManagers = async (env, config, version) => {
|
|
|
122
137
|
// Without a packageManager pin, corepack's own known-good versions: the newest pnpm can be one this corepack cannot
|
|
123
138
|
// start. Mapped folders allow no symlinks, so pnpm uses a flat (hoisted) node_modules instead of its linked layout.
|
|
124
139
|
Object.assign(env.vars, { COREPACK_HOME: tool('corepack'), COREPACK_ENABLE_DOWNLOAD_PROMPT: '0', COREPACK_DEFAULT_TO_LATEST: '0', npm_config_node_linker: 'hoisted' });
|
|
140
|
+
// The shims are shared by every session: a project added later keeps the ones made at boot.
|
|
141
|
+
if (duringSession() && exists(tool('bin', 'pnpm.cmd'))) {
|
|
142
|
+
env.summary.push('pnpm, yarn: via corepack');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
125
145
|
try {
|
|
126
146
|
await execAsync(path.join(dir, 'node.exe'), [corepackJs, 'enable', '--install-directory', mkdirp(tool('bin')), 'pnpm', 'yarn'], { env: nodeEnv, stdio: 'ignore' });
|
|
127
147
|
env.summary.push('pnpm, yarn: via corepack (package.json "packageManager" picks the version)');
|