tunnelvisionlabs / ReferenceAssemblyAnnotator

IL weaver to add nullability annotations to .NET reference assemblies
MIT License
71 stars 8 forks source link

The AnnotatorBuildTask task failed unexpectedly #40

Open JohanLarsson opened 5 years ago

JohanLarsson commented 5 years ago
Severity    Code    Description Project File    Line    Suppression State
Error   MSB4018 The "AnnotatorBuildTask" task failed unexpectedly.
System.IO.IOException: The process cannot access the file 'C:\Git\_GuOrg\Gu.Wpf.UiAutomation\Gu.Wpf.UiAutomation\obj\Debug\net45\annotated\mscorlib.dll' because it is being used by another process.
   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)
   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
   at TunnelVisionLabs.ReferenceAssemblyAnnotator.Program.Main(Nullable`1 log, String referenceAssembly, String annotatedReferenceAssembly, String outputAssembly)
   at TunnelVisionLabs.ReferenceAssemblyAnnotator.AnnotatorBuildTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Gu.Wpf.UiAutomation C:\Users\ds2346\.nuget\packages\tunnelvisionlabs.referenceassemblyannotator\1.0.0-alpha.77\build\TunnelVisionLabs.ReferenceAssemblyAnnotator.targets    60  

From the name I'm guessing it can be something in this nice package. Repro in this commit https://github.com/GuOrg/Gu.Wpf.UiAutomation/tree/a5b789bf37742a9edd098d187d8a8362a80e43a8

I think I have only seen it after git clean and start Visual Studio

jnm2 commented 5 years ago

I see this about once a day.

jnm2 commented 5 years ago

@sharwell Should the annotator bail and assume that the only other process that will be causing this is another build of the same project, and that the file being written is what the annotator would have written anyway?

Or should it retry?

jnm2 commented 5 years ago

This started happening repeatedly until I restarted VS.

JohanLarsson commented 4 years ago

Got this with 1.0.0-alpha.138. Repro: https://github.com/GuOrg/Gu.Wpf.ToolTips

Severity    Code    Description Project File    Line    Suppression State
Error   MSB4018 The "AnnotatorBuildTask" task failed unexpectedly.
System.IO.IOException: The file 'obj\Debug\netcoreapp3.1\annotated\Microsoft.CSharp.xml' already exists.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at System.IO.File.Copy(String sourceFileName, String destFileName)
   at TunnelVisionLabs.ReferenceAssemblyAnnotator.AnnotatorBuildTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Gu.Wpf.ToolTips C:\Users\ds2346\.nuget\packages\tunnelvisionlabs.referenceassemblyannotator\1.0.0-alpha.138\build\TunnelVisionLabs.ReferenceAssemblyAnnotator.targets   89  
sharwell commented 4 years ago

This is going to be possible in parallel build scenarios until file-system locking is used.

jnm2 commented 4 years ago

I was going to say, I don't think it's project-specific. It crops up and requires a VS restart maybe once a day for me no matter what the project is.