From d84d54f2e5d3d66d81453fbd5fafbeeecd0d6cde Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Tue, 30 May 2023 08:02:33 -0700 Subject: [PATCH] Move LongPath check to MSBuild target (#68217) The Roslyn repository effectively depends on having long paths enabled at this point. Between NuGet and the VSSDK, both outside our control, our repository runs right up against `MAX_PATH` limits even with a very short user name. A user name of any significant length will quickly run into issues in our repo. The repository already warns about long path support, and has for some time, but it does so in command line builds. That was a fine experience when it was added as long path support was new and was only needed in a few cases. Now though it's effectivtely needed for everyone so need to give it more visibility by elevating it to an MSBuild warning. This warning is _deliberately_ not configurable. Having long paths disabled at this point means your inner loop dev experience is broken in strange, hard to diagnose ways. Co-authored-by: Jared Parsons --- eng/build.ps1 | 5 ----- eng/enable-long-paths.reg | 4 ++++ eng/targets/Imports.targets | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 eng/enable-long-paths.reg diff --git a/eng/build.ps1 b/eng/build.ps1 index 9086c7de7bce7..300b675bad461 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -711,11 +711,6 @@ try { exit 1 } - $regKeyProperty = Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem -Name "LongPathsEnabled" -ErrorAction Ignore - if (($null -eq $regKeyProperty) -or ($regKeyProperty.LongPathsEnabled -ne 1)) { - Write-Host "LongPath is not enabled, you may experience build errors. You can avoid these by enabling LongPath with `"reg ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1`"" - } - Process-Arguments . (Join-Path $PSScriptRoot "build-utils.ps1") diff --git a/eng/enable-long-paths.reg b/eng/enable-long-paths.reg new file mode 100644 index 0000000000000..a49f4aae6c1fa --- /dev/null +++ b/eng/enable-long-paths.reg @@ -0,0 +1,4 @@ +Windows Registry Editor Version 5.00 + +[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] +"LongPathsEnabled"=dword:00000001 diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets index 0cb7758b747c0..4da62950a42f5 100644 --- a/eng/targets/Imports.targets +++ b/eng/targets/Imports.targets @@ -154,6 +154,14 @@ Condition="$(_VersionComparisonResult) < 0"/> + + + <_RoslynLongPathsEnabled>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled', null, RegistryView.Registry64, RegistryView.Registry32)) + + + + +