Doraku / DefaultDocumentation

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

System.UnauthorizedAccessException #154

Open MrWolfPST opened 5 months ago

MrWolfPST commented 5 months ago

I added this target to my proj file

<Target Name="Documentation" AfterTargets="Build" Condition="$(Configuration)=='Debug'">
    <Exec Command="defaultdocumentation -a $(ProjectDir)$(OutputPath)$(AssemblyName).dll -d $(SolutionDir)Wiki" />
</Target>

When task is run throws an System.UnauthorizedAccessException.

I don't run VS as administrator, but obsully my windows user have full access to solution folder. I use default configurations, no one defaultdocumentation.json is present in my project. At time not all project members is documented.

output logs:

2024-03-13 17:39:35.5730|INFO|DefaultDocumentation|Starting DefaultDocumentation with this configuration:
{
  "AssemblyFilePath": "XXX.dll",
  "DocumentationFilePath": "XXX\\Wiki",
  "FileNameFactory": "FullName",
  "UrlFactories": [
    "DocItem",
    "DotnetApi"
  ],
  "Sections": [
    "Header",
    "Default"
  ]
}
2024-03-13 17:39:35.5878|INFO|DefaultDocumentation|Starting DefaultDocumentation with those settings:
  AssemblyFile: XXX.dll
  DocumentationFile: XXX\Wiki
  ProjectDirectory:
  OutputDirectory: XXX
  AssemblyPageName:
  GeneratedAccessModifiers: Public, Private, Protected, Internal, ProtectedInternal, PrivateProtected
  GeneratedPages: Namespaces, Types, Members
  IncludeUndocumentedItems: False
  LinksOutputFile:
  LinksBaseUrl:
  ExternLinksFiles:
Unhandled exception. System.UnauthorizedAccessException: Access to the path 'XXX\Wiki' is denied.
   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.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider..ctor(String fileName) in /_/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs:line 137
   at DefaultDocumentation.Internal.DocItemReader..ctor(Settings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 48
   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.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
XXX.csproj(44,3): error MSB3073: The command "defaultdocumentation -a XXX.dll -d XXX\Wiki" exited with code -532462766.
Done building project "XXX.csproj" -- FAILED.
Doraku commented 5 months ago

Definitely looks like windows is complaining with the target directory. Does it actually exist (normally it should create it for you automatically...)? Do you get the same error when launching VS as admin just to see if it helps?

MrWolfPST commented 5 months ago

Hi Target directory exists, I created it manually, when it didn't exist a not found exception was throw, I suppose that creation fails for same rights reason but be ignored. I'm tried lounching VS as administrator and I have same issue, both with or without existent folder. If it ca be usefuss, in the same project I added after build call to swagger dotnet tool for generate a swagger yaml file, and it work successfully also in non administrative mode. This confirm that VS process have rights to write to solution folder.

Regards F


Da: Paillat Laszlo @.> Inviato: mercoledì 20 marzo 2024 23:59 A: Doraku/DefaultDocumentation @.> Cc: MrWolfPST @.>; Author @.> Oggetto: Re: [Doraku/DefaultDocumentation] System.UnauthorizedAccessException (Issue #154)

Definitely looks like windows is complaining with the target directory. Does it actually exist (normally it should create it for you automatically...)? Do you get the same error when launching VS as admin just to see if it helps?

— Reply to this email directly, view it on GitHubhttps://github.com/Doraku/DefaultDocumentation/issues/154#issuecomment-2010842960, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABEJ3P3AEF5IMEUHXWJOXB3YZIIE7AVCNFSM6AAAAABEURX5OSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJQHA2DEOJWGA. You are receiving this because you authored the thread.Message ID: @.***>