Repository navigation
Description
Already reported by @ariccio here: #53
but a new ticket, because of 64-bit variant isn't solved.
As seen in Fix 260 character file name length limitation, there's quite a bit of support for better longer-than-MAX_PATH-filename handling.
Will Buik's response w/regard to fixing it was:
We understand that this can be a frustrating issue, however, fixing it requires a large and complicated architectural change across different products and features including Visual Studio, TFS, MSBuild and the .NET Framework. Dedicating resources to this work item would come at the expense of many other features and innovation.I wondered, how big can those architectural changes be (for MSBuild)?
According to Naming Files, Paths, and Namespaces: Maximum Path Length Limitation, (which I have mirrored here ):
The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path". [other stuff] Because you cannot use the "\\?\" prefix with a relative path, relative paths are always limited to a total of MAX_PATH characters.(emphasis mine)
...Which means that wherever MSBuild uses full paths, we can should be able to just prepend "\?" to ask for a long path.
Of course, we'd need to rework the existing path-length-workaround hack.
This won't fix the whole ecosystem, but it'll get us just one step closer.
I'd like to fix this myself (it seems simple enough), so in accordance with:
Contributions must be discussed with the team first, or they will likely be declined. As our process matures and our experience grows, the team expects to take larger contributions. Only contributions referencing an approved Issue will be accepted....this is the suggested issue.
I'm a native developer at heart, not an experienced C# developer, but this shouldn't require anything crazy.
Direct references to MAX_PATH:
NativeMethods.cs#L15 NativeMethodsShared_Tests.cs#L53 NativeMethodsShared.cs#L318 NativeMethodsShared.cs#L540 NativeMethodsShared.cs#L750 FileState.cs#L293 ComReference.cs#L460 TargetsFile_Test.cs#L2041
Activity
rainersigwald commentedon May 4, 2020
Can you provide some repro steps? what kind of project are you building? How exactly are you launching MSBuild?
mahaase commentedon May 5, 2020
In my case, we use bob (build automation tool) which uses e.g. CMake to build windows binaries. CMake calls the msbuild by using the CMake VS2019 generators.
In some cases, the build automation tool creates paths, which resulting with the MAX_PATH issues.
It isn't possible to handle this paths, they will auto-generated by the tool.
refer: #53 (comment)
more references:
refer: #53 (comment)
refer: #53 (comment)
But, generally I guess, we don't need any special use-case to reproduce - I guess there is no case, where the issue doesn't occurs if the paths just long enough.
rainersigwald commentedon May 6, 2020
@benvillalobos, can you try to repro?
mahaase commentedon May 15, 2020
@benvillalobos could you please 👍
goldsam commentedon Jun 4, 2020
rainersigwald commentedon Jun 25, 2020
@mahaase (or anyone): Can you try patching your
amd64\MSBuild.exe.configfile like this:? That appears to resolve the problem for me.
Support long paths on amd64
dannyvv commentedon Jun 26, 2020
I can confirm that this makes the long path errors go away. If anyone needs a workaround for this in their CI system, the following step before building does the trick for our queue.
13 remaining items
spanevin commentedon Apr 7, 2021
Any updates? long path is a real issue...
odalet commentedon Apr 12, 2021
I thought this was fixed in 16.9, but I still had the issue. I've examined some of the commits here and it seems it was once part of the code base, but then removed. Any reason why? Now the target release is 16.10...
Btw, manually modifying
amd64\MSBuild.exe.configdid the trick, so I'm just wondering why this is still not official...spanevin commentedon May 14, 2021
up
spanevin commentedon May 14, 2021
https://github.com/dotnet/msbuild/milestone/51
I don't see this issue here, where else I can check that target release is really 16.10 ?
Explicitly list amd64 quirks
Opt into quirks in amd64 MSBuild explicitly (#6562)
jasonycw commentedon Aug 18, 2021
Hi, I was brought here by https://developercommunity.visualstudio.com/t/msbuild-editorconfig-filename-length-issues/1462559
And I had updated my
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64\MSBuild.exe.configto haveBut my VS still not able to build properly and showing
The error point to this line in

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targetswhich is not my projectTried running
dotnet builddirectly in the root folder and it can build properly.Running Microsoft Visual Studio Community 2019 Version 16.11.1
KrisThielemans commentedon Sep 15, 2022
I have this problem with Visual Studio Community 2022
I've tried patching the
MSBuild.exe.configbut that didn't help.KrisThielemans commentedon Nov 3, 2022
apologies. This wasn't
msbuild, it was actually the OS path limit, as it said...(Setting the registry key via
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1wasn't enough for me (Windows 10 Pro). I had to use the Group Policy editor as well.)Apologies for the noise.
neominky commentedon Apr 15, 2024
This bug still exists. (17.9.6, x64, .NET8) Why isn't it fixed?

In my case, an error occurs even with a folder length of 122 characters. Is it because it is a non-ascii country?
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1is not workspatching "MSBuild.exe.config" is not works
rainersigwald commentedon Apr 15, 2024
@neominky please file a new issue describing your problem, including details about how you are launching the build.