omnisharp-roslyn icon indicating copy to clipboard operation
omnisharp-roslyn copied to clipboard

"Could not find a part of the path" using VS 2022 msbiuld

Open aburgett87 opened this issue 3 years ago • 10 comments

When opening a solution with a long file path in VS Code using either VS 2022 msbuild or the standalone msbiuld the intellisense is broken.

The console app project will execute correctly when running dotnet run and VS 2022 correctly displays the solution.

I receive an error "Could not find a part of the path" in the omnisharp logs.

C# extension version v1.23.16

MS Build versions:

  1. Visual Studio Professional 2022 17.0.31825.309 17.0.0
  2. StandAlone 17.0.0

O/S: Windows 10 (21H1) Build 19043.1288

Log File: scratch2.txt

Reproducible solution: test-proj.zip

Logs of interest:

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\AlexBurgett\devel\temp\test-proj\src\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
        Could not find a part of the path 'c:\Users\AlexBurgett\devel\temp\test-proj\src\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long\obj\Debug\net6.0\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long.GeneratedMSBuildEditorConfig.editorconfig'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\AlexBurgett\devel\temp\test-proj\sr
c\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long.csproj'.
c:\Users\AlexBurgett\devel\temp\test-proj\src\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long.csproj
C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targets(190,5): Error: Could not find a part of the path 'c:\Users\AlexBurgett\devel\temp\test-proj\src\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long\obj\Debug\net6.0\A.Really.Long.Long.Long.Long.Long.File.Path.That.Is.Really.Long.I.Mean.Really.Long.GeneratedMSBuildEditorConfig.editorconfig'.

aburgett87 avatar Nov 01 '21 03:11 aburgett87

I have the same issue, but I was able to fix it by enabling "long path support" in Windows 10: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

schuettecarsten avatar Nov 23 '21 07:11 schuettecarsten

@schuettecarsten I've got long paths enabled in the registry.

Interestingly, following the page you provided, the application's manifest must be long path aware. I checked the msbuild exe's manifest and it is long path aware, but the omnisharp.exe isn't.

aburgett87 avatar Dec 07 '21 02:12 aburgett87

The manifest file was the issue, by adding an app.manifest and enabling long paths (see https://github.com/OmniSharp/omnisharp-roslyn/pull/2298) I was able to successfully utilise omnisharp in vscode

aburgett87 avatar Dec 07 '21 03:12 aburgett87

But why in VS2022 only. same thing build in VS 2019

KamranShahid avatar Jun 15 '22 08:06 KamranShahid

I have the same issue, but I was able to fix it by enabling "long path support" in Windows 10: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

Thanks, it helped me too

mbritov avatar Sep 28 '22 10:09 mbritov

I have the same issue, but I was able to fix it by enabling "long path support" in Windows 10: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

I had an issue that .NET can't build the .editorconfig with a long path file and this is helped

ivanko337 avatar Mar 07 '23 15:03 ivanko337

I have the same issue, but I was able to fix it by enabling "long path support" in Windows 10: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

I had the same issue in the VS2022 with Windows 11. and this helped.

javedali-dev avatar Aug 23 '23 07:08 javedali-dev

I have the same issue, but I was able to fix it by enabling "long path support" in Windows 10: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

Sorry to bump, but fixed my issue aswell.

jarnedhaene avatar Oct 06 '23 12:10 jarnedhaene

Thank you guys, https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry, also fixed my issue.

Proud-Sachinda avatar Apr 04 '24 07:04 Proud-Sachinda

it works!

marcosrobles-qo avatar Apr 24 '24 17:04 marcosrobles-qo