Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSBuild] PathTooLongException #252

Closed
pkupilas opened this issue Aug 23, 2016 · 8 comments
Closed

[MSBuild] PathTooLongException #252

pkupilas opened this issue Aug 23, 2016 · 8 comments

Comments

@pkupilas
Copy link

I got an issue in msbuild. While NSwag searchs for assemblies the PathTooLongException appears. It's happening only in specific situation but still..

System.AggregateException: One or more errors occurred. ---> System.IO.FileLoadException: Could not load file or assembly 'myassembly' or one of its dependencies. The filename or extension is too long. ---> System.IO.PathTooLongException: 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.
5>     at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
5>     at System.IO.Path.GetDirectoryName(String path)
5>     at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
5>     at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
5>     at NSwag.CodeGeneration.SwaggerGenerators.AssemblyLoader.<>c__DisplayClass0_0.<RegisterReferencePaths>b__1(Object sender, ResolveEventArgs args)
5>     at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
5>     --- End of inner exception stack trace ---

I googled it and found this post.
Is it possible to consider external libs like Delimon.Win32.I​O to avoid this problem?

@RicoSuter
Copy link
Owner

RicoSuter commented Aug 23, 2016

Maybe .NET 4.6.2 solves this problem: http://stackoverflow.com/a/38889598/876814

Can you clone the project, change NSwagStudio or the command line tool to .NET 4.6.2 and enable long path support (https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/)? Then try again...

@pkupilas
Copy link
Author

Well after changes in .net framework versions:

4.6.2 NSwag && NSwagStudio - DirectoryNotFoundException

System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Could not load file or assembly 'MyAssembly, Version=0.0.1.0, Culture=neutral, PublicKeyToken=485d6168b1ae96cc' or one of its dependencies. The system cannot find the path specified. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\gitrepo\mfxi\External Tools\swagger-merger\node_modules\swagger-merge\node_modules\swagger2-utils\node_modules\z-schema\node_modules\request\node_modules\har-validator\node_modules\is-my-json-valid\node_modules\generate-object-property\node_modules'.
5>     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
5>     at System.IO.FileSystemEnumerableIterator`1.CommonInit()
5>     at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
5>     at NSwag.CodeGeneration.SwaggerGenerators.AssemblyLoader.<>c__DisplayClass0_0.<RegisterReferencePaths>b__1(Object sender, ResolveEventArgs args) in C:\Users\piotrku\Documents\tmp\Nswagv5\NSwag-master\src\NSwag.AssemblyLoader\SwaggerGenerators\AssemblyLoader.cs:line 35
5>     at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
5>     --- End of inner exception stack trace ---

4.6 NSwag && NSwagStudio - PathTooLongException

System.AggregateException: One or more errors occurred. ---> System.IO.FileLoadException: Could not load file or assembly 'MyAssembly, Version=0.0.1.0, Culture=neutral, PublicKeyToken=485d6168b1ae96cc' or one of its dependencies. The filename or extension is too long. ---> System.IO.PathTooLongException: 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.
5>     at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
5>     at System.IO.Path.InternalGetDirectoryName(String path)
5>     at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
5>     at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
5>     at NSwag.CodeGeneration.SwaggerGenerators.AssemblyLoader.<>c__DisplayClass0_0.<RegisterReferencePaths>b__1(Object sender, ResolveEventArgs args) in C:\Users\piotrku\Documents\tmp\Nswagv5\NSwag-master\src\NSwag.AssemblyLoader\SwaggerGenerators\AssemblyLoader.cs:line 35
5>     at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
5>     --- End of inner exception stack trace ---

Are you sure MSBuild and VS are supported with this MAX_PATH change?
According to your source (comments).

Petr Vones
After many years the legacy MAX_PATH limitation is gone. Thanks ! Will also MSBuild and Visual Studio take advantage of it ?

JeremyKuhne
Not yet. Getting the blocks removed from .NET is the first step to making MAX_PATH a thing of the past.

Immo Landwerth [MSFT]
We haven’t yet updated the VM to support loading DLLs on long paths. So take this feature in .NET Framework 4.6.2 as a large step in the right direction, but don’t expect that Long Path issues are completely gone yet.

@RicoSuter
Copy link
Owner

Are you using the recently released .net v4.6.2?

@pkupilas
Copy link
Author

It's working now with v5 due to changes in #242.

@RicoSuter
Copy link
Owner

RicoSuter commented Aug 26, 2016

Really? Why did this solve this issue here? The paths are still too long, or arent they?

@pkupilas
Copy link
Author

After changes in #242 I don't use @referencepaths so NSwag doesn't need to look through whole solution because paths to dlls are already known (NSwag doesn't get into this unfortunate folder).

@RicoSuter
Copy link
Owner

I think this is just "luck", the problem itself is not solved... But i dont know how easy it is to fix...

@RicoSuter
Copy link
Owner

Closing as not seen for a long time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@RicoSuter @pkupilas and others