Omnisharp-vscode: The project system 'DotNetProjectSystem' threw exception during initialization. The specified path, file name, or both are too long

Created on 5 May 2016  路  10Comments  路  Source: OmniSharp/omnisharp-vscode

When editing my project even the slightest space breaks the omnisharp service with the following errors. Seems like a windows max path issue to me but don't seem to make any sense. I tried to copy my project from the c:\Users\[username]\Repos\[solution]\[projectname]\ to a shallow location in c:\[projectname] and it worked did not work after all. The length of the path is about 60 characters long anyway (way shorter than 248).

Since I like my solutions organized I would like to know If this is considered a bug and will be fixed in future versions.

Cheers and keep up the good work.

The error

[INFORMATION:OmniSharp.DotNet.DotNetProjectSystem] Processing [ProjectState] MyCoreApp.WebApi/.NETCoreApp,Version=v1.0
[ERROR:OmniSharp.Startup] The project system 'DotNetProjectSystem' threw exception during initialization.
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.FileSystemEnumerableIterator1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler1 resultHandler, Boolean checkHost)
at System.IO.DirectoryInfo.EnumerateFileSystemInfos(String searchPattern, SearchOption searchOption)
at Microsoft.Extensions.FileSystemGlobbing.Abstractions.DirectoryInfoWrapper.d__3.MoveNext()
at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Execute()
at Microsoft.Extensions.FileSystemGlobbing.MatcherExtensions.GetResultsInFullPath(Matcher matcher, String directoryPath)
at Microsoft.DotNet.ProjectModel.Files.PatternGroup.SearchFiles(String rootPath)
at Microsoft.DotNet.ProjectModel.Files.ProjectFilesCollection.get_SourceFiles()
at OmniSharp.DotNet.Tools.ProjectContextLens.Resolve() in C:\projects\omnisharp-roslyn\src\OmniSharp.DotNet\Tools\ProjectContextLens.cs:line 41
at OmniSharp.DotNet.DotNetProjectSystem.Update(Boolean allowRestore) in C:\projects\omnisharp-roslyn\src\OmniSharp.DotNet\DotNetProjectSystem.cs:line 134
at OmniSharp.DotNet.DotNetProjectSystem.Initalize(IConfiguration configuration) in C:\projects\omnisharp-roslyn\src\OmniSharp.DotNet\DotNetProjectSystem.cs:line 108
at OmniSharp.Startup.Configure(IApplicationBuilder app, IServiceProvider serviceProvider, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ISharedTextWriter writer, IOmnisharpAssemblyLoader loader, IOptions`1 optionsAccessor) in C:\projects\omnisharp-roslyn\src\OmniSharp.Host\Startup.cs:line 182
[INFORMATION:OmniSharp.MSBuild.MSBuildProjectSystem] No solution files found in 'c:\Users\cleft\Source\Repos\helintec\helintec.Forms.Web'
[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Detecting CSX files in 'c:\Users\cleft\Source\Repos\helintec\helintec.Forms.Web'.
[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Could not find any CSX files
[INFORMATION:OmniSharp.Startup] Configuration finished.
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /projects: 500 351ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /projects: 500 283ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /projects: 500 250ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /projects: 500 250ms

my setup:

.NET Command Line Tools (1.0.0-rc2-002659)

Product Information:
Version: 1.0.0-rc2-002659
Commit Sha: 11a001706f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.14295
OS Platform: Windows
RID: win10-x64

I run on Vs Code insiders v 1.1.0-insider and have installed the RC2 Release Candidate for 4/29.

Most helpful comment

@troydai One more thing I noticed.
I am currently running on the latest dotnet core where the project.json schema has changed (announcement). The omnisharp plugin currently supports ignoring folders the old way.

This means that the RC2 Release Candidate for 4/29 needs exclude member to be outside of buildOptions.

{
  "description": "My App",
  "authors": [ "indice" ],
  "packOptions": {
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": ""
  },
  "exclude": "node_modules",  <-- this works
  "buildOptions": {
    "preserveCompilationContext": true,
    "emitEntryPoint": true,
    "debugType": "portable",
    "compile": {
      "exclude": "node_modules" <-- this does not work!

    }
  },
 ...
}

All 10 comments

@troydai: this looks like it's within the OmniSharp server. Any ideas?

@cleftheris can you share your project.json with us? In addition do you have a deep folder structure like node_modules in your project? You can configure the project.json to ignore the folder to avoid globbing the folder (https://github.com/aspnet/Home/wiki/Project.json-file)

In addition, can you try dotnet build this project from command line. This can help me to locate if the problem is with O# or CLI.

Nevertheless, please share the project.json, I'll take a look.

@DustinCampbell can you assign this to me? Once I accomplish the investigation, I will create an issue in either CLI or OmniSharp-Roslyn.

@troydai

  1. Yes I have node_modules for my gulp tasks but haven't tried to ignore that in project.json. I will have to come back to you.
  2. The project builds and runs just fine both from vscode and through command line (dotnet build). The experience is more like when I edit a c# Controller class the intellisence and codelense features break and then I get red squiggly everywhere. When this happens the project still compiles and runs (provided I don't have syntax errors offcourse).

Here is my project.json

{
  "description": "My App",
  "authors": [ "cleftheris" ],
  "packOptions": {
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": ""
  },
  "buildOptions": {
    "preserveCompilationContext": true,
    "emitEntryPoint": true,
    "debugType": "portable"
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "Views"
    ]
  },
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
    "Microsoft.AspNetCore.Mvc": "1.0.0-*",
    "Microsoft.AspNetCore.Mvc.Formatters.Json": "1.0.0-*",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0-*",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-*",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-*",
    "Microsoft.EntityFrameworkCore": "1.0.0-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-*",
    "Microsoft.EntityFrameworkCore.Commands": "1.0.0-*",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-*"
    },
    "Newtonsoft.Json": "8.0.3"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "portable-net451+win8",
        "dnxcore50"
      ]
    }
  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-*",
      "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
    }
  },
  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
  }
}

@troydai Wow I added the exclude property like so "exclude": "node_modules" and now it works. But why?? Is it scanning for c# everywhere under the root directory... probably.

Why is this still an issue even for dotnet core.? I thought dotnet core gave an excellent opportunity for breaking changes so why not getting rid of the old 260 character path length limit?. Beats me ...

Thanks for the help.

@cleftheris thanks for reporting back. I'm glad that the exclude property helps.

The CLR project model does search all folders. It is because we don't list files in project.json. So globbing files is the mechanism.

It is not a problem for .NET Core. The long path issue is fixed there. However VS Code C# Extension uses the .NET Framework 4.5.1 version of OmniSharp, which relies on full CLR.

@troydai thanks for the explanation & keep up the good work!

@cleftheris thanks for using VS Code C# Extension, too!

@troydai One more thing I noticed.
I am currently running on the latest dotnet core where the project.json schema has changed (announcement). The omnisharp plugin currently supports ignoring folders the old way.

This means that the RC2 Release Candidate for 4/29 needs exclude member to be outside of buildOptions.

{
  "description": "My App",
  "authors": [ "indice" ],
  "packOptions": {
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": ""
  },
  "exclude": "node_modules",  <-- this works
  "buildOptions": {
    "preserveCompilationContext": true,
    "emitEntryPoint": true,
    "debugType": "portable",
    "compile": {
      "exclude": "node_modules" <-- this does not work!

    }
  },
 ...
}

@cleftheris OmniSharp you're using probably hasn't picked up the latest dotnet project model yet.

Was this page helpful?
0 / 5 - 0 ratings