1- # This creates a 20GB dev drive, and exports all required environment
2- # variables so that rustup, uv and others all use the dev drive as much
3- # as possible.
4- $Volume = New-VHD - Path C:/ uv_dev_drive.vhdx - SizeBytes 20 GB |
5- Mount-VHD - Passthru |
6- Initialize-Disk - Passthru |
7- New-Partition - AssignDriveLetter - UseMaximumSize |
8- Format-Volume - FileSystem ReFS - Confirm:$false - Force
1+ # Configures a dev drive for Windows CI to speed up Rust builds.
2+ #
3+ # The main performance win is disabling Windows Defender antivirus scanning
4+ # on the build drive — AV scanning every .o, .rlib, .rmeta, and .exe during
5+ # a Rust build is extremely expensive.
6+ #
7+ # Three code paths:
8+ # 1. D: drive exists (some runners) — use it directly
9+ # 2. Hyper-V available — create a Dev Drive VHD (best perf, supports fsutil devdrv)
10+ # 3. No Hyper-V (Warp/EC2 runners) — use diskpart + ReFS format
911
10- Write-Output $Volume
12+ if (Test-Path " D:\" ) {
13+ Write-Output " Using existing drive at D:"
14+ $Drive = " D:"
15+ } elseif (Get-Command New-VHD - ErrorAction SilentlyContinue) {
16+ # Hyper-V is available — create a proper Dev Drive
17+ $Volume = New-VHD - Path C:/ dev_drive.vhdx - SizeBytes 25 GB |
18+ Mount-VHD - Passthru |
19+ Initialize-Disk - Passthru |
20+ New-Partition - AssignDriveLetter - UseMaximumSize |
21+ Format-Volume - DevDrive - Confirm:$false - Force
1122
12- $Drive = " $ ( $Volume.DriveLetter ) :"
13- $Tmp = " $ ( $Drive ) /uv-tmp"
23+ $Drive = " $ ( $Volume.DriveLetter ) :"
1424
15- # Create the directory ahead of time in an attempt to avoid race-conditions
16- New-Item $Tmp - ItemType Directory
25+ # Mark as trusted and disable antivirus filtering
26+ fsutil devdrv trust $Drive
27+ fsutil devdrv enable / disallowAv
28+
29+ # Remount so the changes take effect
30+ Dismount-VHD - Path C:/ dev_drive.vhdx
31+ Mount-VHD - Path C:/ dev_drive.vhdx
32+
33+ Write-Output $Volume
34+ fsutil devdrv query $Drive
35+ Write-Output " Created Dev Drive at $Drive "
36+ } else {
37+ # No Hyper-V — fall back to diskpart + ReFS
38+ Write-Output " No Hyper-V detected, creating ReFS drive via diskpart..."
39+
40+ $vhdPath = " C:\dev_drive.vhdx"
41+ @"
42+ create vdisk file="$vhdPath " maximum=25600 type=expandable
43+ attach vdisk
44+ create partition primary
45+ active
46+ assign letter=V
47+ "@ | diskpart
48+
49+ format V: / fs:ReFS / q / y
50+ $Drive = " V:"
51+
52+ Write-Output " Created ReFS drive at $Drive "
53+ }
54+
55+ $Tmp = " $ ( $Drive ) \tmp"
56+
57+ # Create directories ahead of time to avoid race conditions
58+ New-Item $Tmp - ItemType Directory - Force
59+
60+ # Move Cargo to the dev drive so registry/crate downloads also benefit
61+ New-Item - Path " $ ( $Drive ) /.cargo/bin" - ItemType Directory - Force
62+ if (Test-Path " C:/Users/runneradmin/.cargo" ) {
63+ Copy-Item - Path " C:/Users/runneradmin/.cargo/*" - Destination " $ ( $Drive ) /.cargo/" - Recurse - Force
64+ }
1765
1866Write-Output `
19- " DEV_DRIVE=$ ( $Drive ) " `
20- " TMP=$ ( $Tmp ) " `
21- " TEMP=$ ( $Tmp ) " `
22- " RUSTUP_HOME=$ ( $Drive ) /.rustup" `
23- " CARGO_HOME=$ ( $Drive ) /.cargo" `
24- " UV_WORKSPACE =$ ( $Drive ) /uv " `
25- " PATH=$ ( $Drive ) /.cargo/bin;$env: PATH " `
26- >> $env: GITHUB_ENV
67+ " DEV_DRIVE=$ ( $Drive ) " `
68+ " TMP=$ ( $Tmp ) " `
69+ " TEMP=$ ( $Tmp ) " `
70+ " RUSTUP_HOME=$ ( $Drive ) /.rustup" `
71+ " CARGO_HOME=$ ( $Drive ) /.cargo" `
72+ " DIOXUS_WORKSPACE =$ ( $Drive ) /dioxus " `
73+ " PATH=$ ( $Drive ) /.cargo/bin;$env: PATH " `
74+ >> $env: GITHUB_ENV
0 commit comments