Skip to content

Commit

Permalink
Add escape hatch MSBUILDCOPYWITHOUTDELETE (#9257)
Browse files Browse the repository at this point in the history
This allows an opt-in workaround for #9250 that affected deployment
processes can use, mitigating the risk of entirely reverting #8685.
  • Loading branch information
rainersigwald authored Sep 22, 2023
1 parent 87eb917 commit 6cdef42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Framework/Traits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ internal class EscapeHatches
/// </summary>
public readonly bool AlwaysDoImmutableFilesUpToDateCheck = Environment.GetEnvironmentVariable("MSBUILDDONOTCACHEMODIFICATIONTIME") == "1";

/// <summary>
/// When copying over an existing file, copy directly into the existing file rather than deleting and recreating.
/// </summary>
public readonly bool CopyWithoutDelete = Environment.GetEnvironmentVariable("MSBUILDCOPYWITHOUTDELETE") == "1";

/// <summary>
/// Emit events for project imports.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Tasks/Copy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ private void LogAlwaysRetryDiagnosticFromResources(string messageResourceName, p
MakeFileWriteable(destinationFileState, true);
}

if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8) && destinationFileState.FileExists && !destinationFileState.IsReadOnly)
if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8) &&
Traits.Instance.EscapeHatches.CopyWithoutDelete != true &&
destinationFileState.FileExists &&
!destinationFileState.IsReadOnly)
{
FileUtilities.DeleteNoThrow(destinationFileState.Name);
}
Expand Down

0 comments on commit 6cdef42

Please sign in to comment.