Skip to content

Commit 24648a7

Browse files
committed
Add escape hatch MSBUILDCOPYWITHOUTDELETE
This allows an opt-in workaround for dotnet#9250 that affected deployment processes can use, mitigating the risk of entirely reverting dotnet#8685.
1 parent 3847162 commit 24648a7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Framework/Traits.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ internal class EscapeHatches
188188
/// </summary>
189189
public readonly bool AlwaysDoImmutableFilesUpToDateCheck = Environment.GetEnvironmentVariable("MSBUILDDONOTCACHEMODIFICATIONTIME") == "1";
190190

191+
/// <summary>
192+
/// When copying over an existing file, copy directly into the existing file rather than deleting and recreating.
193+
/// </summary>
194+
public readonly bool CopyWithoutDelete = Environment.GetEnvironmentVariable("MSBUILDCOPYWITHOUTDELETE") == "1";
195+
191196
/// <summary>
192197
/// Emit events for project imports.
193198
/// </summary>

src/Tasks/Copy.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ private void LogAlwaysRetryDiagnosticFromResources(string messageResourceName, p
285285
MakeFileWriteable(destinationFileState, true);
286286
}
287287

288-
if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8) && destinationFileState.FileExists && !destinationFileState.IsReadOnly)
288+
if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8) &&
289+
Traits.Instance.EscapeHatches.CopyWithoutDelete != true &&
290+
destinationFileState.FileExists &&
291+
!destinationFileState.IsReadOnly)
289292
{
290293
FileUtilities.DeleteNoThrow(destinationFileState.Name);
291294
}

0 commit comments

Comments
 (0)