Skip to content

Could not find a part of the path - AKA Path too long #1122

Open
@Ksdmg

Description

@Ksdmg

Describe the bug
When trying to generate a kiota API client it errors out with the exception:
Could not find a part of the path 'C:\Users\schaafa\AppData\Local\Temp\12ae2f0c-5aea-4dba-89ef-7113888cab4a\Item\ErpBORMAProcSvc\RMADtlsWithCompanyWithRMANumWithRMALine\RMARcptsWithCompanyWithRMANumWithRMALineWithRMAReceipt\RMARcptsWithCompanyWithRMANumWithRMALineWithRMAReceiptRequestBuilder.cs'.
I think this happens due to the length of the path. The file exists in the given location though.

Erp.BO.RMAProcSvc.json

Support Key: [my-support-key] Found in Tools -> Options -> REST API Client Code Generator - Analytics
d1af4e2

To Reproduce
Steps to reproduce the behavior:

  1. Set "Generate Multiple files" setting to False
  2. Generate Kiota client for file Erp.BO.RMAProcSvc.json
  3. Exception is thrown:
23/04/2025 11:19:31: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\schaafa\AppData\Local\Temp\cb440a33-e99c-4962-bbda-554b9e08c971\Item\ErpBORMAProcSvc\RMADtlsWithCompanyWithRMANumWithRMALine\RMADtlAttchesWithCompanyWithRMANumWithRMALineWithDrawingSeq\RMADtlAttchesWithCompanyWithRMANumWithRMALineWithDrawingSeqRequestBuilder.cs'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding)
   at System.IO.File.InternalReadAllLines(String path, Encoding encoding)
   at Rapicgen.Core.Generators.CSharpFileMerger.GetUniqueNamespaces(IEnumerable`1 files) in D:\a\apiclientcodegen\apiclientcodegen\src\Core\ApiClientCodeGen.Core\Generators\CSharpFileMerger.cs:line 153
   at Rapicgen.Core.Generators.CSharpFileMerger.MergeFiles(String folder) in D:\a\apiclientcodegen\apiclientcodegen\src\Core\ApiClientCodeGen.Core\Generators\CSharpFileMerger.cs:line 23
   at Rapicgen.Core.Generators.Kiota.KiotaCodeGenerator.GenerateCode(IProgressReporter pGenerateProgress) in D:\a\apiclientcodegen\apiclientcodegen\src\Core\ApiClientCodeGen.Core\Generators\Kiota\KiotaCodeGenerator.cs:line 74
   at Rapicgen.CustomTool.SingleFileCodeGenerator.Generate(String wszInputFilePath, String bstrInputFileContents, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, IVsGeneratorProgress pGenerateProgress)
23/04/2025 11:19:31: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\schaafa\AppData\Local\Temp\cb440a33-e99c-4962-bbda-554b9e08c971\Item\ErpBORMAProcSvc\RMADtlsWithCompanyWithRMANumWithRMALine\RMADtlAttchesWithCompanyWithRMANumWithRMALineWithDrawingSeq\RMADtlAttchesWithCompanyWithRMANumWithRMALineWithDrawingSeqRequestBuilder.cs'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding)
   at System.IO.File.InternalReadAllLines(String path, Encoding encoding)
   at Rapicgen.Core.Generators.CSharpFileMerger.GetUniqueNamespaces(IEnumerable`1 files) in D:\a\apiclientcodegen\apiclientcodegen\src\Core\ApiClientCodeGen.Core\Generators\CSharpFileMerger.cs:line 153
   at Rapicgen.Core.Generators.CSharpFileMerger.MergeFiles(String folder) in D:\a\apiclientcodegen\apiclientcodegen\src\Core\ApiClientCodeGen.Core\Generators\CSharpFileMerger.cs:line 23
   at Rapicgen.Core.Generators.Kiota.KiotaCodeGenerator.GenerateCode(IProgressReporter pGenerateProgress) in D:\a\apiclientcodegen\apiclientcodegen\src\Core\ApiClientCodeGen.Core\Generators\Kiota\KiotaCodeGenerator.cs:line 74
   at Rapicgen.CustomTool.SingleFileCodeGenerator.Generate(String wszInputFilePath, String bstrInputFileContents, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, IVsGeneratorProgress pGenerateProgress)
23/04/2025 11:19:31: Unable to generate code

Expected behavior
Get an output that compiles.

Visual Studio Extension (please complete the following information):

  • Visual Studio Version: 2022
  • Extension Version [e.g. 1.2.6222]

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions