From f17f607555308eaf0b241d59098f68c7b8e46a6d Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 10 Feb 2021 15:53:47 -0800
Subject: [PATCH 01/57] change library target frameworks to net6.0
---
src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj | 2 +-
src/Directory.Build.props | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
index 95001217b5d..3cdb4a0546e 100644
--- a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
+++ b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
@@ -36,7 +36,7 @@
TargetFramework=$(FullFrameworkTFM)
TargetFramework=$(FullFrameworkTFM)
- TargetFramework=netstandard2.0
+ TargetFramework=net5.0
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index a96fe427c62..2a5fbe50890 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -27,8 +27,8 @@
AnyCPU;x64
- $(FullFrameworkTFM);netstandard2.0
- netstandard2.0
+ $(FullFrameworkTFM);net6.0
+ net6.0
$(FullFrameworkTFM)
AnyCPU
From b1ac2ab32de293825638d7aeccf062393e2a7ba6 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 16 Feb 2021 17:50:30 -0800
Subject: [PATCH 02/57] CustomHttpRequestException obsolete in net6.0, use
SupportedOSPlatform for net6.0
---
src/Tasks/DownloadFile.cs | 34 ++++++++++++++++++++-----
src/Tasks/ManifestUtil/SecurityUtil.cs | 35 +++++++++++++++++++++-----
src/Tasks/ManifestUtil/mansign2.cs | 29 ++++++++++++++++++++-
3 files changed, 85 insertions(+), 13 deletions(-)
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index c55eedb3974..ef4194d663c 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -150,7 +150,11 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
{
// HttpRequestException does not have the status code so its wrapped and thrown here so that later on we can determine
// if a retry is possible based on the status code
+#if RUNTIME_TYPE_NETCORE
+ throw new HttpRequestException(e.Message, e.InnerException, response.StatusCode);
+#else
throw new CustomHttpRequestException(e.Message, e.InnerException, response.StatusCode);
+#endif
}
if (!TryGetFileName(response, out string filename))
@@ -220,17 +224,30 @@ private static bool IsRetriable(Exception exception, out Exception actualExcepti
}
// Some HttpRequestException have an inner exception that has the real error
- if (actualException is HttpRequestException httpRequestException && httpRequestException.InnerException != null)
+ if (actualException is HttpRequestException httpRequestException)
{
- actualException = httpRequestException.InnerException;
+ if (httpRequestException.InnerException != null)
+ {
+ actualException = httpRequestException.InnerException;
+
+ // An IOException inside of a HttpRequestException means that something went wrong while downloading
+ if (actualException is IOException)
+ {
+ return true;
+ }
+ }
- // An IOException inside of a HttpRequestException means that something went wrong while downloading
- if (actualException is IOException)
+#if RUNTIME_TYPE_NETCORE
+ switch (httpRequestException.StatusCode)
{
- return true;
+ case HttpStatusCode.InternalServerError:
+ case HttpStatusCode.RequestTimeout:
+ return true;
}
+#endif
}
+#if !RUNTIME_TYPE_NETCORE
if (actualException is CustomHttpRequestException customHttpRequestException)
{
// A wrapped CustomHttpRequestException has the status code from the error
@@ -241,6 +258,7 @@ private static bool IsRetriable(Exception exception, out Exception actualExcepti
return true;
}
}
+#endif
if (actualException is WebException webException)
{
@@ -287,6 +305,7 @@ private bool TryGetFileName(HttpResponseMessage response, out string filename)
return !String.IsNullOrWhiteSpace(filename);
}
+#if !RUNTIME_TYPE_NETCORE
///
/// Represents a wrapper around the that also contains the .
///
@@ -299,9 +318,12 @@ public CustomHttpRequestException(string message, Exception inner, HttpStatusCod
}
public HttpStatusCode StatusCode { get; }
+
+
}
+#endif
- private bool ShouldSkip(HttpResponseMessage response, FileInfo destinationFile)
+private bool ShouldSkip(HttpResponseMessage response, FileInfo destinationFile)
{
return SkipUnchangedFiles
&& destinationFile.Exists
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index de1caa01567..e9b827bb1a7 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -1,28 +1,33 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Win32;
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Deployment.Internal.CodeSigning;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
-using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
-using System.Security.Permissions;
-using System.Security.Policy;
using System.Text;
using System.Xml;
using Microsoft.Build.Shared.FileSystem;
+
+#if RUNTIME_TYPE_NETCORE
+using System.Runtime.Versioning;
+#else
+using Microsoft.Build.Framework;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
+using System.Security.Permissions;
+using System.Security.Policy;
using FrameworkNameVersioning = System.Runtime.Versioning.FrameworkName;
+#endif
#nullable disable
@@ -483,6 +488,9 @@ public static PermissionSet XmlToPermissionSet(XmlElement element)
/// Hexadecimal string that contains the SHA-1 hash of the certificate.
/// URL that specifies an address of a time stamping server.
/// Path of the file to sign with the certificate.
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public static void SignFile(string certThumbprint, Uri timestampUrl, string path)
{
SignFile(certThumbprint, timestampUrl, path, null, null);
@@ -495,6 +503,9 @@ public static void SignFile(string certThumbprint, Uri timestampUrl, string path
/// URL that specifies an address of a time stamping server.
/// Path of the file to sign with the certificate.
/// Version of the .NET Framework for the target.
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public static void SignFile(string certThumbprint,
Uri timestampUrl,
string path,
@@ -511,6 +522,9 @@ public static void SignFile(string certThumbprint,
/// Path of the file to sign with the certificate.
/// Version of the .NET Framework for the target.
/// .NET Framework identifier for the target.
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public static void SignFile(string certThumbprint,
Uri timestampUrl,
string path,
@@ -568,6 +582,9 @@ public static void SignFile(string certThumbprint,
/// URL that specifies an address of a time stamping server.
/// Path of the file to sign with the certificate.
/// This function is only for signing a manifest, not a PE file.
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public static void SignFile(string certPath, SecureString certPassword, Uri timestampUrl, string path)
{
X509Certificate2 cert = new X509Certificate2(certPath, certPassword, X509KeyStorageFlags.PersistKeySet);
@@ -592,6 +609,9 @@ private static bool UseSha256Algorithm(X509Certificate2 cert)
/// Path of the file to sign with the certificate.
/// This function can only sign a PE file if the X509Certificate2 parameter represents a certificate in the
/// current user's personal certificate store.
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public static void SignFile(X509Certificate2 cert, Uri timestampUrl, string path)
{
// setup resources
@@ -599,6 +619,9 @@ public static void SignFile(X509Certificate2 cert, Uri timestampUrl, string path
SignFileInternal(cert, timestampUrl, path, true, resources);
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
private static void SignFileInternal(X509Certificate2 cert, Uri timestampUrl, string path, bool targetFrameworkSupportsSha256, System.Resources.ResourceManager resources)
{
if (cert == null)
diff --git a/src/Tasks/ManifestUtil/mansign2.cs b/src/Tasks/ManifestUtil/mansign2.cs
index 191add569e4..de9f546f472 100644
--- a/src/Tasks/ManifestUtil/mansign2.cs
+++ b/src/Tasks/ManifestUtil/mansign2.cs
@@ -13,6 +13,10 @@
using System.Xml;
using System.Runtime.InteropServices;
+#if RUNTIME_TYPE_NETCORE
+using System.Runtime.Versioning;
+#endif
+
using _FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
#nullable disable
@@ -330,12 +334,17 @@ internal SignedCmiManifest2(XmlDocument manifestDom, bool useSha256)
_manifestDom = manifestDom ?? throw new ArgumentNullException(nameof(manifestDom));
_useSha256 = useSha256;
}
-
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
internal void Sign(CmiManifestSigner2 signer)
{
Sign(signer, null);
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
internal void Sign(CmiManifestSigner2 signer, string timeStampUrl)
{
// Reset signer infos.
@@ -468,6 +477,9 @@ private static void RemoveExistingSignature(XmlDocument manifestDom)
/// Whether to use sha256
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Cryptographic.Standard", "CA5358:RSAProviderNeeds2048bitKey", Justification = "SHA1 is retained for compatibility reasons as an option in VisualStudio signing page and consequently in the trust manager, default is SHA2.")]
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
internal static RSACryptoServiceProvider GetFixedRSACryptoServiceProvider(RSACryptoServiceProvider oldCsp, bool useSha256)
{
if (!useSha256)
@@ -496,6 +508,9 @@ internal static RSACryptoServiceProvider GetFixedRSACryptoServiceProvider(RSACry
return fixedRsa;
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
private static void ReplacePublicKeyToken(XmlDocument manifestDom, AsymmetricAlgorithm snKey, bool useSha256)
{
// Make sure we can find the publicKeyToken attribute.
@@ -692,6 +707,9 @@ private static XmlDocument CreateLicenseDom(CmiManifestSigner2 signer, XmlElemen
return licenseDom;
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
private static void AuthenticodeSignLicenseDom(XmlDocument licenseDom, CmiManifestSigner2 signer, string timeStampUrl, bool useSha256)
{
// Make sure it is RSA, as this is the only one Fusion will support.
@@ -903,6 +921,9 @@ private static void TimestampSignedLicenseDom(XmlDocument licenseDom, string tim
signatureNode.AppendChild(dsObject);
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
private static void StrongNameSignManifestDom(XmlDocument manifestDom, XmlDocument licenseDom, CmiManifestSigner2 signer, bool useSha256)
{
RSA snKey = signer.StrongNameKey as RSA;
@@ -1232,6 +1253,9 @@ internal CmiAuthenticodeSignerInfo(int errorCode)
_error = errorCode;
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
internal CmiAuthenticodeSignerInfo(Win32.AXL_SIGNER_INFO signerInfo,
Win32.AXL_TIMESTAMPER_INFO timestamperInfo)
{
@@ -1350,6 +1374,9 @@ internal class CmiAuthenticodeTimestamperInfo
private CmiAuthenticodeTimestamperInfo() { }
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
internal CmiAuthenticodeTimestamperInfo(Win32.AXL_TIMESTAMPER_INFO timestamperInfo)
{
_error = (int)timestamperInfo.dwError;
From c5ae661501082a6f58c4320e6c524433d196d439 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 10 Feb 2021 16:19:10 -0800
Subject: [PATCH 03/57] Relax nullable warnings in stringtools
---
src/StringTools/WeakStringCache.Concurrent.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/StringTools/WeakStringCache.Concurrent.cs b/src/StringTools/WeakStringCache.Concurrent.cs
index 6110475e946..f99bbf26501 100644
--- a/src/StringTools/WeakStringCache.Concurrent.cs
+++ b/src/StringTools/WeakStringCache.Concurrent.cs
@@ -37,7 +37,7 @@ public string GetOrCreateEntry(ref InternableString internable, out bool cacheHi
// Get the existing handle from the cache and lock it while we're dereferencing it to prevent a race with the Scavenge
// method running on another thread and freeing the handle from underneath us.
- if (_stringsByHashCode.TryGetValue(hashCode, out handle))
+ if (_stringsByHashCode.TryGetValue(hashCode, out handle!))
{
lock (handle)
{
@@ -98,7 +98,7 @@ public void Scavenge()
foreach (KeyValuePair entry in _stringsByHashCode)
{
// We can safely dereference entry.Value as the caller guarantees that Scavenge runs only on one thread.
- if (!entry.Value.IsUsed && _stringsByHashCode.TryRemove(entry.Key, out StringWeakHandle removedHandle))
+ if (!entry.Value.IsUsed && _stringsByHashCode.TryRemove(entry.Key, out StringWeakHandle? removedHandle))
{
lock (removedHandle)
{
From b2fa123a42614da71174034273e0b2ea62b755b7 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 10 Feb 2021 16:25:51 -0800
Subject: [PATCH 04/57] Update version of
Microsoft.VisualStudio.Setup.Configuration.Interop Also import conditionally
in the same way other projects import it (when on .NETFramework).
---
src/Utilities/Microsoft.Build.Utilities.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Utilities/Microsoft.Build.Utilities.csproj b/src/Utilities/Microsoft.Build.Utilities.csproj
index 4406635c278..fec8f266ab6 100644
--- a/src/Utilities/Microsoft.Build.Utilities.csproj
+++ b/src/Utilities/Microsoft.Build.Utilities.csproj
@@ -26,7 +26,7 @@
-
+
From d98fe68f84e87d514ad84a22428e7f0a5e67cd9a Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 17 Feb 2021 17:22:56 -0800
Subject: [PATCH 05/57] Use property to find netcoresdk bundledversions.props
---
src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
index 8220910cf74..2dd55ce391d 100644
--- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
+++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
@@ -20,7 +20,7 @@
-
+
From 3326faf5d6ad60a3d67e2c1bec3f67b31e7d8ec4 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 18 Feb 2021 15:12:22 -0800
Subject: [PATCH 06/57] Use RuntimeIdentifierGraphPath var
---
src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
index 2dd55ce391d..3c30cb43c58 100644
--- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
+++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
@@ -36,7 +36,7 @@
-
+
From 642093a5daa041fd9558960c5dd8161284d39e07 Mon Sep 17 00:00:00 2001
From: Ladi Prosek
Date: Tue, 2 Mar 2021 10:15:07 +0100
Subject: [PATCH 07/57] Use #if RUNTIME_TYPE_NETCORE instead of NETSTANDARD for
.NET Core-only code
---
src/StringTools/InternableString.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/StringTools/InternableString.cs b/src/StringTools/InternableString.cs
index 302d50bfd6c..7779d16e82d 100644
--- a/src/StringTools/InternableString.cs
+++ b/src/StringTools/InternableString.cs
@@ -96,7 +96,7 @@ public bool MoveNext()
///
private readonly ReadOnlySpan _inlineSpan;
-#if NETSTANDARD
+#if RUNTIME_TYPE_NETCORE
///
/// .NET Core does not keep a reference to the containing object in . In particular,
/// it cannot recover the string if the span represents one. We have to hold the reference separately to be able to
@@ -122,7 +122,7 @@ internal InternableString(ReadOnlySpan span)
_inlineSpan = span;
_spans = null;
Length = span.Length;
-#if NETSTANDARD
+#if RUNTIME_TYPE_NETCORE
_inlineSpanString = null;
#endif
}
@@ -141,7 +141,7 @@ internal InternableString(string str)
_inlineSpan = str.AsSpan();
_spans = null;
Length = str.Length;
-#if NETSTANDARD
+#if RUNTIME_TYPE_NETCORE
_inlineSpanString = str;
#endif
}
@@ -154,7 +154,7 @@ internal InternableString(SpanBasedStringBuilder stringBuilder)
_inlineSpan = default(ReadOnlySpan);
_spans = stringBuilder.Spans;
Length = stringBuilder.Length;
-#if NETSTANDARD
+#if RUNTIME_TYPE_NETCORE
_inlineSpanString = null;
#endif
}
@@ -220,7 +220,7 @@ public unsafe string ExpensiveConvertToString()
// Special case: if we hold just one string, we can directly return it.
if (_inlineSpan.Length == Length)
{
-#if NETSTANDARD
+#if RUNTIME_TYPE_NETCORE
if (_inlineSpanString != null)
{
return _inlineSpanString;
From d5370bf6502e75fc71f24952d5863155d6d93b7b Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 4 Jun 2021 18:51:03 -0700
Subject: [PATCH 08/57] Fix path to ref assemblies
---
src/MSBuild/MSBuild.csproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/MSBuild/MSBuild.csproj b/src/MSBuild/MSBuild.csproj
index 803083dd1fc..ccb4dde845a 100644
--- a/src/MSBuild/MSBuild.csproj
+++ b/src/MSBuild/MSBuild.csproj
@@ -259,8 +259,8 @@
BeforeTargets="AssignTargetPaths"
Condition="'$(MonoBuild)' != 'true'">
-
-
+
+
From f6c1204b4b3313bc70b59879d3387fa0a13339bd Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 4 Jun 2021 19:43:12 -0700
Subject: [PATCH 09/57] Update last SetTargetFramework to net6.0, use
EscapeDataString instead of EscapeUriString
---
src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj | 2 +-
src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
index 3cdb4a0546e..b2f745bc5bb 100644
--- a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
+++ b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
@@ -36,7 +36,7 @@
TargetFramework=$(FullFrameworkTFM)
TargetFramework=$(FullFrameworkTFM)
- TargetFramework=net5.0
+ TargetFramework=net6.0
diff --git a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
index 39469981e66..5a80c47461b 100644
--- a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
+++ b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
@@ -1906,7 +1906,7 @@ private static XmlElement CreateApplicationElement(XmlElement configElement, Bui
XmlElement filesNode = applicationElement.OwnerDocument.CreateElement("Files");
XmlElement fileNode = filesNode.OwnerDocument.CreateElement("File");
AddAttribute(fileNode, "Name", settings.ApplicationFile);
- AddAttribute(fileNode, URLNAME_ATTRIBUTE, Uri.EscapeUriString(settings.ApplicationFile));
+ AddAttribute(fileNode, URLNAME_ATTRIBUTE, Uri.EscapeDataString(settings.ApplicationFile));
filesNode.AppendChild(fileNode);
applicationElement.AppendChild(filesNode);
}
From 6f0581f34011b9214ff372cdb6af0f7fa4d295fc Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Mon, 7 Jun 2021 17:04:41 -0700
Subject: [PATCH 10/57] Mark signfile as supported on windows
---
src/Tasks/SignFile.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/Tasks/SignFile.cs b/src/Tasks/SignFile.cs
index e5d83dc48bc..428eda3cbc6 100644
--- a/src/Tasks/SignFile.cs
+++ b/src/Tasks/SignFile.cs
@@ -9,6 +9,9 @@
using Microsoft.Build.Shared;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
using Microsoft.Build.Utilities;
+#if RUNTIME_TYPE_NETCORE
+using System.Runtime.Versioning;
+#endif
#nullable disable
@@ -38,6 +41,9 @@ public SignFile()
public string TimestampUrl { get; set; }
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public override bool Execute()
{
try
From c720814a0adfcbcab1b018e7cd1fe71cc8b13f16 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 8 Jun 2021 13:33:37 -0700
Subject: [PATCH 11/57] Revert "Fix path to ref assemblies"
This reverts commit ad6b546dc2c38fa952aef5d1bba5f2b240578d4a.
---
src/MSBuild/MSBuild.csproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/MSBuild/MSBuild.csproj b/src/MSBuild/MSBuild.csproj
index ccb4dde845a..803083dd1fc 100644
--- a/src/MSBuild/MSBuild.csproj
+++ b/src/MSBuild/MSBuild.csproj
@@ -259,8 +259,8 @@
BeforeTargets="AssignTargetPaths"
Condition="'$(MonoBuild)' != 'true'">
-
-
+
+
From 499f6dc98e483ce44f0f689df847ed00a1143723 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 8 Jun 2021 13:34:04 -0700
Subject: [PATCH 12/57] Explicitly download netstandard.library for
roslyncodetaskfactory
---
src/MSBuild/MSBuild.csproj | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/MSBuild/MSBuild.csproj b/src/MSBuild/MSBuild.csproj
index 803083dd1fc..0f938f6958b 100644
--- a/src/MSBuild/MSBuild.csproj
+++ b/src/MSBuild/MSBuild.csproj
@@ -211,6 +211,14 @@
+
+
+
+ [2.0.3]
+
+
From 98b28d143c5aa3036a820c40cc9a3d773491bc13 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 9 Jun 2021 17:20:35 -0700
Subject: [PATCH 13/57] FindOnPathSucceeds: Ignore case on windows
---
src/Utilities.UnitTests/ToolTask_Tests.cs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs
index 1ced49c9b63..d4163dda65a 100644
--- a/src/Utilities.UnitTests/ToolTask_Tests.cs
+++ b/src/Utilities.UnitTests/ToolTask_Tests.cs
@@ -697,7 +697,17 @@ public void FindOnPathSucceeds()
cmdPath = ToolTask.FindOnPath(shellName);
}
- cmdPath.ShouldBeOneOf(expectedCmdPath);
+ string cmdPath = ToolTask.FindOnPath(shellName);
+
+ if (NativeMethodsShared.IsWindows)
+ {
+ cmdPath.ShouldBe(expectedCmdPath[0], StringCompareShould.IgnoreCase);
+ }
+ else
+ {
+ cmdPath.ShouldBeOneOf(expectedCmdPath);
+ }
+
}
///
From a34b2fa488cf13530c297fe16ef3b3b5967a7f39 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 13 Jan 2022 14:59:33 -0800
Subject: [PATCH 14/57] Fix SA1508 (blank line before curly brace)
---
src/Tasks/DownloadFile.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index ef4194d663c..b916197b7ae 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -318,8 +318,6 @@ public CustomHttpRequestException(string message, Exception inner, HttpStatusCod
}
public HttpStatusCode StatusCode { get; }
-
-
}
#endif
From 36cff1793fea7f8a4b87cc4fcadae5997c811490 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 13 Jan 2022 15:06:17 -0800
Subject: [PATCH 15/57] Revert FindOnPathSucceeds fix
---
src/Utilities.UnitTests/ToolTask_Tests.cs | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs
index d4163dda65a..1ced49c9b63 100644
--- a/src/Utilities.UnitTests/ToolTask_Tests.cs
+++ b/src/Utilities.UnitTests/ToolTask_Tests.cs
@@ -697,17 +697,7 @@ public void FindOnPathSucceeds()
cmdPath = ToolTask.FindOnPath(shellName);
}
- string cmdPath = ToolTask.FindOnPath(shellName);
-
- if (NativeMethodsShared.IsWindows)
- {
- cmdPath.ShouldBe(expectedCmdPath[0], StringCompareShould.IgnoreCase);
- }
- else
- {
- cmdPath.ShouldBeOneOf(expectedCmdPath);
- }
-
+ cmdPath.ShouldBeOneOf(expectedCmdPath);
}
///
From 982d5bc905497d5a0df506b259c5d0efc04e9716 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 13 Jan 2022 15:28:27 -0800
Subject: [PATCH 16/57] Fix nullability warning CS8765
---
src/Framework/Sdk/SdkResultItem.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Framework/Sdk/SdkResultItem.cs b/src/Framework/Sdk/SdkResultItem.cs
index cff07bb8bf7..febbbeffabc 100644
--- a/src/Framework/Sdk/SdkResultItem.cs
+++ b/src/Framework/Sdk/SdkResultItem.cs
@@ -36,7 +36,7 @@ public SdkResultItem(string itemSpec, Dictionary? metadata)
Metadata = metadata;
}
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is SdkResultItem item &&
ItemSpec == item.ItemSpec &&
From 8e89508e14c2c9c0e165d52d341cb72cb901ff8c Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 18 Jan 2022 11:01:23 -0800
Subject: [PATCH 17/57] Mark GetVersionIndependentToolPath as Windows only.
Resolves CA1416 for SecurityUtil
---
src/Tasks/ManifestUtil/SecurityUtil.cs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index e9b827bb1a7..e450d95e3af 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -826,9 +826,11 @@ internal static string GetPathToTool(System.Resources.ResourceManager resources)
toolPath = Path.Combine(pathToDotNetFrameworkSdk, "bin", ToolName);
}
}
- if (toolPath == null || !FileSystems.Default.FileExists(toolPath))
+ if (NativeMethodsShared.IsWindows && (toolPath == null || !FileSystems.Default.FileExists(toolPath)))
{
+#pragma warning disable CA1416 // Validate platform compatibility
toolPath = GetVersionIndependentToolPath(ToolName);
+#pragma warning restore CA1416
}
if (toolPath == null || !FileSystems.Default.FileExists(toolPath))
{
@@ -880,6 +882,9 @@ private static bool IsCertInStore(X509Certificate2 cert)
return false;
}
+#if NET5_0_OR_GREATER
+ [SupportedOSPlatformAttribute("windows")]
+#endif
private static string GetVersionIndependentToolPath(string toolName)
{
const string versionIndependentToolKeyName = @"Software\Microsoft\ClickOnce\SignTool";
From ab5b02ac2d3f15e2ecca89c41c96bc95e4943a90 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 18 Jan 2022 11:12:49 -0800
Subject: [PATCH 18/57] Fix SYSLIB0021 in BootstrapperBuilder
---
src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
index 5a80c47461b..05df35e1389 100644
--- a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
+++ b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
@@ -1643,7 +1643,7 @@ private static string GetFileHash(string filePath)
// the .NET Framework we are targeting. In ideal situations, bootstrapper files will be
// pre-signed anwyay; this is a fallback in case we ever encounter a bootstrapper that is
// not signed.
- System.Security.Cryptography.SHA256CryptoServiceProvider sha = new System.Security.Cryptography.SHA256CryptoServiceProvider();
+ System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create("System.Security.Cryptography.SHA256CryptoServiceProvider");
using (Stream s = fi.OpenRead())
{
From 8cb9f2c51ee2f095720fa4bede975bd79b1651bf Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 18 Jan 2022 11:27:15 -0800
Subject: [PATCH 19/57] ! Fix SYSLIB0021 in mansign2
---
src/Tasks/ManifestUtil/mansign2.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/Tasks/ManifestUtil/mansign2.cs b/src/Tasks/ManifestUtil/mansign2.cs
index de9f546f472..5dfb3074534 100644
--- a/src/Tasks/ManifestUtil/mansign2.cs
+++ b/src/Tasks/ManifestUtil/mansign2.cs
@@ -277,7 +277,7 @@ private void init()
Sha256SignatureMethodUri);
#if RUNTIME_TYPE_NETCORE
- CryptoConfig.AddAlgorithm(typeof(SHA256Managed),
+ CryptoConfig.AddAlgorithm(typeof(SHA256),
Sha256DigestMethod);
#else
CryptoConfig.AddAlgorithm(typeof(System.Security.Cryptography.SHA256Cng),
@@ -584,7 +584,7 @@ private static byte[] ComputeHashFromManifest(XmlDocument manifestDom, bool oldF
if (useSha256)
{
- using (SHA256CryptoServiceProvider sha2 = new SHA256CryptoServiceProvider())
+ using (SHA256 sha2 = SHA256.Create("System.Security.Cryptography.SHA256CryptoServiceProvider"))
{
byte[] hash = sha2.ComputeHash(exc.GetOutput() as MemoryStream);
if (hash == null)
@@ -597,7 +597,7 @@ private static byte[] ComputeHashFromManifest(XmlDocument manifestDom, bool oldF
}
else
{
- using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
+ using (SHA1 sha1 = SHA1.Create("System.Security.Cryptography.SHA1CryptoServiceProvider"))
{
byte[] hash = sha1.ComputeHash(exc.GetOutput() as MemoryStream);
if (hash == null)
@@ -632,7 +632,7 @@ private static byte[] ComputeHashFromManifest(XmlDocument manifestDom, bool oldF
if (useSha256)
{
- using (SHA256CryptoServiceProvider sha2 = new SHA256CryptoServiceProvider())
+ using (SHA256 sha2 = SHA256.Create("System.Security.Cryptography.SHA256CryptoServiceProvider"))
{
byte[] hash = sha2.ComputeHash(exc.GetOutput() as MemoryStream);
if (hash == null)
@@ -645,7 +645,7 @@ private static byte[] ComputeHashFromManifest(XmlDocument manifestDom, bool oldF
}
else
{
- using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
+ using (SHA1 sha1 = SHA1.Create("System.Security.Cryptography.SHA1CryptoServiceProvider"))
{
byte[] hash = sha1.ComputeHash(exc.GetOutput() as MemoryStream);
if (hash == null)
From 18b8d7c6ef3c2d20786ce4aff78038e858ee1e5c Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 18 Jan 2022 11:33:20 -0800
Subject: [PATCH 20/57] Fix CA2016 in DownloadFile
---
src/Tasks/DownloadFile.cs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index b916197b7ae..658022ff2dd 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -185,7 +185,11 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
{
Log.LogMessageFromResources(MessageImportance.High, "DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength);
+#if NET5_0_OR_GREATER
+ using (Stream responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false))
+#else
using (Stream responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
+#endif
{
await responseStream.CopyToAsync(target, 1024, cancellationToken).ConfigureAwait(false);
}
From 65212a46773c88cb5509d1eeca462f7eae48d7da Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 18 Jan 2022 12:15:02 -0800
Subject: [PATCH 21/57] Add PlatformGuard to NativeMethodsShared.IsWindows
---
src/Framework/NativeMethods.cs | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/Framework/NativeMethods.cs b/src/Framework/NativeMethods.cs
index 886fe7aa982..f98d85b85b0 100644
--- a/src/Framework/NativeMethods.cs
+++ b/src/Framework/NativeMethods.cs
@@ -10,6 +10,7 @@
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Text;
using System.Threading;
@@ -722,6 +723,9 @@ internal static bool IsMono
///
/// Gets a flag indicating if we are running under some version of Windows
///
+#if NET5_0_OR_GREATER
+ [SupportedOSPlatformGuard("windows")]
+#endif
internal static bool IsWindows
{
#if CLR2COMPATIBILITY
@@ -876,9 +880,9 @@ private static SystemInformationData SystemInformation
///
internal static ProcessorArchitectures ProcessorArchitectureNative => SystemInformation.ProcessorArchitectureTypeNative;
- #endregion
+#endregion
- #region Wrapper methods
+#region Wrapper methods
///
/// Really truly non pumping wait.
@@ -1460,9 +1464,9 @@ internal static void VerifyThrowWin32Result(int result)
}
}
- #endregion
+#endregion
- #region PInvoke
+#region PInvoke
///
/// Gets the current OEM code page which is used by console apps
@@ -1622,9 +1626,9 @@ out FILETIME lpLastWriteTime
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern bool SetThreadErrorMode(int newMode, out int oldMode);
- #endregion
+#endregion
- #region Extensions
+#region Extensions
///
/// Waits while pumping APC messages. This is important if the waiting thread is an STA thread which is potentially
@@ -1671,9 +1675,9 @@ internal static bool MsgWaitOne(this WaitHandle handle, int timeout)
return returnValue == 0;
}
- #endregion
+#endregion
- #region helper methods
+#region helper methods
internal static bool DirectoryExists(string fullPath)
{
@@ -1716,6 +1720,6 @@ internal static bool FileOrDirectoryExistsWindows(string path)
return GetFileAttributesEx(path, 0, ref data);
}
- #endregion
+#endregion
}
From e9bed315add35d47dd9696480f0f93764878b912 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 18 Jan 2022 12:26:07 -0800
Subject: [PATCH 22/57] NoWarn on CA1416
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 0df28a5b8b2..a3b0e8f7199 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -38,7 +38,7 @@
SYSLIB0011: Removing binary formatter will happen as part of a larger .NET-wide effort.
-->
- $(NoWarn);NU1603;NU5105;1701;1702;SYSLIB0011
+ $(NoWarn);NU1603;NU5105;1701;1702;SYSLIB0011;CA1416
From 9863e76c967646c7cd27a9c80d5c12801c1deaad Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 18 Jan 2022 12:27:09 -0800
Subject: [PATCH 23/57] Fix SYSLIB0021 in ManifestUtil/Util
---
src/Tasks/ManifestUtil/Util.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Tasks/ManifestUtil/Util.cs b/src/Tasks/ManifestUtil/Util.cs
index f6715320062..bea7f4b1264 100644
--- a/src/Tasks/ManifestUtil/Util.cs
+++ b/src/Tasks/ManifestUtil/Util.cs
@@ -225,11 +225,11 @@ private static void GetFileInfoImpl(string path, string targetFrameWorkVersion,
if (string.IsNullOrEmpty(targetFrameWorkVersion) || CompareFrameworkVersions(targetFrameWorkVersion, Constants.TargetFrameworkVersion40) <= 0)
{
- hashAlg = new SHA1CryptoServiceProvider();
+ hashAlg = SHA1.Create("System.Security.Cryptography.SHA1CryptoServiceProvider");
}
else
{
- hashAlg = new SHA256CryptoServiceProvider();
+ hashAlg = SHA256.Create("System.Security.Cryptography.SHA256CryptoServiceProvider");
}
byte[] hashBytes = hashAlg.ComputeHash(s);
hash = Convert.ToBase64String(hashBytes);
From c927db530de506266b113cefa6b8c6d1893ccf05 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 25 Jan 2022 14:01:23 -0800
Subject: [PATCH 24/57] Target relevant projects to netstandard2.0. Prevent
those targets from being analyzed, generating pdbs, and force them to only
produce reference assemblies
---
src/Directory.Build.props | 9 +++++++++
src/Framework/Microsoft.Build.Framework.csproj | 6 +++++-
src/StringTools/StringTools.csproj | 8 ++++++--
src/Utilities/Microsoft.Build.Utilities.csproj | 6 +++++-
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 2a5fbe50890..735f85cc1c3 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -72,4 +72,13 @@
AnyCPU
+
+
+
+ true
+ false
+ false
+ false
+ false
+
diff --git a/src/Framework/Microsoft.Build.Framework.csproj b/src/Framework/Microsoft.Build.Framework.csproj
index df75564473e..2e5aec36081 100644
--- a/src/Framework/Microsoft.Build.Framework.csproj
+++ b/src/Framework/Microsoft.Build.Framework.csproj
@@ -1,6 +1,6 @@
- $(LibraryTargetFrameworks)
+ $(LibraryTargetFrameworks);netstandard2.0
true
true
true
@@ -22,6 +22,10 @@
+
+ false
+
+
diff --git a/src/StringTools/StringTools.csproj b/src/StringTools/StringTools.csproj
index 15ac5335951..e891ed223c4 100644
--- a/src/StringTools/StringTools.csproj
+++ b/src/StringTools/StringTools.csproj
@@ -1,7 +1,7 @@
- $(LibraryTargetFrameworks)
- $(LibraryTargetFrameworks);net35
+ $(LibraryTargetFrameworks);netstandard2.0
+ $(LibraryTargetFrameworks);net35;netstandard2.0
AnyCPU
true
true
@@ -22,6 +22,10 @@
Microsoft.NET.StringTools.net35
+
+ false
+
+
diff --git a/src/Utilities/Microsoft.Build.Utilities.csproj b/src/Utilities/Microsoft.Build.Utilities.csproj
index fec8f266ab6..93c295becb2 100644
--- a/src/Utilities/Microsoft.Build.Utilities.csproj
+++ b/src/Utilities/Microsoft.Build.Utilities.csproj
@@ -4,7 +4,7 @@
- $(LibraryTargetFrameworks)
+ $(LibraryTargetFrameworks);netstandard2.0
True
Microsoft.Build.Utilities
Microsoft.Build.Utilities.Core
@@ -17,6 +17,10 @@
full
+
+ false
+
+
From 27a0b105054c52cc5818cb978318835d4e15c0e6 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 26 Jan 2022 15:54:31 -0800
Subject: [PATCH 25/57] PortableTask must build as ns2.0
---
src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj | 2 +-
src/Directory.Build.props | 2 +-
src/Samples/PortableTask/PortableTask.csproj | 2 +-
src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
index b2f745bc5bb..8ddca6108ac 100644
--- a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
+++ b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
@@ -38,7 +38,7 @@
TargetFramework=$(FullFrameworkTFM)
TargetFramework=net6.0
-
+
TargetFramework=$(FullFrameworkTFM)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 735f85cc1c3..82a6ac1881d 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -74,7 +74,7 @@
-
+
true
false
false
diff --git a/src/Samples/PortableTask/PortableTask.csproj b/src/Samples/PortableTask/PortableTask.csproj
index 6a4541787a1..a497a305fb2 100644
--- a/src/Samples/PortableTask/PortableTask.csproj
+++ b/src/Samples/PortableTask/PortableTask.csproj
@@ -3,7 +3,7 @@
true
false
false
- netstandard2.0
+ netstandard2.0
diff --git a/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj b/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
index 9d9813898bc..4bf53a812a9 100644
--- a/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
+++ b/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
@@ -25,7 +25,7 @@
-
+
From 42f8e51df2de5c727bc407552d62fe94365ffff0 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 26 Jan 2022 15:58:34 -0800
Subject: [PATCH 26/57] Build M.B.Framework & Utilities as ns2.0 so
RoslynCodeTaskFactory can find them
---
src/Tasks/Microsoft.Build.Tasks.csproj | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/Tasks/Microsoft.Build.Tasks.csproj b/src/Tasks/Microsoft.Build.Tasks.csproj
index 1d84694b402..8771f286d7d 100644
--- a/src/Tasks/Microsoft.Build.Tasks.csproj
+++ b/src/Tasks/Microsoft.Build.Tasks.csproj
@@ -957,6 +957,9 @@
+
+
+
@@ -968,6 +971,12 @@
+
+
+
+
+
+
From 7e07f743809df995eaa1fe762ceca736351db9b2 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 26 Jan 2022 16:34:43 -0800
Subject: [PATCH 27/57] System.Runtime.Versioning is used in netcore and full
framework now
---
src/Tasks/ManifestUtil/SecurityUtil.cs | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index dc4dec46229..ac3920c0a7f 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -22,6 +22,7 @@
using System.Reflection;
#endif
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
@@ -32,9 +33,6 @@
using System.Text;
using System.Xml;
using Microsoft.Build.Shared.FileSystem;
-#if !RUNTIME_TYPE_NETCORE
-using FrameworkNameVersioning = System.Runtime.Versioning.FrameworkName;
-#endif
#nullable disable
@@ -143,15 +141,15 @@ private static PermissionSet GetNamedPermissionSetFromZone(string targetZone, st
private static PermissionSet GetNamedPermissionSet(string targetZone, string targetFrameworkMoniker)
{
- FrameworkNameVersioning fn;
+ FrameworkName fn;
if (!string.IsNullOrEmpty(targetFrameworkMoniker))
{
- fn = new FrameworkNameVersioning(targetFrameworkMoniker);
+ fn = new FrameworkName(targetFrameworkMoniker);
}
else
{
- fn = new FrameworkNameVersioning(".NETFramework", s_dotNet40Version);
+ fn = new FrameworkName(".NETFramework", s_dotNet40Version);
}
int majorVersion = fn.Version.Major;
@@ -170,7 +168,7 @@ private static PermissionSet GetNamedPermissionSet(string targetZone, string tar
}
}
- private static XmlElement GetXmlElement(string targetZone, FrameworkNameVersioning fn)
+ private static XmlElement GetXmlElement(string targetZone, FrameworkName fn)
{
IList paths = ToolLocationHelper.GetPathToReferenceAssemblies(fn);
@@ -889,7 +887,7 @@ private static bool IsCertInStore(X509Certificate2 cert)
return false;
}
-#if NET5_0_OR_GREATER
+#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatformAttribute("windows")]
#endif
private static string GetVersionIndependentToolPath(string toolName)
From 72bf1ac37cf0237b34fc6b2de884724d5b177202 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 27 Jan 2022 16:24:36 -0800
Subject: [PATCH 28/57] Mimic AddRefAssemblies from MSBuild.csproj to
M.B.Tasks.csproj
---
src/Tasks/Microsoft.Build.Tasks.csproj | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/Tasks/Microsoft.Build.Tasks.csproj b/src/Tasks/Microsoft.Build.Tasks.csproj
index 3473d7c2507..2adf8902e96 100644
--- a/src/Tasks/Microsoft.Build.Tasks.csproj
+++ b/src/Tasks/Microsoft.Build.Tasks.csproj
@@ -971,9 +971,11 @@
-
+
-
+
From 6a262ef67168f37fcf881bd98b372327bf2bee88 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 28 Jan 2022 14:10:25 -0800
Subject: [PATCH 29/57] Remove CA1416 from NoWarn and mark each windows-specfic
path as such. Also fix unused usings warnings
---
Directory.Build.props | 2 +-
src/Framework/NativeMethods.cs | 16 +++++++-----
.../AssemblyDependency/Miscellaneous.cs | 1 -
.../BootstrapperUtil/BootstrapperBuilder.cs | 15 ++++++++---
src/Tasks/BootstrapperUtil/Util.cs | 15 +++++++++++
src/Tasks/FormatUrl.cs | 4 ++-
src/Tasks/GenerateApplicationManifest.cs | 4 +--
src/Tasks/GenerateDeploymentManifest.cs | 6 ++++-
src/Tasks/GenerateLauncher.cs | 2 +-
src/Tasks/ManifestUtil/ComImporter.cs | 4 +++
src/Tasks/ManifestUtil/FileReference.cs | 26 ++++++++++++-------
src/Tasks/ManifestUtil/Util.cs | 10 +++++--
12 files changed, 75 insertions(+), 30 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index a3b0e8f7199..0df28a5b8b2 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -38,7 +38,7 @@
SYSLIB0011: Removing binary formatter will happen as part of a larger .NET-wide effort.
-->
- $(NoWarn);NU1603;NU5105;1701;1702;SYSLIB0011;CA1416
+ $(NoWarn);NU1603;NU5105;1701;1702;SYSLIB0011
diff --git a/src/Framework/NativeMethods.cs b/src/Framework/NativeMethods.cs
index 41434303c83..752771d1f78 100644
--- a/src/Framework/NativeMethods.cs
+++ b/src/Framework/NativeMethods.cs
@@ -9,7 +9,9 @@
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
+#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
+#endif
using System.Text;
using System.Threading;
@@ -24,7 +26,7 @@
namespace Microsoft.Build.Framework;
internal static class NativeMethods
{
- #region Constants
+#region Constants
internal const uint ERROR_INSUFFICIENT_BUFFER = 0x8007007A;
internal const uint STARTUP_LOADER_SAFEMODE = 0x10;
@@ -80,9 +82,9 @@ internal static class NativeMethods
internal const CharSet AutoOrUnicode = CharSet.Unicode;
#endif
- #endregion
+#endregion
- #region Enums
+#region Enums
private enum PROCESSINFOCLASS : int
{
@@ -207,9 +209,9 @@ internal enum ProcessorArchitectures
Unknown
}
- #endregion
+#endregion
- #region Structs
+#region Structs
///
/// Structure that contain information about the system on which we are running
@@ -577,9 +579,9 @@ private unsafe static int GetLogicalCoreCountOnWindows()
return -1;
}
- #endregion
+#endregion
- #region Member data
+#region Member data
internal static bool HasMaxPath => MaxPath == MAX_PATH;
diff --git a/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs b/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
index 9fe18eaef93..beec4a1d226 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
@@ -14,7 +14,6 @@
using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture;
using Xunit.Abstractions;
using Shouldly;
-using System.Text;
#nullable disable
diff --git a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
index 05df35e1389..631db0a0bd9 100644
--- a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
+++ b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
@@ -76,7 +76,7 @@ public class BootstrapperBuilder : IBootstrapperBuilder
///
public BootstrapperBuilder()
{
- _path = Util.DefaultPath;
+ _path = NativeMethodsShared.IsWindows ? Util.DefaultPath : string.Empty;
}
///
@@ -85,7 +85,7 @@ public BootstrapperBuilder()
/// The version of Visual Studio that is used to build this bootstrapper.
public BootstrapperBuilder(string visualStudioVersion)
{
- _path = Util.GetDefaultPath(visualStudioVersion);
+ _path = NativeMethodsShared.IsWindows ? Util.GetDefaultPath(visualStudioVersion) : string.Empty;
}
#region IBootstrapperBuilder Members
@@ -447,7 +447,10 @@ public string[] GetOutputFolders(string[] productCodes, string culture, string f
BuildPackages(settings, null, null, files, null);
List packagePaths = new List() { invariantPath };
- packagePaths.AddRange(Util.AdditionalPackagePaths.Select(p => Util.AddTrailingChar(p.ToLowerInvariant(), System.IO.Path.DirectorySeparatorChar)));
+ if (NativeMethodsShared.IsWindows)
+ {
+ packagePaths.AddRange(Util.AdditionalPackagePaths.Select(p => Util.AddTrailingChar(p.ToLowerInvariant(), System.IO.Path.DirectorySeparatorChar)));
+ }
foreach (string file in files)
{
@@ -591,7 +594,11 @@ private void RefreshProducts()
XmlElement rootElement = _document.CreateElement("Products", BOOTSTRAPPER_NAMESPACE);
List packagePaths = new List() { PackagePath };
- packagePaths.AddRange(Util.AdditionalPackagePaths);
+ if (NativeMethodsShared.IsWindows)
+ {
+ packagePaths.AddRange(Util.AdditionalPackagePaths);
+ }
+
foreach (string packagePath in packagePaths)
{
if (FileSystems.Default.DirectoryExists(packagePath))
diff --git a/src/Tasks/BootstrapperUtil/Util.cs b/src/Tasks/BootstrapperUtil/Util.cs
index 0ed5be1dea0..819f4f53edf 100644
--- a/src/Tasks/BootstrapperUtil/Util.cs
+++ b/src/Tasks/BootstrapperUtil/Util.cs
@@ -5,6 +5,9 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
+#if RUNTIME_TYPE_NETCORE
+using System.Runtime.Versioning;
+#endif
using Microsoft.Build.Shared;
using Microsoft.Win32;
@@ -75,6 +78,9 @@ public static CultureInfo GetCultureInfoFromString(string cultureName)
public static CultureInfo DefaultCultureInfo => System.Threading.Thread.CurrentThread.CurrentUICulture;
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
// This is the 4.0 property and will always point to the Dev10 registry key so that we don't break backwards compatibility.
// Applications relying on 4.5 will need to use the new method that is introduced in 4.5.
public static string DefaultPath
@@ -102,6 +108,9 @@ public static string DefaultPath
}
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
// A new method in 4.5 to get the default path for bootstrapper packages.
// This method is not going to cache the path as it could be different depending on the Visual Studio version.
public static string GetDefaultPath(string visualStudioVersion)
@@ -153,6 +162,9 @@ public static string GetDefaultPath(string visualStudioVersion)
return Directory.GetCurrentDirectory();
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
// Gets the list of additional paths to inspect for packages as defined in the registry
public static List AdditionalPackagePaths
{
@@ -202,6 +214,9 @@ public static List AdditionalPackagePaths
}
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
private static string ReadRegistryString(RegistryKey key, string path, string registryValue)
{
RegistryKey subKey = key.OpenSubKey(path, false);
diff --git a/src/Tasks/FormatUrl.cs b/src/Tasks/FormatUrl.cs
index f742f4d238b..4b600c49ef9 100644
--- a/src/Tasks/FormatUrl.cs
+++ b/src/Tasks/FormatUrl.cs
@@ -1,9 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+#if !RUNTIME_TYPE_NETCORE
using System;
-using Microsoft.Build.Framework;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
+#endif
+using Microsoft.Build.Framework;
#nullable disable
diff --git a/src/Tasks/GenerateApplicationManifest.cs b/src/Tasks/GenerateApplicationManifest.cs
index bece4016d94..b90bfe1002c 100644
--- a/src/Tasks/GenerateApplicationManifest.cs
+++ b/src/Tasks/GenerateApplicationManifest.cs
@@ -219,7 +219,7 @@ private bool AddIsolatedComReferences(ApplicationManifest manifest)
name = Path.GetFileName(item.ItemSpec);
}
FileReference file = AddFileFromItem(item);
- if (!file.ImportComComponent(item.ItemSpec, manifest.OutputMessages, name))
+ if (NativeMethodsShared.IsWindows && !file.ImportComComponent(item.ItemSpec, manifest.OutputMessages, name))
{
success = false;
}
@@ -386,7 +386,7 @@ private bool BuildResolvedSettings(ApplicationManifest manifest)
}
else if (String.IsNullOrEmpty(manifest.Publisher))
{
- string org = Util.GetRegisteredOrganization();
+ string org = NativeMethodsShared.IsWindows ? Util.GetRegisteredOrganization() : string.Empty;
if (!String.IsNullOrEmpty(org))
{
manifest.Publisher = org;
diff --git a/src/Tasks/GenerateDeploymentManifest.cs b/src/Tasks/GenerateDeploymentManifest.cs
index d4ff40421a4..a19de20c07d 100644
--- a/src/Tasks/GenerateDeploymentManifest.cs
+++ b/src/Tasks/GenerateDeploymentManifest.cs
@@ -141,7 +141,11 @@ private bool BuildResolvedSettings(DeployManifest manifest)
}
else if (String.IsNullOrEmpty(manifest.Publisher))
{
- string org = Util.GetRegisteredOrganization();
+ string org = string.Empty;
+ if (NativeMethodsShared.IsWindows)
+ {
+ org = Util.GetRegisteredOrganization();
+ }
manifest.Publisher = !String.IsNullOrEmpty(org) ? org : manifest.Product;
}
Debug.Assert(!String.IsNullOrEmpty(manifest.Publisher));
diff --git a/src/Tasks/GenerateLauncher.cs b/src/Tasks/GenerateLauncher.cs
index 6bedd918410..060f7224791 100644
--- a/src/Tasks/GenerateLauncher.cs
+++ b/src/Tasks/GenerateLauncher.cs
@@ -39,7 +39,7 @@ public sealed class GenerateLauncher : TaskExtension
public override bool Execute()
{
- if (LauncherPath == null)
+ if (LauncherPath == null && NativeMethodsShared.IsWindows)
{
// Launcher lives next to ClickOnce bootstrapper.
// GetDefaultPath obtains the root ClickOnce boostrapper path.
diff --git a/src/Tasks/ManifestUtil/ComImporter.cs b/src/Tasks/ManifestUtil/ComImporter.cs
index 116439f37de..32c121b9725 100644
--- a/src/Tasks/ManifestUtil/ComImporter.cs
+++ b/src/Tasks/ManifestUtil/ComImporter.cs
@@ -9,12 +9,16 @@
using System.Runtime.InteropServices;
#if RUNTIME_TYPE_NETCORE
using System.Runtime.InteropServices.ComTypes;
+using System.Runtime.Versioning;
#endif
#nullable disable
namespace Microsoft.Build.Tasks.Deployment.ManifestUtilities
{
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
internal class ComImporter
{
private readonly OutputMessageCollection _outputMessages;
diff --git a/src/Tasks/ManifestUtil/FileReference.cs b/src/Tasks/ManifestUtil/FileReference.cs
index e2e0f6b75d8..3f62edaecc5 100644
--- a/src/Tasks/ManifestUtil/FileReference.cs
+++ b/src/Tasks/ManifestUtil/FileReference.cs
@@ -5,6 +5,9 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
+#if RUNTIME_TYPE_NETCORE
+using System.Runtime.Versioning;
+#endif
using System.Text;
using System.Xml.Serialization;
@@ -44,6 +47,9 @@ public FileReference(string path) : base(path)
[XmlIgnore]
public ComClass[] ComClasses => _comClasses;
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
internal bool ImportComComponent(string path, OutputMessageCollection outputMessages, string outputDisplayName)
{
var importer = new ComImporter(path, outputMessages, outputDisplayName);
@@ -103,7 +109,7 @@ public bool IsDataFile
[XmlIgnore]
public TypeLib[] TypeLibs => _typeLibs;
- #region " XmlSerializer "
+#region " XmlSerializer "
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -141,7 +147,7 @@ public string XmlWriteableType
set => _writeableType = value;
}
- #endregion
+#endregion
}
[ComVisible(false)]
@@ -181,7 +187,7 @@ internal ComClass(Guid tlbId, Guid clsId, string progId, string threadingModel,
[XmlIgnore]
public string TlbId => _tlbid;
- #region " XmlSerializer "
+#region " XmlSerializer "
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -228,7 +234,7 @@ public string XmlTlbId
set => _tlbid = value;
}
- #endregion
+#endregion
}
[ComVisible(false)]
@@ -293,7 +299,7 @@ private static string FlagsFromInt(int flags)
[XmlIgnore]
public string Version => _version;
- #region " XmlSerializer "
+#region " XmlSerializer "
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -340,7 +346,7 @@ public string XmlVersion
set => _version = value;
}
- #endregion
+#endregion
}
[ComVisible(false)]
@@ -380,7 +386,7 @@ public bool Versioned
}
}
- #region " XmlSerializer "
+#region " XmlSerializer "
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -400,7 +406,7 @@ public string XmlVersioned
set => _versioned = value;
}
- #endregion
+#endregion
}
[ComVisible(false)]
@@ -427,7 +433,7 @@ public class ProxyStub
[XmlIgnore]
public string TlbId => _tlbid;
- #region " XmlSerializer "
+#region " XmlSerializer "
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -474,6 +480,6 @@ public string XmlTlbId
set => _tlbid = value;
}
- #endregion
+#endregion
}
}
diff --git a/src/Tasks/ManifestUtil/Util.cs b/src/Tasks/ManifestUtil/Util.cs
index 12ba135aa53..20018c9c9f7 100644
--- a/src/Tasks/ManifestUtil/Util.cs
+++ b/src/Tasks/ManifestUtil/Util.cs
@@ -13,6 +13,9 @@
using System.IO;
using System.Linq;
using System.Reflection;
+#if RUNTIME_TYPE_NETCORE
+using System.Runtime.Versioning;
+#endif
using System.Security;
using System.Security.Cryptography;
using System.Text;
@@ -250,6 +253,9 @@ private static string GetLogPath()
return logPath;
}
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public static string GetRegisteredOrganization()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false);
@@ -515,7 +521,7 @@ public static string WriteTempFile(string s)
return path;
}
- #region ItemComparer
+#region ItemComparer
private static readonly ItemComparer s_itemComparer = new ItemComparer();
private class ItemComparer : IComparer
{
@@ -541,7 +547,7 @@ int IComparer.Compare(object obj1, object obj2)
return String.Compare(item1.ItemSpec, item2.ItemSpec, StringComparison.Ordinal);
}
}
- #endregion
+#endregion
public static Version ConvertFrameworkVersionToString(string version)
{
From ce53557598e4362f026392821bd6a8d781a44c38 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 2 Feb 2022 15:12:05 -0800
Subject: [PATCH 30/57] Update latest package version
---
eng/Packages.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eng/Packages.props b/eng/Packages.props
index b6e51805983..7334fbeb8d7 100644
--- a/eng/Packages.props
+++ b/eng/Packages.props
@@ -10,7 +10,7 @@
-
+
From 44626b8e5930bc927a70cc32544de6733457a6cc Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 3 Feb 2022 16:28:07 -0800
Subject: [PATCH 31/57] Last SignFile call is now under SupportedOSPlatform
---
src/Tasks/ManifestUtil/SecurityUtil.cs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index 590df05f8e4..efb1351524c 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -548,6 +548,9 @@ public static void SignFile(string certThumbprint,
/// Version of the .NET Framework for the target.
/// .NET Framework identifier for the target.
/// Disallow fallback to legacy timestamping when RFC3161 timestamping fails during manifest signing
+#if RUNTIME_TYPE_NETCORE
+ [SupportedOSPlatform("windows")]
+#endif
public static void SignFile(string certThumbprint,
Uri timestampUrl,
string path,
From 6099f124ecc2072267d3cae07cef69295e3b4bca Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 4 Feb 2022 13:17:29 -0800
Subject: [PATCH 32/57] Code cleanup. Use RUNTIME_TYPE_NETCORE instead of
NET5_0_OR_GREATER
---
src/StringTools/StringTools.csproj | 7 ++++---
src/StringTools/WeakStringCache.Concurrent.cs | 4 ++--
src/Tasks/DownloadFile.cs | 13 ++++++++-----
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/StringTools/StringTools.csproj b/src/StringTools/StringTools.csproj
index e891ed223c4..67211078842 100644
--- a/src/StringTools/StringTools.csproj
+++ b/src/StringTools/StringTools.csproj
@@ -22,9 +22,10 @@
Microsoft.NET.StringTools.net35
-
- false
-
+
+
+ false
+
diff --git a/src/StringTools/WeakStringCache.Concurrent.cs b/src/StringTools/WeakStringCache.Concurrent.cs
index f99bbf26501..3261141fcbf 100644
--- a/src/StringTools/WeakStringCache.Concurrent.cs
+++ b/src/StringTools/WeakStringCache.Concurrent.cs
@@ -32,12 +32,12 @@ public string GetOrCreateEntry(ref InternableString internable, out bool cacheHi
{
int hashCode = internable.GetHashCode();
- StringWeakHandle handle;
+ StringWeakHandle? handle;
string? result;
// Get the existing handle from the cache and lock it while we're dereferencing it to prevent a race with the Scavenge
// method running on another thread and freeing the handle from underneath us.
- if (_stringsByHashCode.TryGetValue(hashCode, out handle!))
+ if (_stringsByHashCode.TryGetValue(hashCode, out handle))
{
lock (handle)
{
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index 658022ff2dd..01c304b5ca2 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -185,7 +185,7 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
{
Log.LogMessageFromResources(MessageImportance.High, "DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength);
-#if NET5_0_OR_GREATER
+#if RUNTIME_TYPE_NETCORE
using (Stream responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false))
#else
using (Stream responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
@@ -242,19 +242,20 @@ private static bool IsRetriable(Exception exception, out Exception actualExcepti
}
#if RUNTIME_TYPE_NETCORE
+ // net5.0 included StatusCode in the HttpRequestException.
switch (httpRequestException.StatusCode)
{
case HttpStatusCode.InternalServerError:
case HttpStatusCode.RequestTimeout:
return true;
}
-#endif
+ }
+#else
}
-#if !RUNTIME_TYPE_NETCORE
+ // framework workaround for HttpRequestException not containing StatusCode
if (actualException is CustomHttpRequestException customHttpRequestException)
{
- // A wrapped CustomHttpRequestException has the status code from the error
switch (customHttpRequestException.StatusCode)
{
case HttpStatusCode.InternalServerError:
@@ -264,6 +265,7 @@ private static bool IsRetriable(Exception exception, out Exception actualExcepti
}
#endif
+
if (actualException is WebException webException)
{
// WebException is thrown when accessing the Content of the response
@@ -312,6 +314,7 @@ private bool TryGetFileName(HttpResponseMessage response, out string filename)
#if !RUNTIME_TYPE_NETCORE
///
/// Represents a wrapper around the that also contains the .
+ /// DEPRECATED as of net5.0, which included the StatusCode in the HttpRequestException class.
///
private sealed class CustomHttpRequestException : HttpRequestException
{
@@ -325,7 +328,7 @@ public CustomHttpRequestException(string message, Exception inner, HttpStatusCod
}
#endif
-private bool ShouldSkip(HttpResponseMessage response, FileInfo destinationFile)
+ private bool ShouldSkip(HttpResponseMessage response, FileInfo destinationFile)
{
return SkipUnchangedFiles
&& destinationFile.Exists
From 5f3e506462ff2bfc4f18fb88e29fd18b24056703 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 4 Feb 2022 14:32:50 -0800
Subject: [PATCH 33/57] Minor code cleanup
---
src/Tasks/ManifestUtil/SecurityUtil.cs | 2 --
src/Tasks/Microsoft.Build.Tasks.csproj | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index efb1351524c..1f9f5c18a8e 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -860,9 +860,7 @@ internal static string GetPathToTool(System.Resources.ResourceManager resources)
}
if (NativeMethodsShared.IsWindows && (toolPath == null || !FileSystems.Default.FileExists(toolPath)))
{
-#pragma warning disable CA1416 // Validate platform compatibility
toolPath = GetVersionIndependentToolPath(ToolName);
-#pragma warning restore CA1416
}
if (toolPath == null || !FileSystems.Default.FileExists(toolPath))
{
diff --git a/src/Tasks/Microsoft.Build.Tasks.csproj b/src/Tasks/Microsoft.Build.Tasks.csproj
index 2adf8902e96..1e8d82aa831 100644
--- a/src/Tasks/Microsoft.Build.Tasks.csproj
+++ b/src/Tasks/Microsoft.Build.Tasks.csproj
@@ -971,6 +971,7 @@
+
From 6a0fa83f9506acc6845ee746c23d97021320576b Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 4 Feb 2022 14:45:07 -0800
Subject: [PATCH 34/57] Add FEATURE_FASTSPAN
---
src/Directory.BeforeCommon.targets | 2 +-
src/Framework/NativeMethods.cs | 2 +-
src/StringTools/InternableString.cs | 10 +++++-----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/Directory.BeforeCommon.targets b/src/Directory.BeforeCommon.targets
index 81b11a5b4ed..e238270ae6a 100644
--- a/src/Directory.BeforeCommon.targets
+++ b/src/Directory.BeforeCommon.targets
@@ -82,7 +82,7 @@
true
- $(DefineConstants);RUNTIME_TYPE_NETCORE
+ $(DefineConstants);RUNTIME_TYPE_NETCORE;FEATURE_FASTSPAN
diff --git a/src/Framework/NativeMethods.cs b/src/Framework/NativeMethods.cs
index 88f24171f30..162a6e7e7bb 100644
--- a/src/Framework/NativeMethods.cs
+++ b/src/Framework/NativeMethods.cs
@@ -716,7 +716,7 @@ internal static bool IsMono
///
/// Gets a flag indicating if we are running under some version of Windows
///
-#if NET5_0_OR_GREATER
+#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatformGuard("windows")]
#endif
internal static bool IsWindows
diff --git a/src/StringTools/InternableString.cs b/src/StringTools/InternableString.cs
index 7779d16e82d..f04d2a9e931 100644
--- a/src/StringTools/InternableString.cs
+++ b/src/StringTools/InternableString.cs
@@ -96,7 +96,7 @@ public bool MoveNext()
///
private readonly ReadOnlySpan _inlineSpan;
-#if RUNTIME_TYPE_NETCORE
+#if FEATURE_FASTSPAN
///
/// .NET Core does not keep a reference to the containing object in . In particular,
/// it cannot recover the string if the span represents one. We have to hold the reference separately to be able to
@@ -122,7 +122,7 @@ internal InternableString(ReadOnlySpan span)
_inlineSpan = span;
_spans = null;
Length = span.Length;
-#if RUNTIME_TYPE_NETCORE
+#if FEATURE_FASTSPAN
_inlineSpanString = null;
#endif
}
@@ -141,7 +141,7 @@ internal InternableString(string str)
_inlineSpan = str.AsSpan();
_spans = null;
Length = str.Length;
-#if RUNTIME_TYPE_NETCORE
+#if FEATURE_FASTSPAN
_inlineSpanString = str;
#endif
}
@@ -154,7 +154,7 @@ internal InternableString(SpanBasedStringBuilder stringBuilder)
_inlineSpan = default(ReadOnlySpan);
_spans = stringBuilder.Spans;
Length = stringBuilder.Length;
-#if RUNTIME_TYPE_NETCORE
+#if FEATURE_FASTSPAN
_inlineSpanString = null;
#endif
}
@@ -220,7 +220,7 @@ public unsafe string ExpensiveConvertToString()
// Special case: if we hold just one string, we can directly return it.
if (_inlineSpan.Length == Length)
{
-#if RUNTIME_TYPE_NETCORE
+#if FEATURE_FASTSPAN
if (_inlineSpanString != null)
{
return _inlineSpanString;
From c9362f3198a22838d5580d789fb7736c1bc7748c Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 4 Feb 2022 15:16:20 -0800
Subject: [PATCH 35/57] Log an error if SignFile is called from a non-windows
machine
---
src/Framework/NativeMethods.cs | 2 +-
src/Tasks/Resources/Strings.resx | 4 ++++
src/Tasks/Resources/xlf/Strings.cs.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.de.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.es.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.fr.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.it.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.ja.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.ko.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.pl.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.pt-BR.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.ru.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.tr.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.zh-Hans.xlf | 5 +++++
src/Tasks/Resources/xlf/Strings.zh-Hant.xlf | 5 +++++
src/Tasks/SignFile.cs | 11 +++++------
16 files changed, 75 insertions(+), 7 deletions(-)
diff --git a/src/Framework/NativeMethods.cs b/src/Framework/NativeMethods.cs
index 162a6e7e7bb..5d91bb1bb40 100644
--- a/src/Framework/NativeMethods.cs
+++ b/src/Framework/NativeMethods.cs
@@ -716,7 +716,7 @@ internal static bool IsMono
///
/// Gets a flag indicating if we are running under some version of Windows
///
-#if RUNTIME_TYPE_NETCORE
+#if RUNTIME_TYPE_NETCORE && NET5_0_OR_GREATER
[SupportedOSPlatformGuard("windows")]
#endif
internal static bool IsWindows
diff --git a/src/Tasks/Resources/Strings.resx b/src/Tasks/Resources/Strings.resx
index 07b5097294d..1f49848a025 100644
--- a/src/Tasks/Resources/Strings.resx
+++ b/src/Tasks/Resources/Strings.resx
@@ -571,6 +571,10 @@
MSB3094: "{2}" refers to {0} item(s), and "{3}" refers to {1} item(s). They must have the same number of items.
{StrBegin="MSB3094: "}
+
+ MSB3096: Task "{0}" is only supported on Windows devices.
+ {StrBegin="MSB3096: "}
+
+
+
false
diff --git a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
index 631db0a0bd9..a4ad3eb94c2 100644
--- a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
+++ b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
@@ -17,6 +17,11 @@
using System.Xml.XPath;
using System.Xml.Xsl;
using Microsoft.Build.Shared.FileSystem;
+#if RUNTIME_TYPE_NETCORE
+using System.Runtime.Versioning;
+#else
+using Microsoft.Build.Framework;
+#endif
#nullable disable
@@ -28,6 +33,7 @@ namespace Microsoft.Build.Tasks.Deployment.Bootstrapper
[ComVisible(true)]
[Guid("1D9FE38A-0226-4b95-9C6B-6DFFA2236270")]
[ClassInterface(ClassInterfaceType.None)]
+ [SupportedOSPlatform("windows")]
public class BootstrapperBuilder : IBootstrapperBuilder
{
private static readonly bool s_logging = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("VSPLOG"));
@@ -76,7 +82,7 @@ public class BootstrapperBuilder : IBootstrapperBuilder
///
public BootstrapperBuilder()
{
- _path = NativeMethodsShared.IsWindows ? Util.DefaultPath : string.Empty;
+ _path = Util.DefaultPath;
}
///
@@ -85,7 +91,7 @@ public BootstrapperBuilder()
/// The version of Visual Studio that is used to build this bootstrapper.
public BootstrapperBuilder(string visualStudioVersion)
{
- _path = NativeMethodsShared.IsWindows ? Util.GetDefaultPath(visualStudioVersion) : string.Empty;
+ _path = Util.GetDefaultPath(visualStudioVersion);
}
#region IBootstrapperBuilder Members
@@ -447,10 +453,7 @@ public string[] GetOutputFolders(string[] productCodes, string culture, string f
BuildPackages(settings, null, null, files, null);
List packagePaths = new List() { invariantPath };
- if (NativeMethodsShared.IsWindows)
- {
- packagePaths.AddRange(Util.AdditionalPackagePaths.Select(p => Util.AddTrailingChar(p.ToLowerInvariant(), System.IO.Path.DirectorySeparatorChar)));
- }
+ packagePaths.AddRange(Util.AdditionalPackagePaths.Select(p => Util.AddTrailingChar(p.ToLowerInvariant(), System.IO.Path.DirectorySeparatorChar)));
foreach (string file in files)
{
@@ -594,10 +597,7 @@ private void RefreshProducts()
XmlElement rootElement = _document.CreateElement("Products", BOOTSTRAPPER_NAMESPACE);
List packagePaths = new List() { PackagePath };
- if (NativeMethodsShared.IsWindows)
- {
- packagePaths.AddRange(Util.AdditionalPackagePaths);
- }
+ packagePaths.AddRange(Util.AdditionalPackagePaths);
foreach (string packagePath in packagePaths)
{
diff --git a/src/Tasks/BootstrapperUtil/Util.cs b/src/Tasks/BootstrapperUtil/Util.cs
index 819f4f53edf..bd46c5ce5cc 100644
--- a/src/Tasks/BootstrapperUtil/Util.cs
+++ b/src/Tasks/BootstrapperUtil/Util.cs
@@ -10,6 +10,9 @@
#endif
using Microsoft.Build.Shared;
using Microsoft.Win32;
+#if NETFRAMEWORK
+using Microsoft.Build.Framework;
+#endif
#nullable disable
@@ -78,9 +81,7 @@ public static CultureInfo GetCultureInfoFromString(string cultureName)
public static CultureInfo DefaultCultureInfo => System.Threading.Thread.CurrentThread.CurrentUICulture;
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
// This is the 4.0 property and will always point to the Dev10 registry key so that we don't break backwards compatibility.
// Applications relying on 4.5 will need to use the new method that is introduced in 4.5.
public static string DefaultPath
@@ -108,9 +109,7 @@ public static string DefaultPath
}
}
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
// A new method in 4.5 to get the default path for bootstrapper packages.
// This method is not going to cache the path as it could be different depending on the Visual Studio version.
public static string GetDefaultPath(string visualStudioVersion)
@@ -162,9 +161,7 @@ public static string GetDefaultPath(string visualStudioVersion)
return Directory.GetCurrentDirectory();
}
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
// Gets the list of additional paths to inspect for packages as defined in the registry
public static List AdditionalPackagePaths
{
@@ -214,9 +211,7 @@ public static List AdditionalPackagePaths
}
}
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
private static string ReadRegistryString(RegistryKey key, string path, string registryValue)
{
RegistryKey subKey = key.OpenSubKey(path, false);
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index 01c304b5ca2..6aa90907dcd 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -148,9 +148,9 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
}
catch (HttpRequestException e)
{
- // HttpRequestException does not have the status code so its wrapped and thrown here so that later on we can determine
- // if a retry is possible based on the status code
#if RUNTIME_TYPE_NETCORE
+ // MSBuild History: CustomHttpRequestException was created as a wrapper over HttpRequestException
+ // so it could include the StatusCode. As of net5.0, the statuscode is now in HttpRequestException.
throw new HttpRequestException(e.Message, e.InnerException, response.StatusCode);
#else
throw new CustomHttpRequestException(e.Message, e.InnerException, response.StatusCode);
diff --git a/src/Tasks/ManifestUtil/ComImporter.cs b/src/Tasks/ManifestUtil/ComImporter.cs
index 99ddb9dfe04..be9ab0c1b42 100644
--- a/src/Tasks/ManifestUtil/ComImporter.cs
+++ b/src/Tasks/ManifestUtil/ComImporter.cs
@@ -12,13 +12,15 @@
using System.Runtime.Versioning;
#endif
+#if NETFRAMEWORK
+using Microsoft.Build.Framework;
+#endif
+
#nullable disable
namespace Microsoft.Build.Tasks.Deployment.ManifestUtilities
{
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
internal class ComImporter
{
private readonly OutputMessageCollection _outputMessages;
diff --git a/src/Tasks/ManifestUtil/FileReference.cs b/src/Tasks/ManifestUtil/FileReference.cs
index 3f62edaecc5..dcd3e09f74e 100644
--- a/src/Tasks/ManifestUtil/FileReference.cs
+++ b/src/Tasks/ManifestUtil/FileReference.cs
@@ -11,6 +11,10 @@
using System.Text;
using System.Xml.Serialization;
+#if NETFRAMEWORK
+using Microsoft.Build.Framework;
+#endif
+
#nullable disable
namespace Microsoft.Build.Tasks.Deployment.ManifestUtilities
@@ -47,9 +51,7 @@ public FileReference(string path) : base(path)
[XmlIgnore]
public ComClass[] ComClasses => _comClasses;
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
internal bool ImportComComponent(string path, OutputMessageCollection outputMessages, string outputDisplayName)
{
var importer = new ComImporter(path, outputMessages, outputDisplayName);
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index 1f9f5c18a8e..3bcadaa14fd 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -493,9 +493,7 @@ public static PermissionSet XmlToPermissionSet(XmlElement element)
/// Hexadecimal string that contains the SHA-1 hash of the certificate.
/// URL that specifies an address of a time stamping server.
/// Path of the file to sign with the certificate.
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
public static void SignFile(string certThumbprint, Uri timestampUrl, string path)
{
SignFile(certThumbprint, timestampUrl, path, null, null);
@@ -508,9 +506,7 @@ public static void SignFile(string certThumbprint, Uri timestampUrl, string path
/// URL that specifies an address of a time stamping server.
/// Path of the file to sign with the certificate.
/// Version of the .NET Framework for the target.
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
public static void SignFile(string certThumbprint,
Uri timestampUrl,
string path,
@@ -527,9 +523,7 @@ public static void SignFile(string certThumbprint,
/// Path of the file to sign with the certificate.
/// Version of the .NET Framework for the target.
/// .NET Framework identifier for the target.
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
public static void SignFile(string certThumbprint,
Uri timestampUrl,
string path,
@@ -548,9 +542,7 @@ public static void SignFile(string certThumbprint,
/// Version of the .NET Framework for the target.
/// .NET Framework identifier for the target.
/// Disallow fallback to legacy timestamping when RFC3161 timestamping fails during manifest signing
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
public static void SignFile(string certThumbprint,
Uri timestampUrl,
string path,
@@ -609,9 +601,7 @@ public static void SignFile(string certThumbprint,
/// URL that specifies an address of a time stamping server.
/// Path of the file to sign with the certificate.
/// This function is only for signing a manifest, not a PE file.
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
public static void SignFile(string certPath, SecureString certPassword, Uri timestampUrl, string path)
{
X509Certificate2 cert = new X509Certificate2(certPath, certPassword, X509KeyStorageFlags.PersistKeySet);
@@ -636,9 +626,7 @@ private static bool UseSha256Algorithm(X509Certificate2 cert)
/// Path of the file to sign with the certificate.
/// This function can only sign a PE file if the X509Certificate2 parameter represents a certificate in the
/// current user's personal certificate store.
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
public static void SignFile(X509Certificate2 cert, Uri timestampUrl, string path)
{
// setup resources
@@ -646,9 +634,7 @@ public static void SignFile(X509Certificate2 cert, Uri timestampUrl, string path
SignFileInternal(cert, timestampUrl, path, true, resources);
}
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
private static void SignFileInternal(X509Certificate2 cert,
Uri timestampUrl,
string path,
@@ -912,9 +898,7 @@ private static bool IsCertInStore(X509Certificate2 cert)
return false;
}
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatformAttribute("windows")]
-#endif
+ [SupportedOSPlatform("windows")]
private static string GetVersionIndependentToolPath(string toolName)
{
const string versionIndependentToolKeyName = @"Software\Microsoft\ClickOnce\SignTool";
diff --git a/src/Tasks/ManifestUtil/Util.cs b/src/Tasks/ManifestUtil/Util.cs
index 20018c9c9f7..ed7a00c9229 100644
--- a/src/Tasks/ManifestUtil/Util.cs
+++ b/src/Tasks/ManifestUtil/Util.cs
@@ -253,9 +253,7 @@ private static string GetLogPath()
return logPath;
}
-#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
-#endif
public static string GetRegisteredOrganization()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false);
diff --git a/src/Tasks/ManifestUtil/mansign2.cs b/src/Tasks/ManifestUtil/mansign2.cs
index 998f93517a1..43d4683aee9 100644
--- a/src/Tasks/ManifestUtil/mansign2.cs
+++ b/src/Tasks/ManifestUtil/mansign2.cs
@@ -15,6 +15,8 @@
#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
+#else
+using Microsoft.Build.Framework;
#endif
using _FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
@@ -298,6 +300,7 @@ public override XmlElement GetIdElement(XmlDocument document, string idValue)
}
}
+ [SupportedOSPlatform("windows")]
internal class SignedCmiManifest2
{
private XmlDocument _manifestDom = null;
@@ -317,17 +320,12 @@ internal SignedCmiManifest2(XmlDocument manifestDom, bool useSha256)
_manifestDom = manifestDom ?? throw new ArgumentNullException(nameof(manifestDom));
_useSha256 = useSha256;
}
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
+
internal void Sign(CmiManifestSigner2 signer)
{
Sign(signer, null);
}
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
internal void Sign(CmiManifestSigner2 signer, string timeStampUrl, bool disallowMansignTimestampFallback = false)
{
// Reset signer infos.
@@ -460,9 +458,6 @@ private static void RemoveExistingSignature(XmlDocument manifestDom)
/// Whether to use sha256
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Cryptographic.Standard", "CA5358:RSAProviderNeeds2048bitKey", Justification = "SHA1 is retained for compatibility reasons as an option in VisualStudio signing page and consequently in the trust manager, default is SHA2.")]
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
internal static RSACryptoServiceProvider GetFixedRSACryptoServiceProvider(RSACryptoServiceProvider oldCsp, bool useSha256)
{
if (!useSha256)
@@ -491,9 +486,6 @@ internal static RSACryptoServiceProvider GetFixedRSACryptoServiceProvider(RSACry
return fixedRsa;
}
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
private static void ReplacePublicKeyToken(XmlDocument manifestDom, AsymmetricAlgorithm snKey, bool useSha256)
{
// Make sure we can find the publicKeyToken attribute.
@@ -691,9 +683,6 @@ private static XmlDocument CreateLicenseDom(CmiManifestSigner2 signer, XmlElemen
return licenseDom;
}
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
private static void AuthenticodeSignLicenseDom(XmlDocument licenseDom, CmiManifestSigner2 signer, string timeStampUrl, bool useSha256, bool disallowMansignTimestampFallback)
{
// Make sure it is RSA, as this is the only one Fusion will support.
@@ -912,9 +901,6 @@ private static void TimestampSignedLicenseDom(XmlDocument licenseDom, string tim
signatureNode.AppendChild(dsObject);
}
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
private static void StrongNameSignManifestDom(XmlDocument manifestDom, XmlDocument licenseDom, CmiManifestSigner2 signer, bool useSha256)
{
RSA snKey = signer.StrongNameKey as RSA;
@@ -1227,6 +1213,7 @@ internal AsymmetricAlgorithm PublicKey
}
}
+ [SupportedOSPlatform("windows")]
internal class CmiAuthenticodeSignerInfo
{
private int _error = 0;
@@ -1244,9 +1231,6 @@ internal CmiAuthenticodeSignerInfo(int errorCode)
_error = errorCode;
}
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
internal CmiAuthenticodeSignerInfo(Win32.AXL_SIGNER_INFO signerInfo,
Win32.AXL_TIMESTAMPER_INFO timestamperInfo)
{
@@ -1356,6 +1340,7 @@ internal X509Chain SignerChain
}
}
+ [SupportedOSPlatform("windows")]
internal class CmiAuthenticodeTimestamperInfo
{
private int _error = 0;
@@ -1365,9 +1350,6 @@ internal class CmiAuthenticodeTimestamperInfo
private CmiAuthenticodeTimestamperInfo() { }
-#if RUNTIME_TYPE_NETCORE
- [SupportedOSPlatform("windows")]
-#endif
internal CmiAuthenticodeTimestamperInfo(Win32.AXL_TIMESTAMPER_INFO timestamperInfo)
{
_error = (int)timestamperInfo.dwError;
diff --git a/src/Tasks/Resources/Strings.resx b/src/Tasks/Resources/Strings.resx
index 1f49848a025..d0dd9311e15 100644
--- a/src/Tasks/Resources/Strings.resx
+++ b/src/Tasks/Resources/Strings.resx
@@ -572,7 +572,7 @@
{StrBegin="MSB3094: "}
- MSB3096: Task "{0}" is only supported on Windows devices.
+ MSB3096: Task "{0}" is only supported when building on Windows.
{StrBegin="MSB3096: "}
-
-
- [2.0.3]
-
-
+
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index 6aa90907dcd..537d6d7b56a 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -185,11 +185,11 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
{
Log.LogMessageFromResources(MessageImportance.High, "DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength);
+ using (Stream responseStream = await response.Content.ReadAsStreamAsync(
#if RUNTIME_TYPE_NETCORE
- using (Stream responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false))
-#else
- using (Stream responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
+ cancellationToken
#endif
+ ).ConfigureAwait(false))
{
await responseStream.CopyToAsync(target, 1024, cancellationToken).ConfigureAwait(false);
}
From f253f5a81ddd19a11889e2ab03eec8486cb7dd2a Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 8 Feb 2022 16:07:14 -0800
Subject: [PATCH 40/57] Create SupportedOSPlatform type for framework and
ns2.0. Remove now-unnecessary preprocessor directives
---
src/Framework/NativeMethods.cs | 19 -------------
src/Framework/SupportedOSPlatform.cs | 27 +++++++++++++++++++
src/MSBuildTaskHost/MSBuildTaskHost.csproj | 3 +++
.../BootstrapperUtil/BootstrapperBuilder.cs | 4 ---
src/Tasks/BootstrapperUtil/Util.cs | 5 ----
src/Tasks/ManifestUtil/ComImporter.cs | 6 +----
src/Tasks/ManifestUtil/FileReference.cs | 6 -----
src/Tasks/ManifestUtil/SecurityUtil.cs | 6 ++---
src/Tasks/ManifestUtil/Util.cs | 2 --
src/Tasks/ManifestUtil/mansign2.cs | 5 ----
src/Tasks/NativeMethods.cs | 17 +++++++-----
11 files changed, 44 insertions(+), 56 deletions(-)
create mode 100644 src/Framework/SupportedOSPlatform.cs
diff --git a/src/Framework/NativeMethods.cs b/src/Framework/NativeMethods.cs
index 608005241d2..a838e0dc9a6 100644
--- a/src/Framework/NativeMethods.cs
+++ b/src/Framework/NativeMethods.cs
@@ -9,9 +9,7 @@
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
-#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
-#endif
using System.Text;
using System.Threading;
@@ -25,23 +23,6 @@
namespace Microsoft.Build.Framework;
-#if NETFRAMEWORK || NETSTANDARD2_0
-[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)]
-internal class SupportedOSPlatformGuard : Attribute
-{
- internal SupportedOSPlatformGuard(string platformName)
- {
- }
-}
-[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Class)]
-internal class SupportedOSPlatform : Attribute
-{
- internal SupportedOSPlatform(string platformName)
- {
- }
-}
-#endif
-
internal static class NativeMethods
{
#region Constants
diff --git a/src/Framework/SupportedOSPlatform.cs b/src/Framework/SupportedOSPlatform.cs
new file mode 100644
index 00000000000..71deb58019b
--- /dev/null
+++ b/src/Framework/SupportedOSPlatform.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#if !NET5_0_OR_GREATER
+namespace System.Runtime.Versioning
+{
+ ///
+ /// SupportedOSPlatform is a net5.0+ Attribute.
+ /// Create the same type only in full-framework and netstandard2.0 builds
+ /// to prevent many #if RUNTIME_TYPE_NETCORE checks.
+ ///
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)]
+ internal class SupportedOSPlatformGuard : Attribute
+ {
+ internal SupportedOSPlatformGuard(string platformName)
+ {
+ }
+ }
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Class)]
+ internal class SupportedOSPlatform : Attribute
+ {
+ internal SupportedOSPlatform(string platformName)
+ {
+ }
+ }
+}
+#endif
diff --git a/src/MSBuildTaskHost/MSBuildTaskHost.csproj b/src/MSBuildTaskHost/MSBuildTaskHost.csproj
index f56435ec284..becff23674d 100644
--- a/src/MSBuildTaskHost/MSBuildTaskHost.csproj
+++ b/src/MSBuildTaskHost/MSBuildTaskHost.csproj
@@ -142,6 +142,9 @@
StringBuilderCache.cs
+
+ SupportedOSAttribute.cs
+
TaskEngineAssemblyResolver.cs
diff --git a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
index a4ad3eb94c2..8b0ffffed17 100644
--- a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
+++ b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
@@ -17,11 +17,7 @@
using System.Xml.XPath;
using System.Xml.Xsl;
using Microsoft.Build.Shared.FileSystem;
-#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
-#else
-using Microsoft.Build.Framework;
-#endif
#nullable disable
diff --git a/src/Tasks/BootstrapperUtil/Util.cs b/src/Tasks/BootstrapperUtil/Util.cs
index bd46c5ce5cc..d62c8247070 100644
--- a/src/Tasks/BootstrapperUtil/Util.cs
+++ b/src/Tasks/BootstrapperUtil/Util.cs
@@ -5,14 +5,9 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
-#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
-#endif
using Microsoft.Build.Shared;
using Microsoft.Win32;
-#if NETFRAMEWORK
-using Microsoft.Build.Framework;
-#endif
#nullable disable
diff --git a/src/Tasks/ManifestUtil/ComImporter.cs b/src/Tasks/ManifestUtil/ComImporter.cs
index be9ab0c1b42..30b34cc10fe 100644
--- a/src/Tasks/ManifestUtil/ComImporter.cs
+++ b/src/Tasks/ManifestUtil/ComImporter.cs
@@ -7,13 +7,9 @@
using System.Globalization;
using System.Resources;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
#if RUNTIME_TYPE_NETCORE
using System.Runtime.InteropServices.ComTypes;
-using System.Runtime.Versioning;
-#endif
-
-#if NETFRAMEWORK
-using Microsoft.Build.Framework;
#endif
#nullable disable
diff --git a/src/Tasks/ManifestUtil/FileReference.cs b/src/Tasks/ManifestUtil/FileReference.cs
index dcd3e09f74e..e13dad0af4f 100644
--- a/src/Tasks/ManifestUtil/FileReference.cs
+++ b/src/Tasks/ManifestUtil/FileReference.cs
@@ -5,16 +5,10 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
-#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
-#endif
using System.Text;
using System.Xml.Serialization;
-#if NETFRAMEWORK
-using Microsoft.Build.Framework;
-#endif
-
#nullable disable
namespace Microsoft.Build.Tasks.Deployment.ManifestUtilities
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index 3bcadaa14fd..2ab1d221d09 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -1,9 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#if !RUNTIME_TYPE_NETCORE
-using Microsoft.Build.Framework;
-#endif
using Microsoft.Build.Utilities;
using Microsoft.Win32;
using System;
@@ -33,6 +30,9 @@
using System.Text;
using System.Xml;
using Microsoft.Build.Shared.FileSystem;
+#if !NET5_0_OR_GREATER
+using Microsoft.Build.Framework;
+#endif
#nullable disable
diff --git a/src/Tasks/ManifestUtil/Util.cs b/src/Tasks/ManifestUtil/Util.cs
index ed7a00c9229..56ba265c495 100644
--- a/src/Tasks/ManifestUtil/Util.cs
+++ b/src/Tasks/ManifestUtil/Util.cs
@@ -13,9 +13,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
-#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
-#endif
using System.Security;
using System.Security.Cryptography;
using System.Text;
diff --git a/src/Tasks/ManifestUtil/mansign2.cs b/src/Tasks/ManifestUtil/mansign2.cs
index 43d4683aee9..8d0d9fbf267 100644
--- a/src/Tasks/ManifestUtil/mansign2.cs
+++ b/src/Tasks/ManifestUtil/mansign2.cs
@@ -12,12 +12,7 @@
using System.Text;
using System.Xml;
using System.Runtime.InteropServices;
-
-#if RUNTIME_TYPE_NETCORE
using System.Runtime.Versioning;
-#else
-using Microsoft.Build.Framework;
-#endif
using _FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
diff --git a/src/Tasks/NativeMethods.cs b/src/Tasks/NativeMethods.cs
index 45bc7d9faad..94ec0181eb5 100644
--- a/src/Tasks/NativeMethods.cs
+++ b/src/Tasks/NativeMethods.cs
@@ -3,9 +3,12 @@
using System;
using System.IO;
+using System.Runtime.InteropServices;
+using Microsoft.Build.Shared.FileSystem;
+
+#if FEATURE_COM_INTEROP
using System.Text;
using System.Reflection;
-using System.Runtime.InteropServices;
using Microsoft.Build.Shared;
using System.Collections.Generic;
using System.Collections;
@@ -13,7 +16,7 @@
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text.RegularExpressions;
-using Microsoft.Build.Shared.FileSystem;
+#endif
#nullable disable
@@ -522,7 +525,7 @@ internal enum SymbolicLink
///
internal static class NativeMethods
{
- #region Constants
+#region Constants
internal static readonly IntPtr NullPtr = IntPtr.Zero;
internal static readonly IntPtr InvalidIntPtr = new IntPtr(-1);
@@ -627,9 +630,9 @@ internal enum MoveFileFlags
MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020
}
- #endregion
+#endregion
- #region NT header stuff
+#region NT header stuff
internal const uint IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10b;
internal const uint IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x20b;
@@ -780,9 +783,9 @@ internal struct CRYPTOAPI_BLOB
internal IntPtr pbData;
}
- #endregion
+#endregion
- #region PInvoke
+#region PInvoke
private const string Crypt32DLL = "crypt32.dll";
private const string Advapi32DLL = "advapi32.dll";
#if !RUNTIME_TYPE_NETCORE
From ffb3d6b36fb4494fe5eb8dc8bfb0f19bc2cf085d Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 8 Feb 2022 16:17:03 -0800
Subject: [PATCH 41/57] Code cleanup. Use full paths for RuntimeIdentifierGraph
and Microsoft.NETCoreSdk.BundledVersions.props
---
src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 4 ++--
src/MSBuild/MSBuild.csproj | 1 -
src/MSBuildTaskHost/MSBuildTaskHost.csproj | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
index 3c30cb43c58..8220910cf74 100644
--- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
+++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
@@ -20,7 +20,7 @@
-
+
@@ -36,7 +36,7 @@
-
+
diff --git a/src/MSBuild/MSBuild.csproj b/src/MSBuild/MSBuild.csproj
index 75c26d786e1..803083dd1fc 100644
--- a/src/MSBuild/MSBuild.csproj
+++ b/src/MSBuild/MSBuild.csproj
@@ -211,7 +211,6 @@
-
diff --git a/src/MSBuildTaskHost/MSBuildTaskHost.csproj b/src/MSBuildTaskHost/MSBuildTaskHost.csproj
index becff23674d..e7dba840e1a 100644
--- a/src/MSBuildTaskHost/MSBuildTaskHost.csproj
+++ b/src/MSBuildTaskHost/MSBuildTaskHost.csproj
@@ -143,7 +143,7 @@
StringBuilderCache.cs
- SupportedOSAttribute.cs
+ SupportedOSPlatform.cs
TaskEngineAssemblyResolver.cs
From a47d737e062ee1470f1941a81031ae66735aab46 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 9 Feb 2022 16:53:51 -0800
Subject: [PATCH 42/57] Libraries build as ns2.0 again. NuGet package contains
ref assemblies in `ref/netstandard2.0/`
---
src/Directory.Build.props | 21 ++++++++++++++++---
src/Directory.Build.targets | 10 +++++++++
.../Microsoft.Build.Framework.csproj | 2 +-
src/StringTools/StringTools.csproj | 7 +++++--
src/Tasks/ManifestUtil/SecurityUtil.cs | 4 +---
src/Tasks/Microsoft.Build.Tasks.csproj | 9 ++++----
src/Tasks/SignFile.cs | 2 +-
.../Microsoft.Build.Utilities.csproj | 2 +-
8 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index cc8bf13d120..793642ee89e 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -27,9 +27,9 @@
AnyCPU;x64
- $(FullFrameworkTFM);net6.0
- net6.0
- $(FullFrameworkTFM)
+ $(FullFrameworkTFM);net6.0;netstandard2.0
+ net6.0;netstandard2.0
+ $(FullFrameworkTFM);netstandard2.0
AnyCPU
@@ -75,8 +75,23 @@
+
true
false
false
+ $(TargetsForTfmSpecificContentInPackage);ShipRefAssembliesToNuGetPackage
+ false
+
+ $(NoWarn);NU5131
+
+
+
+
+
+ ref/$(TargetFramework)
+
+
+
+
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets
index 2dbbe6d8ace..0355f57ec5b 100644
--- a/src/Directory.Build.targets
+++ b/src/Directory.Build.targets
@@ -112,6 +112,16 @@
+
+
+
+
+
+
+
diff --git a/src/Framework/Microsoft.Build.Framework.csproj b/src/Framework/Microsoft.Build.Framework.csproj
index 2e5aec36081..1925d86c476 100644
--- a/src/Framework/Microsoft.Build.Framework.csproj
+++ b/src/Framework/Microsoft.Build.Framework.csproj
@@ -1,6 +1,6 @@
- $(LibraryTargetFrameworks);netstandard2.0
+ $(LibraryTargetFrameworks)
true
true
true
diff --git a/src/StringTools/StringTools.csproj b/src/StringTools/StringTools.csproj
index faddef78f18..831b662a628 100644
--- a/src/StringTools/StringTools.csproj
+++ b/src/StringTools/StringTools.csproj
@@ -1,7 +1,7 @@
- $(LibraryTargetFrameworks);netstandard2.0
- $(LibraryTargetFrameworks);net35;netstandard2.0
+ $(LibraryTargetFrameworks)
+ $(LibraryTargetFrameworks);net35
AnyCPU
true
true
@@ -43,4 +43,7 @@
+
+
+
diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs
index 2ab1d221d09..986370caf84 100644
--- a/src/Tasks/ManifestUtil/SecurityUtil.cs
+++ b/src/Tasks/ManifestUtil/SecurityUtil.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Win32;
using System;
@@ -30,9 +31,6 @@
using System.Text;
using System.Xml;
using Microsoft.Build.Shared.FileSystem;
-#if !NET5_0_OR_GREATER
-using Microsoft.Build.Framework;
-#endif
#nullable disable
diff --git a/src/Tasks/Microsoft.Build.Tasks.csproj b/src/Tasks/Microsoft.Build.Tasks.csproj
index 1e8d82aa831..b8b4709cf6f 100644
--- a/src/Tasks/Microsoft.Build.Tasks.csproj
+++ b/src/Tasks/Microsoft.Build.Tasks.csproj
@@ -957,11 +957,10 @@
-
-
-
-
-
+
+
+
+
diff --git a/src/Tasks/SignFile.cs b/src/Tasks/SignFile.cs
index 3845672f21e..52698db83b4 100644
--- a/src/Tasks/SignFile.cs
+++ b/src/Tasks/SignFile.cs
@@ -44,7 +44,7 @@ public override bool Execute()
{
if (!NativeMethodsShared.IsWindows)
{
- Log.LogErrorWithCodeFromResources("General.TaskRequiresWindows", "SignFile");
+ Log.LogErrorWithCodeFromResources("General.TaskRequiresWindows", nameof(SignFile));
return false;
}
try
diff --git a/src/Utilities/Microsoft.Build.Utilities.csproj b/src/Utilities/Microsoft.Build.Utilities.csproj
index 0c6b937eb32..ee29f5585f6 100644
--- a/src/Utilities/Microsoft.Build.Utilities.csproj
+++ b/src/Utilities/Microsoft.Build.Utilities.csproj
@@ -4,7 +4,7 @@
- $(LibraryTargetFrameworks);netstandard2.0
+ $(LibraryTargetFrameworks)
True
Microsoft.Build.Utilities
Microsoft.Build.Utilities.Core
From ca7b4879e0a4525f856788537b022bb893c4e6d4 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 9 Feb 2022 16:56:35 -0800
Subject: [PATCH 43/57] ns2.0 targets dont publish pdbs
---
src/Directory.Build.props | 1 +
src/Framework/Microsoft.Build.Framework.csproj | 4 ----
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 793642ee89e..05ca3fa9add 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -83,6 +83,7 @@
false
$(NoWarn);NU5131
+ false
diff --git a/src/Framework/Microsoft.Build.Framework.csproj b/src/Framework/Microsoft.Build.Framework.csproj
index 1925d86c476..df75564473e 100644
--- a/src/Framework/Microsoft.Build.Framework.csproj
+++ b/src/Framework/Microsoft.Build.Framework.csproj
@@ -22,10 +22,6 @@
-
- false
-
-
From ecfff474a8512678b647ce2c86acb7d4c9532190 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 10 Feb 2022 10:57:52 -0800
Subject: [PATCH 44/57] Remove unused target, redownload netstandard.library
for tests
---
src/Directory.Build.targets | 10 ----------
src/MSBuild/MSBuild.csproj | 8 ++++++++
src/Tasks/Microsoft.Build.Tasks.csproj | 4 ++--
src/Utilities/Microsoft.Build.Utilities.csproj | 4 ----
4 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets
index 0355f57ec5b..2dbbe6d8ace 100644
--- a/src/Directory.Build.targets
+++ b/src/Directory.Build.targets
@@ -112,16 +112,6 @@
-
-
-
-
-
-
-
diff --git a/src/MSBuild/MSBuild.csproj b/src/MSBuild/MSBuild.csproj
index 803083dd1fc..f363f605822 100644
--- a/src/MSBuild/MSBuild.csproj
+++ b/src/MSBuild/MSBuild.csproj
@@ -211,6 +211,14 @@
+
+
+
+ [2.0.3]
+
+
diff --git a/src/Tasks/Microsoft.Build.Tasks.csproj b/src/Tasks/Microsoft.Build.Tasks.csproj
index b8b4709cf6f..6a3ccbfc7e4 100644
--- a/src/Tasks/Microsoft.Build.Tasks.csproj
+++ b/src/Tasks/Microsoft.Build.Tasks.csproj
@@ -957,8 +957,8 @@
-
-
+
+
diff --git a/src/Utilities/Microsoft.Build.Utilities.csproj b/src/Utilities/Microsoft.Build.Utilities.csproj
index ee29f5585f6..5e5bcafb605 100644
--- a/src/Utilities/Microsoft.Build.Utilities.csproj
+++ b/src/Utilities/Microsoft.Build.Utilities.csproj
@@ -17,10 +17,6 @@
full
-
- false
-
-
From 7b90a534395effd0adb9415bcaf3210fae91e9ca Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 10 Feb 2022 12:19:22 -0800
Subject: [PATCH 45/57] Always nowarn NU5131
---
src/Directory.Build.props | 8 ++++++--
src/Framework/Microsoft.Build.Framework.csproj | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 05ca3fa9add..379e07452f6 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -15,6 +15,9 @@
true
+
+
+ $(NoWarn);NU5131
false
@@ -73,6 +76,9 @@
AnyCPU
+
+
+
@@ -81,8 +87,6 @@
false
$(TargetsForTfmSpecificContentInPackage);ShipRefAssembliesToNuGetPackage
false
-
- $(NoWarn);NU5131
false
diff --git a/src/Framework/Microsoft.Build.Framework.csproj b/src/Framework/Microsoft.Build.Framework.csproj
index df75564473e..5e0d9a48a53 100644
--- a/src/Framework/Microsoft.Build.Framework.csproj
+++ b/src/Framework/Microsoft.Build.Framework.csproj
@@ -15,7 +15,7 @@
an imported package. This suppression should be removed if/when the project is migrated to enable nullable
reference types.
-->
- $(NoWarn),CS8632
+ $(NoWarn);CS8632
From 0549c148eac82c31aa7bf680554ce9fb9e3632fd Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Thu, 10 Feb 2022 14:39:17 -0800
Subject: [PATCH 46/57] Prevent any version of GenerateManifest from running on
a non-windows machine
---
src/Tasks/GenerateApplicationManifest.cs | 10 ++++++++++
src/Tasks/GenerateDeploymentManifest.cs | 10 ++++++++++
src/Tasks/GenerateManifestBase.cs | 6 ++++++
src/Tasks/PublicAPI/net/PublicAPI.Unshipped.txt | 2 ++
.../PublicAPI/netstandard/PublicAPI.Unshipped.txt | 2 ++
5 files changed, 30 insertions(+)
diff --git a/src/Tasks/GenerateApplicationManifest.cs b/src/Tasks/GenerateApplicationManifest.cs
index b90bfe1002c..68501fce1da 100644
--- a/src/Tasks/GenerateApplicationManifest.cs
+++ b/src/Tasks/GenerateApplicationManifest.cs
@@ -108,6 +108,16 @@ public bool UseApplicationTrust
set => _useApplicationTrust = value;
}
+ public override bool Execute()
+ {
+ if (!NativeMethodsShared.IsWindows)
+ {
+ Log.LogErrorWithCodeFromResources("General.TaskRequiresWindows", nameof(GenerateApplicationManifest));
+ return false;
+ }
+ return base.Execute();
+ }
+
protected override Type GetObjectType()
{
return typeof(ApplicationManifest);
diff --git a/src/Tasks/GenerateDeploymentManifest.cs b/src/Tasks/GenerateDeploymentManifest.cs
index a9e8fae1d8b..c5492033e97 100644
--- a/src/Tasks/GenerateDeploymentManifest.cs
+++ b/src/Tasks/GenerateDeploymentManifest.cs
@@ -150,6 +150,16 @@ private bool BuildResolvedSettings(DeployManifest manifest)
return true;
}
+ public override bool Execute()
+ {
+ if (!NativeMethodsShared.IsWindows)
+ {
+ Log.LogErrorWithCodeFromResources("General.TaskRequiresWindows", nameof(GenerateDeploymentManifest));
+ return false;
+ }
+ return base.Execute();
+ }
+
protected override Type GetObjectType()
{
return typeof(DeployManifest);
diff --git a/src/Tasks/GenerateManifestBase.cs b/src/Tasks/GenerateManifestBase.cs
index 65ea58c62b0..ef8aed08163 100644
--- a/src/Tasks/GenerateManifestBase.cs
+++ b/src/Tasks/GenerateManifestBase.cs
@@ -272,6 +272,12 @@ private AssemblyIdentity CreateAssemblyIdentity(AssemblyIdentity baseIdentity, A
public override bool Execute()
{
+ if (!NativeMethodsShared.IsWindows)
+ {
+ Log.LogErrorWithCodeFromResources("General.TaskRequiresWindows", nameof(GenerateManifestBase));
+ return false;
+ }
+
bool success = true;
Type manifestType = GetObjectType();
diff --git a/src/Tasks/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Tasks/PublicAPI/net/PublicAPI.Unshipped.txt
index 78e394ce7bc..5f9ec5dc2a5 100644
--- a/src/Tasks/PublicAPI/net/PublicAPI.Unshipped.txt
+++ b/src/Tasks/PublicAPI/net/PublicAPI.Unshipped.txt
@@ -1,3 +1,5 @@
Microsoft.Build.Tasks.SignFile.DisallowMansignTimestampFallback.get -> bool
Microsoft.Build.Tasks.SignFile.DisallowMansignTimestampFallback.set -> void
+override Microsoft.Build.Tasks.GenerateApplicationManifest.Execute() -> bool
+override Microsoft.Build.Tasks.GenerateDeploymentManifest.Execute() -> bool
static Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(string certThumbprint, System.Uri timestampUrl, string path, string targetFrameworkVersion, string targetFrameworkIdentifier, bool disallowMansignTimestampFallback) -> void
diff --git a/src/Tasks/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Tasks/PublicAPI/netstandard/PublicAPI.Unshipped.txt
index 78e394ce7bc..5f9ec5dc2a5 100644
--- a/src/Tasks/PublicAPI/netstandard/PublicAPI.Unshipped.txt
+++ b/src/Tasks/PublicAPI/netstandard/PublicAPI.Unshipped.txt
@@ -1,3 +1,5 @@
Microsoft.Build.Tasks.SignFile.DisallowMansignTimestampFallback.get -> bool
Microsoft.Build.Tasks.SignFile.DisallowMansignTimestampFallback.set -> void
+override Microsoft.Build.Tasks.GenerateApplicationManifest.Execute() -> bool
+override Microsoft.Build.Tasks.GenerateDeploymentManifest.Execute() -> bool
static Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(string certThumbprint, System.Uri timestampUrl, string path, string targetFrameworkVersion, string targetFrameworkIdentifier, bool disallowMansignTimestampFallback) -> void
From 34a8b6daef819571860fec29ecbfb83078b85beb Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 11 Feb 2022 11:10:55 -0800
Subject: [PATCH 47/57] Code cleanup
---
src/Directory.Build.props | 10 ++++------
src/MSBuild/MSBuild.csproj | 3 +--
src/StringTools/StringTools.csproj | 6 ------
src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs | 1 -
src/Tasks/DownloadFile.cs | 1 -
5 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 379e07452f6..4fbd2ac5496 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -76,9 +76,6 @@
AnyCPU
-
-
-
@@ -87,16 +84,17 @@
false
$(TargetsForTfmSpecificContentInPackage);ShipRefAssembliesToNuGetPackage
false
+
+
false
-
-
+
+
ref/$(TargetFramework)
-
diff --git a/src/MSBuild/MSBuild.csproj b/src/MSBuild/MSBuild.csproj
index f363f605822..337e3260d18 100644
--- a/src/MSBuild/MSBuild.csproj
+++ b/src/MSBuild/MSBuild.csproj
@@ -211,8 +211,7 @@
-
diff --git a/src/StringTools/StringTools.csproj b/src/StringTools/StringTools.csproj
index 831b662a628..c574969b6a1 100644
--- a/src/StringTools/StringTools.csproj
+++ b/src/StringTools/StringTools.csproj
@@ -22,12 +22,6 @@
Microsoft.NET.StringTools.net35
-
-
-
- false
-
-
diff --git a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
index 8b0ffffed17..b8960252b8a 100644
--- a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
+++ b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs
@@ -594,7 +594,6 @@ private void RefreshProducts()
List packagePaths = new List() { PackagePath };
packagePaths.AddRange(Util.AdditionalPackagePaths);
-
foreach (string packagePath in packagePaths)
{
if (FileSystems.Default.DirectoryExists(packagePath))
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index 537d6d7b56a..3b834c15c6f 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -265,7 +265,6 @@ private static bool IsRetriable(Exception exception, out Exception actualExcepti
}
#endif
-
if (actualException is WebException webException)
{
// WebException is thrown when accessing the Content of the response
From 0bcaf194985158b6c8245346520e8208ee93824c Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 11 Feb 2022 11:43:59 -0800
Subject: [PATCH 48/57] Remove unneeded target. Fix whitespace in SignFile
---
src/StringTools/StringTools.csproj | 3 ---
src/Tasks/SignFile.cs | 1 -
2 files changed, 4 deletions(-)
diff --git a/src/StringTools/StringTools.csproj b/src/StringTools/StringTools.csproj
index c574969b6a1..15ac5335951 100644
--- a/src/StringTools/StringTools.csproj
+++ b/src/StringTools/StringTools.csproj
@@ -37,7 +37,4 @@
-
-
-
diff --git a/src/Tasks/SignFile.cs b/src/Tasks/SignFile.cs
index 52698db83b4..f98c16e6bf5 100644
--- a/src/Tasks/SignFile.cs
+++ b/src/Tasks/SignFile.cs
@@ -37,7 +37,6 @@ public SignFile()
public String TargetFrameworkVersion { get; set; }
public string TimestampUrl { get; set; }
-
public bool DisallowMansignTimestampFallback { get; set; } = false;
public override bool Execute()
From 2b00f97d4e6462fb69a1dd59ecc14d9ab0f04b04 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 11 Feb 2022 14:51:23 -0800
Subject: [PATCH 49/57] Ship all ref assemblies in ref/ in NuGet package root
---
src/Directory.Build.props | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 4fbd2ac5496..d6c6dbbdda8 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -76,6 +76,10 @@
AnyCPU
+
+ $(TargetsForTfmSpecificContentInPackage);ShipRefAssembliesToNuGetPackage
+
+
@@ -90,9 +94,13 @@
-
+
-
+
+ ref/$(TargetFramework)
+
+
+
ref/$(TargetFramework)
From 21a19753731d3824508ad523386e67eebb3e3dbc Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Fri, 11 Feb 2022 15:56:46 -0800
Subject: [PATCH 50/57] Use TargetRefPath instead of IntermediateRefAssembly.
Fix stale comment
---
src/Directory.Build.props | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index d6c6dbbdda8..497b198210a 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -93,10 +93,10 @@
false
-
+
-
+
ref/$(TargetFramework)
From f47d7397519cc3ae312ae47c906a670210359fcb Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 1 Mar 2022 10:48:10 -0800
Subject: [PATCH 51/57] [PR Feedback] Fix slash on PackagePath
---
src/Directory.Build.props | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 497b198210a..de2ef19eb31 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -97,11 +97,11 @@
- ref/$(TargetFramework)
+ ref\$(TargetFramework)
- ref/$(TargetFramework)
+ ref\$(TargetFramework)
From 7e50fa8e3eef6913984ec64d74ef6fb6ec23ba70 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 1 Mar 2022 10:50:16 -0800
Subject: [PATCH 52/57] [PR] Remove semicolon change for CS8632 to prevent a
merge conflict
---
src/Framework/Microsoft.Build.Framework.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Framework/Microsoft.Build.Framework.csproj b/src/Framework/Microsoft.Build.Framework.csproj
index 5e0d9a48a53..df75564473e 100644
--- a/src/Framework/Microsoft.Build.Framework.csproj
+++ b/src/Framework/Microsoft.Build.Framework.csproj
@@ -15,7 +15,7 @@
an imported package. This suppression should be removed if/when the project is migrated to enable nullable
reference types.
-->
- $(NoWarn);CS8632
+ $(NoWarn),CS8632
From 8771062d3c016c3f6841b952feaad9f1d0d38b89 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 1 Mar 2022 11:16:06 -0800
Subject: [PATCH 53/57] [PR] Check newer APIs using NET6_0_OR_GREATER. Updated
Framework readme
---
src/Framework/README.md | 2 +-
src/Framework/SupportedOSPlatform.cs | 2 +-
src/Tasks/DownloadFile.cs | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Framework/README.md b/src/Framework/README.md
index 40373c5dad8..1b72454f526 100644
--- a/src/Framework/README.md
+++ b/src/Framework/README.md
@@ -6,6 +6,6 @@ The items in this namespace are primarily base-level classes and interfaces shar
[`ITask`](https://docs.microsoft.com/dotnet/api/microsoft.build.framework.itask), and [`ILogger`](https://docs.microsoft.com/dotnet/api/microsoft.build.framework.ilogger).
### netstandard2.0 target
-The `netstandard2.0` target of this build is configured only to output ref assemblies, we do not ship the implementation assemblies. Please use the net6.0-targeted assemblies for .NET Core 6+ scenarios.
+The `netstandard2.0` target of this build is configured only to output reference assemblies; at runtime MSBuild will be `net6.0` or `net472`. Please use the `net6.0`-targeted assemblies for .NET Core 6+ scenarios.
For context, see https://github.com/dotnet/msbuild/pull/6148
\ No newline at end of file
diff --git a/src/Framework/SupportedOSPlatform.cs b/src/Framework/SupportedOSPlatform.cs
index 71deb58019b..8a50d7c82f0 100644
--- a/src/Framework/SupportedOSPlatform.cs
+++ b/src/Framework/SupportedOSPlatform.cs
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#if !NET5_0_OR_GREATER
+#if !NET6_0_OR_GREATER
namespace System.Runtime.Versioning
{
///
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index 3b834c15c6f..2e54c018c86 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -148,7 +148,7 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
}
catch (HttpRequestException e)
{
-#if RUNTIME_TYPE_NETCORE
+#if NET6_0_OR_GREATER
// MSBuild History: CustomHttpRequestException was created as a wrapper over HttpRequestException
// so it could include the StatusCode. As of net5.0, the statuscode is now in HttpRequestException.
throw new HttpRequestException(e.Message, e.InnerException, response.StatusCode);
@@ -186,7 +186,7 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
Log.LogMessageFromResources(MessageImportance.High, "DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength);
using (Stream responseStream = await response.Content.ReadAsStreamAsync(
-#if RUNTIME_TYPE_NETCORE
+#if NET6_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false))
@@ -241,7 +241,7 @@ private static bool IsRetriable(Exception exception, out Exception actualExcepti
}
}
-#if RUNTIME_TYPE_NETCORE
+#if NET6_0_OR_GREATER
// net5.0 included StatusCode in the HttpRequestException.
switch (httpRequestException.StatusCode)
{
@@ -310,7 +310,7 @@ private bool TryGetFileName(HttpResponseMessage response, out string filename)
return !String.IsNullOrWhiteSpace(filename);
}
-#if !RUNTIME_TYPE_NETCORE
+#if !NET6_0_OR_GREATER
///
/// Represents a wrapper around the that also contains the .
/// DEPRECATED as of net5.0, which included the StatusCode in the HttpRequestException class.
From 4c7ff53d17fc7ba67254d8813df379eba214e59b Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 1 Mar 2022 11:38:37 -0800
Subject: [PATCH 54/57] [PR] Use SupportedOSPlatform on
GenerateDeploymentManifest and GenerateApplicationManifest. Minor PR feedback
---
src/Tasks/GenerateApplicationManifest.cs | 6 ++++--
src/Tasks/GenerateDeploymentManifest.cs | 4 +++-
src/Tasks/ManifestUtil/ComImporter.cs | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/Tasks/GenerateApplicationManifest.cs b/src/Tasks/GenerateApplicationManifest.cs
index 68501fce1da..a6361b25472 100644
--- a/src/Tasks/GenerateApplicationManifest.cs
+++ b/src/Tasks/GenerateApplicationManifest.cs
@@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
+using System.Runtime.Versioning;
using System.Xml;
using Microsoft.Build.Framework;
@@ -17,6 +18,7 @@ namespace Microsoft.Build.Tasks
///
/// Generates an application manifest for ClickOnce projects.
///
+ [SupportedOSPlatform("windows")]
public sealed class GenerateApplicationManifest : GenerateManifestBase
{
private enum _ManifestType
@@ -229,7 +231,7 @@ private bool AddIsolatedComReferences(ApplicationManifest manifest)
name = Path.GetFileName(item.ItemSpec);
}
FileReference file = AddFileFromItem(item);
- if (NativeMethodsShared.IsWindows && !file.ImportComComponent(item.ItemSpec, manifest.OutputMessages, name))
+ if (!file.ImportComComponent(item.ItemSpec, manifest.OutputMessages, name))
{
success = false;
}
@@ -396,7 +398,7 @@ private bool BuildResolvedSettings(ApplicationManifest manifest)
}
else if (String.IsNullOrEmpty(manifest.Publisher))
{
- string org = NativeMethodsShared.IsWindows ? Util.GetRegisteredOrganization() : string.Empty;
+ string org = Util.GetRegisteredOrganization();
if (!String.IsNullOrEmpty(org))
{
manifest.Publisher = org;
diff --git a/src/Tasks/GenerateDeploymentManifest.cs b/src/Tasks/GenerateDeploymentManifest.cs
index c5492033e97..6867f27717b 100644
--- a/src/Tasks/GenerateDeploymentManifest.cs
+++ b/src/Tasks/GenerateDeploymentManifest.cs
@@ -5,6 +5,7 @@
using System.Diagnostics;
using System.IO;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
+using System.Runtime.Versioning;
#nullable disable
@@ -13,6 +14,7 @@ namespace Microsoft.Build.Tasks
///
/// Generates a deploy manifest for ClickOnce projects.
///
+ [SupportedOSPlatform("windows")]
public sealed class GenerateDeploymentManifest : GenerateManifestBase
{
private bool? _createDesktopShortcut;
@@ -141,7 +143,7 @@ private bool BuildResolvedSettings(DeployManifest manifest)
}
else if (String.IsNullOrEmpty(manifest.Publisher))
{
- string org = NativeMethodsShared.IsWindows ? Util.GetRegisteredOrganization() : string.Empty;
+ string org = Util.GetRegisteredOrganization();
manifest.Publisher = !String.IsNullOrEmpty(org) ? org : manifest.Product;
}
diff --git a/src/Tasks/ManifestUtil/ComImporter.cs b/src/Tasks/ManifestUtil/ComImporter.cs
index 30b34cc10fe..96a941a43e0 100644
--- a/src/Tasks/ManifestUtil/ComImporter.cs
+++ b/src/Tasks/ManifestUtil/ComImporter.cs
@@ -7,10 +7,10 @@
using System.Globalization;
using System.Resources;
using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
#if RUNTIME_TYPE_NETCORE
using System.Runtime.InteropServices.ComTypes;
#endif
+using System.Runtime.Versioning;
#nullable disable
From 990538cf3bac1399712f9b28a6ecd3aa5ec2879c Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Tue, 1 Mar 2022 11:41:59 -0800
Subject: [PATCH 55/57] Fix M.B.Utilities README
---
src/Utilities/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Utilities/README.md b/src/Utilities/README.md
index 57c3ae642c9..a85d56e11cc 100644
--- a/src/Utilities/README.md
+++ b/src/Utilities/README.md
@@ -7,6 +7,6 @@ This package contains `Microsoft.Build.Utilities.Core.dll`, which defines helper
* [`Logger`](https://docs.microsoft.com/dotnet/api/microsoft.build.utilities.logger), a base class for custom logging functionality.
### netstandard2.0 target
-The `netstandard2.0` target of this build is configured only to output ref assemblies, we do not ship the implementation assemblies. Please use the net6.0-targeted assemblies for .NET Core 6+ scenarios.
+The `netstandard2.0` target of this build is configured only to output reference assemblies; at runtime MSBuild will be `net6.0` or `net472`. Please use the `net6.0`-targeted assemblies for .NET Core 6+ scenarios.
For context, see https://github.com/dotnet/msbuild/pull/6148
\ No newline at end of file
From 84a11ad47736dc6bfcabe9dff1be7cbcd32649fc Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 2 Mar 2022 12:01:55 -0800
Subject: [PATCH 56/57] Simply throw in DownloadFile when catching an
HttpRequestException
---
src/Tasks/DownloadFile.cs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs
index 2e54c018c86..5192719aa13 100644
--- a/src/Tasks/DownloadFile.cs
+++ b/src/Tasks/DownloadFile.cs
@@ -146,13 +146,15 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
{
response.EnsureSuccessStatusCode();
}
+#if NET6_0_OR_GREATER
+ catch (HttpRequestException)
+ {
+ throw;
+#else
catch (HttpRequestException e)
{
-#if NET6_0_OR_GREATER
// MSBuild History: CustomHttpRequestException was created as a wrapper over HttpRequestException
// so it could include the StatusCode. As of net5.0, the statuscode is now in HttpRequestException.
- throw new HttpRequestException(e.Message, e.InnerException, response.StatusCode);
-#else
throw new CustomHttpRequestException(e.Message, e.InnerException, response.StatusCode);
#endif
}
From 7ef24b23020bb632259543cae245b4f68992a8f6 Mon Sep 17 00:00:00 2001
From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com>
Date: Wed, 2 Mar 2022 12:41:02 -0800
Subject: [PATCH 57/57] SignFile and GenerateLauncher are marked as windows
only.
---
src/Tasks/GenerateLauncher.cs | 16 ++++++++++++----
src/Tasks/SignFile.cs | 2 ++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/Tasks/GenerateLauncher.cs b/src/Tasks/GenerateLauncher.cs
index 060f7224791..683736168cc 100644
--- a/src/Tasks/GenerateLauncher.cs
+++ b/src/Tasks/GenerateLauncher.cs
@@ -3,6 +3,7 @@
using System;
using System.IO;
+using System.Runtime.Versioning;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Microsoft.Build.Tasks.Deployment.Bootstrapper;
@@ -16,6 +17,7 @@ namespace Microsoft.Build.Tasks
///
/// Generates a bootstrapper for ClickOnce deployment projects.
///
+ [SupportedOSPlatform("windows")]
public sealed class GenerateLauncher : TaskExtension
{
private const string LAUNCHER_EXE = "Launcher.exe";
@@ -39,7 +41,13 @@ public sealed class GenerateLauncher : TaskExtension
public override bool Execute()
{
- if (LauncherPath == null && NativeMethodsShared.IsWindows)
+ if (!NativeMethodsShared.IsWindows)
+ {
+ Log.LogErrorWithCodeFromResources("General.TaskRequiresWindows", nameof(GenerateLauncher));
+ return false;
+ }
+
+ if (LauncherPath == null)
{
// Launcher lives next to ClickOnce bootstrapper.
// GetDefaultPath obtains the root ClickOnce boostrapper path.
@@ -57,17 +65,17 @@ public override bool Execute()
var launcherBuilder = new LauncherBuilder(LauncherPath);
string entryPointFileName = Path.GetFileName(EntryPoint.ItemSpec);
- //
+
// If the EntryPoint specified is apphost.exe or singlefilehost.exe, we need to replace the EntryPoint
// with the AssemblyName instead since apphost.exe/singlefilehost.exe is an intermediate file for
// for final published {assemblyname}.exe.
- //
if ((entryPointFileName.Equals(Constants.AppHostExe, StringComparison.InvariantCultureIgnoreCase) ||
entryPointFileName.Equals(Constants.SingleFileHostExe, StringComparison.InvariantCultureIgnoreCase)) &&
- !String.IsNullOrEmpty(AssemblyName))
+ !string.IsNullOrEmpty(AssemblyName))
{
entryPointFileName = AssemblyName;
}
+
BuildResults results = launcherBuilder.Build(entryPointFileName, OutputPath);
BuildMessage[] messages = results.Messages;
diff --git a/src/Tasks/SignFile.cs b/src/Tasks/SignFile.cs
index f98c16e6bf5..379fe059587 100644
--- a/src/Tasks/SignFile.cs
+++ b/src/Tasks/SignFile.cs
@@ -4,6 +4,7 @@
using System;
using System.ComponentModel;
using System.IO;
+using System.Runtime.Versioning;
using System.Security.Cryptography;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
@@ -19,6 +20,7 @@ namespace Microsoft.Build.Tasks
/// provided and optionally uses a timestamp if a URL is provided.
/// It can sign ClickOnce manifests as well as exe's.
///
+ [SupportedOSPlatform("windows")]
public sealed class SignFile : Task
{
public SignFile()