Doraku / DefaultDocumentation

Create a simple markdown documentation from the Visual Studio xml one.
MIT No Attribution
157 stars 26 forks source link

System.IO.IOException #156

Closed anektar closed 5 months ago

anektar commented 5 months ago

Hello,

we've been trying out your very helpful tool. When working from the .csproj all work fine while building from VStudio. When the same runs from a CI we get this error:

System.IO.IOException: The process cannot access the file 'C:\InnoBuildAgent\_work\5\s\docs\wiki\Qualco.Platform.Configuration.Links.txt' because it is being used by another process.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.FileInfo.OpenText()
   at DefaultDocumentation.Internal.DocItemReader..ctor(Settings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 213
   at DefaultDocumentation.Internal.DocItemReader.GetItems(Settings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 354
   at DefaultDocumentation.Generator..ctor(Target loggerTarget, IRawSettings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 116
   at DefaultDocumentation.Generator.Execute(Target loggerTarget, IRawSettings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 195
   at DefaultDocumentation.DefaultDocumentationTask.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation\DefaultDocumentationTask.cs:line 57
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

I have tried running from the CLI tool for a single dll:

C:\QCS Projects\QualcoPlatformNew>defaultDocumentation -a Qualco.Platform.DataTransfer\src\Qualco.Platform.DataTransfer\bin\Debug\netstandard2.0\Qualco.Platform.DataTransfer.dll
2024-03-20 12:54:41.2693|INFO|DefaultDocumentation|Starting DefaultDocumentation with this configuration:
{
  "AssemblyFilePath": "Qualco.Platform.DataTransfer\\src\\Qualco.Platform.DataTransfer\\bin\\Debug\\netstandard2.0\\Qualco.Platform.DataTransfer.dll",
  "FileNameFactory": "FullName",
  "UrlFactories": [
    "DocItem",
    "DotnetApi"
  ],
  "Sections": [
    "Header",
    "Default"
  ]
}
2024-03-20 12:54:41.2898|INFO|DefaultDocumentation|Starting DefaultDocumentation with those settings:
  AssemblyFile: C:\QCS Projects\QualcoPlatformNew\Qualco.Platform.DataTransfer\src\Qualco.Platform.DataTransfer\bin\Debug\netstandard2.0\Qualco.Platform.DataTransfer.dll
  DocumentationFile: C:\QCS Projects\QualcoPlatformNew\Qualco.Platform.DataTransfer\src\Qualco.Platform.DataTransfer\bin\Debug\netstandard2.0\Qualco.Platform.DataTransfer.xml
  ProjectDirectory:
  OutputDirectory: C:\QCS Projects\QualcoPlatformNew\Qualco.Platform.DataTransfer\src\Qualco.Platform.DataTransfer\bin\Debug\netstandard2.0
  AssemblyPageName:
  GeneratedAccessModifiers: Public, Private, Protected, Internal, ProtectedInternal, PrivateProtected
  GeneratedPages: Namespaces, Types, Members
  IncludeUndocumentedItems: False
  LinksOutputFile:
  LinksBaseUrl:
  ExternLinksFiles:
2024-03-20 12:54:41.6892|INFO|DefaultDocumentation|Elements that will be used:
  c: DefaultDocumentation.Markdown.Elements.CElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  code: DefaultDocumentation.Markdown.Elements.CodeElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  list: DefaultDocumentation.Markdown.Elements.ListElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  note: DefaultDocumentation.Markdown.Elements.NoteElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  para: DefaultDocumentation.Markdown.Elements.ParaElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  paramref: DefaultDocumentation.Markdown.Elements.ParamRefElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  see: DefaultDocumentation.Markdown.Elements.SeeElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  typeparamref: DefaultDocumentation.Markdown.Elements.TypeParamRefElement, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
2024-03-20 12:54:41.6892|INFO|DefaultDocumentation|FileNameFactory that will be used: DefaultDocumentation.Markdown.FileNameFactories.FullNameFactory, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
2024-03-20 12:54:41.6892|INFO|DefaultDocumentation|UrlFactories that will be used:
  DefaultDocumentation.Markdown.UrlFactories.DocItemFactory, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  DefaultDocumentation.Markdown.UrlFactories.DotnetApiFactory, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
2024-03-20 12:54:41.6892|INFO|DefaultDocumentation|Sections that will be used:
  DefaultDocumentation.Markdown.Sections.HeaderSection, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
  DefaultDocumentation.Markdown.Sections.DefaultSection, DefaultDocumentation.Markdown, Version=0.8.0.0, Culture=neutral, PublicKeyToken=0ab8f459261ccb3c
Unhandled exception. System.Exception: Error while writing documentation for Qualco.Platform.DataTransfer.DataObjectCollectionAnnotation.DataObjectCollectionAnnotation(Qualco.Platform.DataTransfer.DataPackageAnnotation, Qualco.Platform.DataTransfer.Descriptors.DataObjectCollectionDescriptor, Newtonsoft.Json.Linq.JArray, System.Nullable<Qualco.Platform.DataTransfer.DataObjectState>)
 ---> System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. : 'C:\QCS Projects\QualcoPlatformNew\Qualco.Platform.DataTransfer\src\Qualco.Platform.DataTransfer\bin\Debug\netstandard2.0\Qualco.Platform.DataTransfer.DataObjectCollectionAnnotation.DataObjectCollectionAnnotation(Qualco.Platform.DataTransfer.DataPackageAnnotation,Qualco.Platform.DataTransfer.Descriptors.DataObjectCollectionDescriptor,Newtonsoft.Json.Linq.JArray,System.Nullable_Qualco.Platform.DataTransfer.DataObjectState_).md'
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   at System.IO.File.WriteAllText(String path, String contents)
   at DefaultDocumentation.Generator.WritePage(DocItem item, StringBuilder builder) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 141
   at DefaultDocumentation.Generator.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 181
   --- End of inner exception stack trace ---
   at DefaultDocumentation.Generator.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 185
   at DefaultDocumentation.Generator.Execute(Target loggerTarget, IRawSettings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 207
   at DefaultDocumentation.Program.<>c.<Main>b__0_1(SettingsArgs a) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 24
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at DefaultDocumentation.Program.Main(String[] args) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 18

Any thoughts/help on this?

Doraku commented 5 months ago

looking at the file name it's probably a length issue of the path but it's weird that it works from VStudio O_o, you should try to change the FileNameFactory and see if it works with one that produce shorter name.

anektar commented 5 months ago

Good morning, thanks for the quick response!

Regarding my second issue I used your configuration json and after setting all needed, including FileNameFactory, the documentation CLI worked.

Regarding my first issue, I was too very puzzled why it would work with no issue from V Studio during build but not from CI. Turns out in our CI the build task built every project with a wildcard. This might have resulted in building projects with dependencies in not the right order. So instead I changed the ci to build the actual .sln the same that's being built from the Visual Studio. And the problem is gone. Nothing to do with your library. :)

Thanks a lot for your input!