Closed JBBianchi closed 7 months ago
Indeed let me take a look
Now I have this error straight away:
10:58:10.124 ERROR: Error processing queue: The filename, directory name, or volume label syntax is incorrect
at Typewriter.LongPaths.FileWriter.WriteAllText(String path, String contents)
at Typewriter.Generation.Template.SaveFile(File file, String output, Boolean& success)
at Typewriter.Generation.Template.RenderFile(File file)
at Typewriter.Generation.Controllers.GenerationController.<>c__DisplayClass5_1.<OnTemplateChanged>b__1()
at Typewriter.Generation.Controllers.EventQueue.ProcessQueue()
I added small part which creates folder if it is missing - also it seems interop is not needed as System.IO is able to work with long paths when using that magic prefix - can you run test in solution "FileWriterTest" ? it should pass
The test does indeed run successfully.
I changed the path in the test to the actual failing one and then the test fails. I think it's because I use ..
in the path.
For instance, by replacing the path in test with
var path = @"C:\Dev\..\Dev\SomeInnerPath\Github\Project\src\innerpath\another-subpath\A.Very.Long.Project.Name.Like.Dotnet.People.Like\packages\some-random-scope\some-package-name\src\lib\events\a-very-very-very-very-very-very-very-very-very-very-very-very-very-very-long-file-name.ts";
Which is basically the same, then the test fails.
I think it can be fixed by calling GetFullPath
var path = @"C:\Dev\..\Dev\SomeInnerPath\Github\Project\src\innerpath\another-subpath\A.Very.Long.Project.Name.Like.Dotnet.People.Like\packages\some-random-scope\some-package-name\src\lib\events\a-very-very-very-very-very-very-very-very-very-very-very-very-very-very-long-file-name.ts";
path = System.IO.Path.GetFullPath(path);
Then the test is successful.
It seems to work flawlessly now. Thanks a lot for your reactivity !
Where trying to write a file with a path longer than 260 character, an error is thrown (the path has been changed but the length is the saame):
Even though
LongPathsEnabled
is true in the registry:Or via gpedit:
One thing I find odd is that it's not the System.IO.PathTooLongException that seems to be thrown but it's definitely related to the 260 char limitation.
I read things about the
Switch.System.IO.UseLegacyPathHandling
,Switch.System.IO.BlockLongPaths
or<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
in the application manifest but I don't think I have access to those or if they even apply to a VS extension...Maybe WriteFile could rely on something else than System.IO, like ZetaLongPaths or other workarounds ?
// OS: Windows 10/11 x64