Skip to content

Commit 26a4fc6

Browse files
Merge pull request #9272 from dotnet-maestro-bot/merge/vs17.8-to-main
[automated] Merge branch 'vs17.8' => 'main'
2 parents fecef0f + 9951075 commit 26a4fc6

File tree

7 files changed

+41
-19
lines changed

7 files changed

+41
-19
lines changed

documentation/wiki/ChangeWaves.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t
2626
### 17.8
2727
- [[RAR] Don't do I/O on SDK-provided references](https://github.com/dotnet/msbuild/pull/8688)
2828
- [Delete destination file before copy](https://github.com/dotnet/msbuild/pull/8685)
29-
- [New serialization approach for transferring build exceptions between processes](https://github.com/dotnet/msbuild/pull/8779)
3029
- [Moving from SHA1 to SHA256 for Hash task](https://github.com/dotnet/msbuild/pull/8812)
30+
- [Deprecating custom derived BuildEventArgs](https://github.com/dotnet/msbuild/pull/8917) - feature can be opted out only if [BinaryFormatter](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.formatters.binary.binaryformatter) is allowed at runtime by editing `MSBuild.runtimeconfig.json`
31+
3132

3233
### 17.6
3334
- [Parse invalid property under target](https://github.com/dotnet/msbuild/pull/8190)
@@ -68,4 +69,4 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t
6869
- [Optimized immutable files up to date checks](https://github.com/dotnet/msbuild/pull/6974)
6970
- [Add Microsoft.IO.Redist for directory enumeration](https://github.com/dotnet/msbuild/pull/6771)
7071
- [Process-wide caching of ToolsetConfigurationSection](https://github.com/dotnet/msbuild/pull/6832)
71-
- [Normalize RAR output paths](https://github.com/dotnet/msbuild/pull/6533)
72+
- [Normalize RAR output paths](https://github.com/dotnet/msbuild/pull/6533)

src/Build/BackEnd/Node/OutOfProcNode.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,8 @@ private void SendPacket(INodePacket packet)
587587
#if RUNTIME_TYPE_NETCORE
588588
if (packet is LogMessagePacketBase logMessage
589589
&& logMessage.EventType == LoggingEventType.CustomEvent
590-
&& ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8)
590+
&&
591+
(ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8) || !Traits.Instance.EscapeHatches.IsBinaryFormatterSerializationAllowed)
591592
&& Traits.Instance.EscapeHatches.EnableWarningOnCustomBuildEvent)
592593
{
593594
BuildEventArgs buildEvent = logMessage.NodeBuildEvent.Value.Value;

src/Build/Instance/TaskFactories/TaskHostTask.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
@@ -436,7 +436,7 @@ private void HandlePacket(INodePacket packet, out bool taskFinished)
436436
private void HandleTaskHostTaskComplete(TaskHostTaskComplete taskHostTaskComplete)
437437
{
438438
#if FEATURE_REPORTFILEACCESSES
439-
if (taskHostTaskComplete.FileAccessData.Count > 0)
439+
if (taskHostTaskComplete.FileAccessData?.Count > 0)
440440
{
441441
IFileAccessManager fileAccessManager = ((IFileAccessManager)_buildComponentHost.GetComponent(BuildComponentType.FileAccessManager));
442442
foreach (FileAccessData fileAccessData in taskHostTaskComplete.FileAccessData)

src/Framework/BinaryTranslator.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,6 @@ public void TranslateDotNet<T>(ref T value)
582582

583583
public void TranslateException(ref Exception value)
584584
{
585-
if (!ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8))
586-
{
587-
TranslateDotNet<Exception>(ref value);
588-
return;
589-
}
590-
591585
if (!TranslateNullable(value))
592586
{
593587
return;
@@ -1291,12 +1285,6 @@ public void TranslateDotNet<T>(ref T value)
12911285

12921286
public void TranslateException(ref Exception value)
12931287
{
1294-
if (!ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8))
1295-
{
1296-
TranslateDotNet<Exception>(ref value);
1297-
return;
1298-
}
1299-
13001288
if (!TranslateNullable(value))
13011289
{
13021290
return;

src/Framework/Traits.cs

Lines changed: 26 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>
@@ -395,6 +400,27 @@ public bool EnableWarningOnCustomBuildEvent
395400
}
396401
}
397402

403+
private bool? _isBinaryFormatterSerializationAllowed;
404+
public bool IsBinaryFormatterSerializationAllowed
405+
{
406+
get
407+
{
408+
if (!_isBinaryFormatterSerializationAllowed.HasValue)
409+
{
410+
#if RUNTIME_TYPE_NETCORE
411+
AppContext.TryGetSwitch("System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization",
412+
out bool enabled);
413+
_isBinaryFormatterSerializationAllowed = enabled;
414+
#else
415+
_isBinaryFormatterSerializationAllowed = true;
416+
#endif
417+
}
418+
419+
return _isBinaryFormatterSerializationAllowed.Value;
420+
}
421+
}
422+
423+
398424
private static bool? ParseNullableBoolFromEnvironmentVariable(string environmentVariable)
399425
{
400426
var value = Environment.GetEnvironmentVariable(environmentVariable);

src/Shared/TaskHostTaskComplete.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
@@ -245,6 +245,9 @@ public void Translate(ITranslator translator)
245245
translator.TranslateDictionary(ref _buildProcessEnvironment, StringComparer.OrdinalIgnoreCase);
246246
#if FEATURE_REPORTFILEACCESSES
247247
translator.Translate(ref _fileAccessData);
248+
#else
249+
bool hasFileAccessData = false;
250+
translator.Translate(ref hasFileAccessData);
248251
#endif
249252
}
250253

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)