diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs b/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs index 20f6c71..04bbdb6 100644 --- a/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs @@ -102,9 +102,16 @@ public override bool Execute() string sourceDocumentation = Path.ChangeExtension(unannotatedReferenceAssembly, ".xml"); string targetDocumentation = Path.ChangeExtension(outputAssembly, ".xml"); - if (File.Exists(sourceDocumentation)) + if (File.Exists(sourceDocumentation) && !File.Exists(targetDocumentation)) { - File.Copy(sourceDocumentation, targetDocumentation); + try + { + File.Copy(sourceDocumentation, targetDocumentation); + } + catch (IOException ex) when ((WindowsErrorCode)ex.HResult == WindowsErrorCode.FileExists) + { + } + GeneratedDocumentationFiles = new[] { new TaskItem(targetDocumentation) }; } else diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/WindowsErrorCode.cs b/TunnelVisionLabs.ReferenceAssemblyAnnotator/WindowsErrorCode.cs new file mode 100644 index 0000000..64e8d7d --- /dev/null +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/WindowsErrorCode.cs @@ -0,0 +1,13 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace TunnelVisionLabs.ReferenceAssemblyAnnotator +{ + internal enum WindowsErrorCode : ushort + { + /// + /// https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-#error_file_exists + /// + FileExists = 80, + } +}