-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dx: warn about long paths disabled (#11140)
- Loading branch information
Showing
5 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Handling long paths on windows | ||
|
||
This repository requires [windows long paths support] to be enabled. | ||
|
||
## Git | ||
In order to clone sucessfully, you might need to allow for [git long paths]: | ||
```shell | ||
git config --global core.longpaths true | ||
``` | ||
|
||
## Building | ||
While working with the project, you might encounter load- or buildtime-errors popping up, hinting on paths being too long on your local environment, f.e.: | ||
``` | ||
error MSB4248: Cannot expand metadata in expression "$([MSBuild]::ValueOrDefault('%(FullPath)', '').StartsWith($([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))))". | ||
The item metadata "%(FullPath)" cannot be applied to the path "TestFiles\IntegrationTests\ComponentDesignTimeCodeGenerationTest\GenericComponent_GenericEventCallbackWithGenericTypeParameter_NestedTypeInference\TestComponent.mappings.txt". | ||
Path: {{REPOSITORY_ROOT}}\src\Compiler\Microsoft.AspNetCore.Razor.Language\test\TestFiles\IntegrationTests\ComponentDesignTimeCodeGenerationTest\GenericComponent_GenericEventCallbackWithGenericTypeParameter_NestedTypeInference\TestComponent.mappings.txt exceeds the OS max path limit. The fully qualified file name must be less than 260 characters. | ||
``` | ||
|
||
or similar. | ||
|
||
This repository also generates a warning when building on windows and long paths are not enabled: | ||
``` | ||
error LongPathsDisabled: Long paths are required for this project. See 'docs/contributing/LongPaths.md' on how to overcome this. | ||
``` | ||
|
||
To overcome this, apply one of the following options: | ||
|
||
### Enable long path support | ||
> :bulb: This is the preferred approach of the razor team | ||
Either import / execute [/eng/enable-long-path.reg] or invoke the following powershell-script from an elevated prompt: | ||
|
||
```ps1 | ||
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value "1" -PropertyType DWORD -Force | ||
``` | ||
|
||
[git long paths]:https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows | ||
[windows long paths support]:https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later | ||
[/eng/enable-long-path.reg]:../../eng/enable-long-paths.reg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Windows Registry Editor Version 5.00 | ||
|
||
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] | ||
"LongPathsEnabled"=dword:00000001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
<Import Project="Packaging.targets" /> | ||
|
||
<Target Name="_CheckLongPathSupport" BeforeTargets="BeforeBuild;CollectPackageReferences" Condition="'$(MSBuildRuntimeType)' == 'Full'"> | ||
<PropertyGroup> | ||
<_RazorLongPathsEnabled>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled', null, RegistryView.Registry64, RegistryView.Registry32))</_RazorLongPathsEnabled> | ||
</PropertyGroup> | ||
<Warning Condition="'$(_RazorLongPathsEnabled)' != '1'" | ||
Code="LongPathsDisabled" | ||
Text="Long paths are required for this project. See 'docs/contributing/LongPaths.md'" | ||
HelpLink="https://github.com/dotnet/razor/blob/main/docs/contributing/LongPaths.md" | ||
/> | ||
</Target> | ||
|
||
</Project> |