Doraku / DefaultDocumentation

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

Frequent "file being used by another process IOException" when building documentation #52

Closed etaxi341 closed 3 years ago

etaxi341 commented 3 years ago

Hello, I am actually still getting the same Error as in #39 I am on the newest Version.

This is my Errorlog

Schweregrad Code    Beschreibung    Projekt Datei   Zeile   Unterdrückungszustand
Fehler  MSB4018 Unerwarteter Fehler bei der DefaultDocumentationTask-Aufgabe.
System.Exception: Error while writing documentation for Helper.Web.RestHelper ---> System.IO.IOException: Der Prozess kann nicht auf die Datei "C:\Work\ProjectFolder\Project\Helper\Docs\Helper_Web_RestHelper.md" zugreifen, da sie von einem anderen Prozess verwendet wird.
   bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   bei 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)
   bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   bei System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   bei System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   bei System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
   bei System.IO.File.WriteAllText(String path, String contents)
   bei DefaultDocumentation.Writer.MarkdownWriter.WritePage(DirectoryInfo directory, DocItem item) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\MarkdownWriter.cs:Zeile 621.
   bei DefaultDocumentation.Writer.DocItemWriter.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\DocItemWriter.cs:Zeile 121.
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei DefaultDocumentation.Writer.DocItemWriter.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\DocItemWriter.cs:Zeile 125.
   bei DefaultDocumentation.DefaultDocumentationTask.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation\DefaultDocumentationTask.cs:Zeile 42.
   bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   bei Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()    Helper  C:\Users\xxx\.nuget\packages\defaultdocumentation\0.7.3\build\DefaultDocumentation.targets  38  

Somehow this only happens when building the whole solution! Building each project by its own works. Could you maybe check if such an error occurs and allow us to just ignore it? Or maybe you can find way to resolve the issue completely.

Thanks for all the hard work on this amazing project!

Doraku commented 3 years ago

grrr this again, I am starting to wonder if it is not visual studio git module (if you are using it) which is locking the files randomly to check for modification from time to time. does it also happen when you try to build your sln with dotnet command and your IDE closed? I'll try to create file in a temp folder and copy them once done to see if it works better.

etaxi341 commented 3 years ago

Tested it. Same error with "dotnet build"

My current solution is to try it a few times. This only fails like 3/4 times. So sometimes it works in Visual Studio and in "dotnet build"

etaxi341 commented 3 years ago

And yes I am using the VS Git module. But then "dotnet build" should work i think, right?

Doraku commented 3 years ago

An other possibility is that since File.Delete can return BEFORE the file is actually deleted, maybe the process try to recreate the file too soon. I will put some safeguard. That or the os search indexer or some antivirus is keeping the file open with a shared delete. Anyway a simple check should fix this problem for good :|

Doraku commented 3 years ago

Can you try the version 0.7.4-beta1 if it helps :)?

etaxi341 commented 3 years ago

Wow, I think it works! Took my time and built the project 20 times. Never failed. Looks like you fixed it :) Thank you very much!