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

System.UnauthorizedAccessException #154

Closed
MrWolfPST opened this issue Mar 13, 2024 · 6 comments
Closed

System.UnauthorizedAccessException #154

MrWolfPST opened this issue Mar 13, 2024 · 6 comments

Comments

@MrWolfPST
Copy link

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
Copy link
Owner

Doraku commented Mar 20, 2024

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
Copy link
Author

MrWolfPST commented Mar 21, 2024 via email

@Doraku
Copy link
Owner

Doraku commented Oct 23, 2024

Pretty late reply but any reason you are calling the dotnet tool yourself instead of using the msbuild task package? wondering if you have the same issue with it.

@MrWolfPST
Copy link
Author

Hi
I don't know difference, in another project I used successfully the same syntax to run swagger tofile for generate local yaml version of swagger.json and and I thought that it work with all dotnet tools.

@Doraku
Copy link
Owner

Doraku commented Oct 25, 2024

It shouldn't but who knows with windows... I'll try to see if I can replicate your error when I'm back from the week end 🤔 for now I've only tested by:

  • using the msbuild task
  • calling directly the console exe outside of dotnet (so not like you)

@Doraku
Copy link
Owner

Doraku commented Nov 1, 2024

ok I think I got it, you are using the wrong command line argument for $(SolutionDir)Wiki, -d is for the xml documentation file generated by the compilation, not the output folder where you want your markdown documentation, you should use -o for that, I'll add a clearer error >_> sorry it took so long for me to look at it.

@Doraku Doraku closed this as completed in 361844c Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants