Skip to content

Commit

Permalink
Merge pull request #75 from jnm2/documentation_file_already_exists
Browse files Browse the repository at this point in the history
Skip copying documentation file when target already exists
  • Loading branch information
sharwell authored Jan 3, 2020
2 parents 7c75c5d + 890b117 commit 52022df
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,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
Expand Down
13 changes: 13 additions & 0 deletions TunnelVisionLabs.ReferenceAssemblyAnnotator/WindowsErrorCode.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-#error_file_exists
/// </summary>
FileExists = 80,
}
}

0 comments on commit 52022df

Please sign in to comment.