diff --git a/eng/build.ps1 b/eng/build.ps1 index 1401f5c72b55ca..e01d1b9ecdcaee 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -135,6 +135,29 @@ function Get-Help() { Write-Host "For more information, check out https://github.com/dotnet/runtime/blob/main/docs/workflow/README.md" } +function Check-LongPathSupport() { + $regValue = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -ErrorAction SilentlyContinue + + if ($regValue -and $regValue.LongPathsEnabled -eq 1) { + return + } + + Write-Host "" + Write-Host "ERROR: Long file paths are not enabled on this system." -ForegroundColor Red + Write-Host "The dotnet/runtime repository requires long path support to build successfully." -ForegroundColor Red + Write-Host "" + Write-Host "Please follow the instructions at:" -ForegroundColor Yellow + Write-Host " docs\workflow\requirements\windows-requirements.md#enable-long-paths" -ForegroundColor Yellow + Write-Host "" + Write-Host "Quick fix:" -ForegroundColor Yellow + Write-Host " 1. Enable long paths in Windows (requires admin):" -ForegroundColor White + Write-Host " https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation" -ForegroundColor White + Write-Host " 2. Enable long paths in Git:" -ForegroundColor White + Write-Host " git config --system core.longpaths true" -ForegroundColor White + Write-Host "" + exit 1 +} + if ($help) { Get-Help exit 0 @@ -152,6 +175,8 @@ if ($subset -eq 'help') { exit 0 } +Check-LongPathSupport + # Lower-case the passed in OS string. if ($os) { $os = $os.ToLowerInvariant()