From a6698930abeddbf64fb6ca047ba75a53311437d2 Mon Sep 17 00:00:00 2001 From: Anipik Date: Fri, 23 Jul 2021 11:46:12 -0700 Subject: [PATCH 1/8] inbox the package Validation --- .../PackageValidationTestProject.csproj | 7 ++- .../Microsoft.DotNet.PackageValidation.csproj | 19 ++++-- .../ValidatePackage.cs | 59 ++++++++++++++----- ...Microsoft.DotNet.PackageValidation.targets | 35 ++--------- .../Microsoft.DotNet.PackageValidation.props | 4 -- ...Microsoft.DotNet.PackageValidation.targets | 4 -- .../sdk/Sdk.props | 4 -- .../sdk/Sdk.targets | 4 -- .../Microsoft.NET.Build.Tasks.csproj | 3 + .../Microsoft.NET.PackageValidation.props} | 2 +- .../Microsoft.NET.PackageValidation.targets | 40 +++++++++++++ .../targets/Microsoft.NET.Sdk.props | 1 + .../targets/Microsoft.NET.Sdk.targets | 1 + 13 files changed, 113 insertions(+), 70 deletions(-) delete mode 100644 src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.props delete mode 100644 src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.targets delete mode 100644 src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.props delete mode 100644 src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.targets rename src/{Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.props => Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.props} (76%) create mode 100644 src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets diff --git a/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj b/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj index 7c48ac8322ea..9403ca301c83 100644 --- a/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj +++ b/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj @@ -1,10 +1,11 @@ - + netstandard2.0;net6.0 $(DefineConstants);ForceValidationProblem $(DefineConstants);AddBreakingChange true + true @@ -15,8 +16,8 @@ - - + + $(MSBuildThisFileDirectory)\bin\$(Configuration)\netstandard2.0\Microsoft.DotNet.PackageValidation.dll $(MSBuildThisFileDirectory)\bin\$(Configuration)\net6.0\Microsoft.DotNet.PackageValidation.dll diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj b/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj index 4cd5ce6340e1..34627be54319 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj @@ -15,10 +15,11 @@ - - - - + + + + + @@ -81,7 +82,15 @@ - + + + diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs index 470b23386405..151216c1eedf 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs @@ -1,6 +1,9 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; +using System.IO; +using System.Reflection; using Microsoft.Build.Framework; using Microsoft.NET.Build.Tasks; using NuGet.RuntimeModel; @@ -30,30 +33,58 @@ public class ValidatePackage : TaskBase public string CompatibilitySuppressionFilePath { get; set; } + public string RoslynDirectory { get; set; } + protected override void ExecuteCore() { - RuntimeGraph runtimeGraph = null; - if (!string.IsNullOrEmpty(RuntimeGraph)) + if (string.IsNullOrEmpty(RoslynDirectory)) { - runtimeGraph = JsonRuntimeFormat.ReadRuntimeGraph(RuntimeGraph); + throw new ArgumentNullException(nameof(RoslynDirectory)); } - Package package = NupkgParser.CreatePackage(PackageTargetPath, runtimeGraph); - PackageValidationLogger logger = new(Log, CompatibilitySuppressionFilePath, GenerateCompatibilitySuppressionFile); - - new CompatibleTfmValidator(NoWarn, null, RunApiCompat, EnableStrictModeForCompatibleTfms, logger).Validate(package); - new CompatibleFrameworkInPackageValidator(NoWarn, null, EnableStrictModeForCompatibleFrameworksInPackage, logger).Validate(package); + AppDomain.CurrentDomain.AssemblyResolve += ResolverForRoslyn; - if (!DisablePackageBaselineValidation && !string.IsNullOrEmpty(BaselinePackageTargetPath)) + try { - Package baselinePackage = NupkgParser.CreatePackage(BaselinePackageTargetPath, runtimeGraph); - new BaselinePackageValidator(baselinePackage, NoWarn, null, RunApiCompat, logger).Validate(package); + RuntimeGraph runtimeGraph = null; + if (!string.IsNullOrEmpty(RuntimeGraph)) + { + runtimeGraph = JsonRuntimeFormat.ReadRuntimeGraph(RuntimeGraph); + } + + Package package = NupkgParser.CreatePackage(PackageTargetPath, runtimeGraph); + PackageValidationLogger logger = new(Log, CompatibilitySuppressionFilePath, GenerateCompatibilitySuppressionFile); + + new CompatibleTfmValidator(NoWarn, null, RunApiCompat, EnableStrictModeForCompatibleTfms, logger).Validate(package); + new CompatibleFrameworkInPackageValidator(NoWarn, null, EnableStrictModeForCompatibleFrameworksInPackage, logger).Validate(package); + + if (!DisablePackageBaselineValidation && !string.IsNullOrEmpty(BaselinePackageTargetPath)) + { + Package baselinePackage = NupkgParser.CreatePackage(BaselinePackageTargetPath, runtimeGraph); + new BaselinePackageValidator(baselinePackage, NoWarn, null, RunApiCompat, logger).Validate(package); + } + + if (GenerateCompatibilitySuppressionFile) + { + logger.GenerateSuppressionsFile(CompatibilitySuppressionFilePath); + } } - - if (GenerateCompatibilitySuppressionFile) + finally { - logger.GenerateSuppressionsFile(CompatibilitySuppressionFilePath); + AppDomain.CurrentDomain.AssemblyResolve -= ResolverForRoslyn; } } + + private Assembly ResolverForRoslyn(object sender, ResolveEventArgs args) + { + AssemblyName name = new(args.Name); + + return name.Name switch + { + "Microsoft.CodeAnalysis" or "Microsoft.CodeAnalysis.CSharp" => + Assembly.LoadFrom(Path.Combine(RoslynDirectory, $"{name.Name}.dll")), + _ => null, + }; + } } } diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets b/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets index aa1d04e9d168..90422cf79ad7 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets @@ -1,34 +1,7 @@ - - - - - - - - - - $(PackageId) - $([MSBuild]::NormalizePath('$(NuGetPackageRoot)', '$(PackageValidationBaselineName.ToLower())', '$(PackageValidationBaselineVersion)', '$(PackageValidationBaselineName.ToLower()).$(PackageValidationBaselineVersion).nupkg')) - false - <_compatibilitySuppressionFilePath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', 'CompatibilitySuppressions.xml')) - $(_compatibilitySuppressionFilePath) - - - - - + + $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.PackageValidation.dll + $(MSBuildThisFileDirectory)..\tools\netcoreapp3.1\Microsoft.DotNet.PackageValidation.dll + diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.props b/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.props deleted file mode 100644 index 1d5afc708a52..000000000000 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.props +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.targets b/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.targets deleted file mode 100644 index e68261f2f2dc..000000000000 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.targets +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.props b/src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.props deleted file mode 100644 index d557caa06916..000000000000 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.props +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.targets b/src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.targets deleted file mode 100644 index 42391fb3be2f..000000000000 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/sdk/Sdk.targets +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj index e7ff4814657f..180f1d9d79e2 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj +++ b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj @@ -50,10 +50,13 @@ + + + diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.props similarity index 76% rename from src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.props rename to src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.props index 90422cf79ad7..84765e303971 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.props @@ -2,6 +2,6 @@ $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.PackageValidation.dll - $(MSBuildThisFileDirectory)..\tools\netcoreapp3.1\Microsoft.DotNet.PackageValidation.dll + $(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.DotNet.PackageValidation.dll diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets new file mode 100644 index 000000000000..24770119eaa8 --- /dev/null +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets @@ -0,0 +1,40 @@ + + + + + + + + + + + + $([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath))) + $([System.IO.Path]::Combine('$(RoslynDirectory)', bincore)) + + + + $(PackageId) + $([MSBuild]::NormalizePath('$(NuGetPackageRoot)', '$(PackageValidationBaselineName.ToLower())', '$(PackageValidationBaselineVersion)', '$(PackageValidationBaselineName.ToLower()).$(PackageValidationBaselineVersion).nupkg')) + false + <_compatibilitySuppressionFilePath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', 'CompatibilitySuppressions.xml')) + $(_compatibilitySuppressionFilePath) + + + + + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props index 63f33d94a6a2..ecf3f4f76785 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props @@ -142,6 +142,7 @@ Copyright (c) .NET Foundation. All rights reserved. + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index f4080f304418..0329aedd38bf 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -1112,6 +1112,7 @@ Copyright (c) .NET Foundation. All rights reserved. + - + + diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj b/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj index 34627be54319..3a9fdecd66e5 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj @@ -18,7 +18,7 @@ - + @@ -82,15 +82,8 @@ - - - diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx b/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx index e951449935e8..b2dc5f7bff0a 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx @@ -153,4 +153,7 @@ [Baseline] + + You are using an older version of the roslyn. Please update to the latest sdk version. + \ No newline at end of file diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs index 151216c1eedf..29b694c2f785 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs @@ -33,58 +33,67 @@ public class ValidatePackage : TaskBase public string CompatibilitySuppressionFilePath { get; set; } - public string RoslynDirectory { get; set; } + public string RoslynAssemblyPath { get; set; } - protected override void ExecuteCore() + public string RoslynMinVersion { get; set; } + + public override bool Execute() { - if (string.IsNullOrEmpty(RoslynDirectory)) + if (string.IsNullOrEmpty(RoslynAssemblyPath)) { - throw new ArgumentNullException(nameof(RoslynDirectory)); + throw new ArgumentNullException(nameof(RoslynAssemblyPath)); } AppDomain.CurrentDomain.AssemblyResolve += ResolverForRoslyn; - try { - RuntimeGraph runtimeGraph = null; - if (!string.IsNullOrEmpty(RuntimeGraph)) - { - runtimeGraph = JsonRuntimeFormat.ReadRuntimeGraph(RuntimeGraph); - } + return base.Execute(); + } + finally + { + AppDomain.CurrentDomain.AssemblyResolve -= ResolverForRoslyn; + } + } - Package package = NupkgParser.CreatePackage(PackageTargetPath, runtimeGraph); - PackageValidationLogger logger = new(Log, CompatibilitySuppressionFilePath, GenerateCompatibilitySuppressionFile); + protected override void ExecuteCore() + { + RuntimeGraph runtimeGraph = null; + if (!string.IsNullOrEmpty(RuntimeGraph)) + { + runtimeGraph = JsonRuntimeFormat.ReadRuntimeGraph(RuntimeGraph); + } - new CompatibleTfmValidator(NoWarn, null, RunApiCompat, EnableStrictModeForCompatibleTfms, logger).Validate(package); - new CompatibleFrameworkInPackageValidator(NoWarn, null, EnableStrictModeForCompatibleFrameworksInPackage, logger).Validate(package); + Package package = NupkgParser.CreatePackage(PackageTargetPath, runtimeGraph); + PackageValidationLogger logger = new(Log, CompatibilitySuppressionFilePath, GenerateCompatibilitySuppressionFile); - if (!DisablePackageBaselineValidation && !string.IsNullOrEmpty(BaselinePackageTargetPath)) - { - Package baselinePackage = NupkgParser.CreatePackage(BaselinePackageTargetPath, runtimeGraph); - new BaselinePackageValidator(baselinePackage, NoWarn, null, RunApiCompat, logger).Validate(package); - } + new CompatibleTfmValidator(NoWarn, null, RunApiCompat, EnableStrictModeForCompatibleTfms, logger).Validate(package); + new CompatibleFrameworkInPackageValidator(NoWarn, null, EnableStrictModeForCompatibleFrameworksInPackage, logger).Validate(package); - if (GenerateCompatibilitySuppressionFile) - { - logger.GenerateSuppressionsFile(CompatibilitySuppressionFilePath); - } + if (!DisablePackageBaselineValidation && !string.IsNullOrEmpty(BaselinePackageTargetPath)) + { + Package baselinePackage = NupkgParser.CreatePackage(BaselinePackageTargetPath, runtimeGraph); + new BaselinePackageValidator(baselinePackage, NoWarn, null, RunApiCompat, logger).Validate(package); } - finally + + if (GenerateCompatibilitySuppressionFile) { - AppDomain.CurrentDomain.AssemblyResolve -= ResolverForRoslyn; + logger.GenerateSuppressionsFile(CompatibilitySuppressionFilePath); } } private Assembly ResolverForRoslyn(object sender, ResolveEventArgs args) { AssemblyName name = new(args.Name); - - return name.Name switch + if (name.Name == "Microsoft.CodeAnalysis" || name.Name == "Microsoft.CodeAnalysis.CSharp") { - "Microsoft.CodeAnalysis" or "Microsoft.CodeAnalysis.CSharp" => - Assembly.LoadFrom(Path.Combine(RoslynDirectory, $"{name.Name}.dll")), - _ => null, - }; + Assembly asm = Assembly.LoadFrom(Path.Combine(RoslynAssemblyPath, $"{name.Name}.dll")); + if (asm.GetName().Version < new Version(RoslynMinVersion)) + { + throw new Exception(Resources.UpdateSdkVersion); + } + return asm; + } + return null; } } } diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf index 58eea1247ece..4e606e17faac 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf index 28ae631c2b50..6ff5fea32d15 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf index f41c50018c4e..e666e1ace5af 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf index 1026e45d87a2..5ccc5f8de032 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf index ea278cf4f917..5314781261e8 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf index cc4955b2f76c..34d2ed29d252 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf index 392e00a08aed..d89c4d86db5d 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf index 7a6067fa7fdb..fb3ed954a38b 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf index ca79b4dcee63..6dd8d42193b0 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf index 5039f382d18d..de4696a21bc7 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf index 175b690fb1f6..a2b071b96b65 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf index fda26afdf7df..8a649bd05868 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf index cabd46f99e1f..a501b2e1bca5 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf @@ -57,6 +57,11 @@ Package '{0}' not found. Please provide a valid package path. + + You are using an older version of the roslyn. Please update to the latest sdk version. + You are using an older version of the roslyn. Please update to the latest sdk version. + + Successfully wrote compatibility suppressions to '{0}'. Successfully wrote compatibility suppressions to '{0}'. diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj index 180f1d9d79e2..74a2a3b64582 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj +++ b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj @@ -50,7 +50,6 @@ - diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets index 24770119eaa8..560586199a2a 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets @@ -2,6 +2,10 @@ + + 4.0.0.0 + + @@ -10,9 +14,9 @@ AfterTargets="Pack" Condition="'$(IsPackable)' == 'true' and '$(EnablePackageValidation)' == 'true'"> - - $([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath))) - $([System.IO.Path]::Combine('$(RoslynDirectory)', bincore)) + + $(RoslynTargetsPath) + $([System.IO.Path]::Combine('$(RoslynAssemblyPath)', bincore)) @@ -35,6 +39,7 @@ CompatibilitySuppressionFilePath="$(CompatibilitySuppressionFilePath)" BaselinePackageTargetPath="$(PackageValidationBaselinePath)" DisablePackageBaselineValidation="$(DisablePackageBaselineValidation)" - RoslynDirectory="$(RoslynDirectory)"/> + RoslynAssemblyPath="$(RoslynAssemblyPath)" + RoslynMinVersion="$(RoslynMinVersion)" /> diff --git a/src/Tests/Microsoft.DotNet.ApiCompatibility.Tests/CompatDifferenceComparer.cs b/src/Tests/Microsoft.DotNet.ApiCompatibility.Tests/CompatDifferenceComparer.cs index 271aedda4c39..7510ab3e5076 100644 --- a/src/Tests/Microsoft.DotNet.ApiCompatibility.Tests/CompatDifferenceComparer.cs +++ b/src/Tests/Microsoft.DotNet.ApiCompatibility.Tests/CompatDifferenceComparer.cs @@ -18,7 +18,13 @@ public bool Equals(CompatDifference x, CompatDifference y) => string.Equals(x.ReferenceId, y.ReferenceId, StringComparison.OrdinalIgnoreCase) && x.Type == y.Type; - public int GetHashCode(CompatDifference difference) => - HashCode.Combine(difference.DiagnosticId, difference.ReferenceId, difference.Type); + public int GetHashCode(CompatDifference difference) + { + int hashCode = 1447485498; + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(difference.DiagnosticId); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(difference.Type); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(difference.ReferenceId); + return hashCode; + } } } From fe75633258174c9a62cc21143a539ce9c6cc1434 Mon Sep 17 00:00:00 2001 From: Anipik Date: Tue, 27 Jul 2021 09:59:36 -0700 Subject: [PATCH 3/8] fix some test failures and roslyn min version --- .../Microsoft.DotNet.ApiCompatibility/DiagnosticBag.cs | 2 +- .../ErrorSuppression/Suppression.cs | 8 ++++---- .../Microsoft.DotNet.ApiCompatibility.csproj | 3 +-- .../Microsoft.DotNet.PackageValidation/ValidatePackage.cs | 4 +--- .../targets/Microsoft.NET.PackageValidation.targets | 7 +------ 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/Compatibility/Microsoft.DotNet.ApiCompatibility/DiagnosticBag.cs b/src/Compatibility/Microsoft.DotNet.ApiCompatibility/DiagnosticBag.cs index 6217edc56fb6..0688c82627ae 100644 --- a/src/Compatibility/Microsoft.DotNet.ApiCompatibility/DiagnosticBag.cs +++ b/src/Compatibility/Microsoft.DotNet.ApiCompatibility/DiagnosticBag.cs @@ -28,7 +28,7 @@ public class DiagnosticBag where T : IDiagnostic public DiagnosticBag(IEnumerable noWarn, (string diagnosticId, string referenceId)[] ignoredDifferences) { - if (_noWarn != null) + if (noWarn != null) _noWarn = new HashSet(noWarn); else _noWarn = new HashSet(); diff --git a/src/Compatibility/Microsoft.DotNet.ApiCompatibility/ErrorSuppression/Suppression.cs b/src/Compatibility/Microsoft.DotNet.ApiCompatibility/ErrorSuppression/Suppression.cs index 39ee70c2fff6..0632efcf7210 100644 --- a/src/Compatibility/Microsoft.DotNet.ApiCompatibility/ErrorSuppression/Suppression.cs +++ b/src/Compatibility/Microsoft.DotNet.ApiCompatibility/ErrorSuppression/Suppression.cs @@ -58,10 +58,10 @@ static bool AreEqual(string? first, string? second) public override int GetHashCode() { int hashCode = 1447485498; - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(DiagnosticId ?? string.Empty); - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Target ?? string.Empty); - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Left ?? string.Empty); - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Right ?? string.Empty); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(DiagnosticId?.ToLowerInvariant() ?? string.Empty); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Target?.ToLowerInvariant() ?? string.Empty); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Left?.ToLowerInvariant() ?? string.Empty); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Right?.ToLowerInvariant() ?? string.Empty); return hashCode; } } diff --git a/src/Compatibility/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj b/src/Compatibility/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj index dc6b507e4039..e1bbc0b7cb6b 100644 --- a/src/Compatibility/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj +++ b/src/Compatibility/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj @@ -9,8 +9,7 @@ - - + diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs index 29b694c2f785..fc5176df7add 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs @@ -35,8 +35,6 @@ public class ValidatePackage : TaskBase public string RoslynAssemblyPath { get; set; } - public string RoslynMinVersion { get; set; } - public override bool Execute() { if (string.IsNullOrEmpty(RoslynAssemblyPath)) @@ -87,7 +85,7 @@ private Assembly ResolverForRoslyn(object sender, ResolveEventArgs args) if (name.Name == "Microsoft.CodeAnalysis" || name.Name == "Microsoft.CodeAnalysis.CSharp") { Assembly asm = Assembly.LoadFrom(Path.Combine(RoslynAssemblyPath, $"{name.Name}.dll")); - if (asm.GetName().Version < new Version(RoslynMinVersion)) + if (asm.GetName().Version < name.Version) { throw new Exception(Resources.UpdateSdkVersion); } diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets index 560586199a2a..0fe9935702c7 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets @@ -2,10 +2,6 @@ - - 4.0.0.0 - - @@ -39,7 +35,6 @@ CompatibilitySuppressionFilePath="$(CompatibilitySuppressionFilePath)" BaselinePackageTargetPath="$(PackageValidationBaselinePath)" DisablePackageBaselineValidation="$(DisablePackageBaselineValidation)" - RoslynAssemblyPath="$(RoslynAssemblyPath)" - RoslynMinVersion="$(RoslynMinVersion)" /> + RoslynAssemblyPath="$(RoslynAssemblyPath)" /> From 6b373d0c26287c6faa77d96ee1a030ba1d3eac8f Mon Sep 17 00:00:00 2001 From: Anipik Date: Tue, 27 Jul 2021 13:52:05 -0700 Subject: [PATCH 4/8] add msbuld targets to the package. --- .../PackageValidationTestProject.csproj | 2 +- .../Microsoft.DotNet.PackageValidation.csproj | 4 ++++ .../build/Microsoft.DotNet.PackageValidation.targets | 3 +++ ...targets => Microsoft.NET.Compatibility.Common.targets} | 4 ---- ...Validation.props => Microsoft.NET.Compatibility.props} | 0 .../targets/Microsoft.NET.Compatibility.targets | 8 ++++++++ .../targets/Microsoft.NET.Sdk.props | 2 +- .../targets/Microsoft.NET.Sdk.targets | 2 +- 8 files changed, 18 insertions(+), 7 deletions(-) rename src/Tasks/Microsoft.NET.Build.Tasks/targets/{Microsoft.NET.PackageValidation.targets => Microsoft.NET.Compatibility.Common.targets} (88%) rename src/Tasks/Microsoft.NET.Build.Tasks/targets/{Microsoft.NET.PackageValidation.props => Microsoft.NET.Compatibility.props} (100%) create mode 100644 src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.targets diff --git a/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj b/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj index 9403ca301c83..02b879cfc68b 100644 --- a/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj +++ b/src/Assets/TestProjects/PackageValidationTestProject/PackageValidationTestProject.csproj @@ -16,7 +16,7 @@ - + $(MSBuildThisFileDirectory)\bin\$(Configuration)\netstandard2.0\Microsoft.DotNet.PackageValidation.dll diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj b/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj index 3a9fdecd66e5..2dc0a7cd6e07 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj @@ -35,6 +35,10 @@ %(RecursiveDir)%(Filename)%(Extension) + + build/Microsoft.NET.Compatibility.Common.targets + build/%(Filename)%(Extension) + diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets b/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets index 90422cf79ad7..6ab158fbed32 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets @@ -3,5 +3,8 @@ $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.PackageValidation.dll $(MSBuildThisFileDirectory)..\tools\netcoreapp3.1\Microsoft.DotNet.PackageValidation.dll + true + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.Common.targets similarity index 88% rename from src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets rename to src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.Common.targets index 0fe9935702c7..56e7116dc753 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.Common.targets @@ -2,10 +2,6 @@ - - - - diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props similarity index 100% rename from src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackageValidation.props rename to src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.targets new file mode 100644 index 000000000000..de7d6aef953f --- /dev/null +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.targets @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props index ecf3f4f76785..664ae5470589 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props @@ -142,7 +142,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index 0329aedd38bf..dcdbe89e3239 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -1112,7 +1112,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + - netcoreapp3.1;net472 + net6.0;net472 true true Open diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx b/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx index b2dc5f7bff0a..d369dfd50adb 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/Resources.resx @@ -154,6 +154,6 @@ [Baseline] - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. \ No newline at end of file diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs index fc5176df7add..2b9f94baec6d 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/ValidatePackage.cs @@ -15,6 +15,9 @@ public class ValidatePackage : TaskBase [Required] public string PackageTargetPath { get; set; } + [Required] + public string RoslynAssembliesPath { get; set; } + public string RuntimeGraph { get; set; } public string NoWarn { get; set; } @@ -33,15 +36,8 @@ public class ValidatePackage : TaskBase public string CompatibilitySuppressionFilePath { get; set; } - public string RoslynAssemblyPath { get; set; } - public override bool Execute() { - if (string.IsNullOrEmpty(RoslynAssemblyPath)) - { - throw new ArgumentNullException(nameof(RoslynAssemblyPath)); - } - AppDomain.CurrentDomain.AssemblyResolve += ResolverForRoslyn; try { @@ -84,10 +80,11 @@ private Assembly ResolverForRoslyn(object sender, ResolveEventArgs args) AssemblyName name = new(args.Name); if (name.Name == "Microsoft.CodeAnalysis" || name.Name == "Microsoft.CodeAnalysis.CSharp") { - Assembly asm = Assembly.LoadFrom(Path.Combine(RoslynAssemblyPath, $"{name.Name}.dll")); - if (asm.GetName().Version < name.Version) + Assembly asm = Assembly.LoadFrom(Path.Combine(RoslynAssembliesPath, $"{name.Name}.dll")); + Version version = asm.GetName().Version; + if (version < name.Version) { - throw new Exception(Resources.UpdateSdkVersion); + throw new Exception(string.Format(Resources.UpdateSdkVersion, version, name.Version)); } return asm; } diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets b/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets index 6ab158fbed32..8af05c03937d 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/build/Microsoft.DotNet.PackageValidation.targets @@ -2,7 +2,7 @@ $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.PackageValidation.dll - $(MSBuildThisFileDirectory)..\tools\netcoreapp3.1\Microsoft.DotNet.PackageValidation.dll + $(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.DotNet.PackageValidation.dll true diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.targets b/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.targets new file mode 100644 index 000000000000..7389c74bb966 --- /dev/null +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/buildMultiTargeting/Microsoft.DotNet.PackageValidation.targets @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf index 4e606e17faac..090ac4c74949 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf index 6ff5fea32d15..9d78d2335a4c 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf index e666e1ace5af..e0b65afd576a 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf index 5ccc5f8de032..ed36d1ecf99c 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf index 5314781261e8..c6d8fd041332 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf index 34d2ed29d252..5ef7060d2d22 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf index d89c4d86db5d..94181a95755b 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf index fb3ed954a38b..92727cf4a2fa 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf index 6dd8d42193b0..4ff2e35dc325 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf index de4696a21bc7..2af44dd64dff 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf index a2b071b96b65..6aa78fc37119 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf index 8a649bd05868..98fbef2c7c3e 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf index a501b2e1bca5..79e16a901e6e 100644 --- a/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf +++ b/src/Compatibility/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf @@ -58,8 +58,8 @@ - You are using an older version of the roslyn. Please update to the latest sdk version. - You are using an older version of the roslyn. Please update to the latest sdk version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. + The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version. diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets index 5f3715982760..7d5a46179849 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets @@ -41,6 +41,8 @@ Copyright (c) .NET Foundation. All rights reserved. + + $(MSBuildThisFileDirectory)..\..\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.Common.targets index 56e7116dc753..623de4712da5 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.Common.targets @@ -6,9 +6,9 @@ AfterTargets="Pack" Condition="'$(IsPackable)' == 'true' and '$(EnablePackageValidation)' == 'true'"> - - $(RoslynTargetsPath) - $([System.IO.Path]::Combine('$(RoslynAssemblyPath)', bincore)) + + $(RoslynTargetsPath) + $([System.IO.Path]::Combine('$(RoslynAssembliesPath)', bincore)) @@ -31,6 +31,6 @@ CompatibilitySuppressionFilePath="$(CompatibilitySuppressionFilePath)" BaselinePackageTargetPath="$(PackageValidationBaselinePath)" DisablePackageBaselineValidation="$(DisablePackageBaselineValidation)" - RoslynAssemblyPath="$(RoslynAssemblyPath)" /> + RoslynAssembliesPath="$(RoslynAssembliesPath)" /> diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index dcdbe89e3239..f4080f304418 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -1112,7 +1112,6 @@ Copyright (c) .NET Foundation. All rights reserved. - - \ No newline at end of file + From 0606543885eeb561ff2c385eddb7cec687bcd862 Mon Sep 17 00:00:00 2001 From: Anipik Date: Wed, 28 Jul 2021 15:12:37 -0700 Subject: [PATCH 7/8] use tasks existing property --- .../targets/Microsoft.NET.Compatibility.props | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props index 84765e303971..a2dff43153a5 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props @@ -1,7 +1,6 @@ - $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.PackageValidation.dll - $(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.DotNet.PackageValidation.dll + $(MicrosoftNETBuildTasksDirectoryRoot)$(MicrosoftNETBuildTasksTFM)\Microsoft.DotNet.PackageValidation.dll From 974e68ed6236a1164803e3b554fd6ceef45dfadd Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Wed, 28 Jul 2021 19:49:27 -0700 Subject: [PATCH 8/8] Revert "use tasks existing property" This reverts commit 0606543885eeb561ff2c385eddb7cec687bcd862. --- .../targets/Microsoft.NET.Compatibility.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props index a2dff43153a5..84765e303971 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Compatibility.props @@ -1,6 +1,7 @@ - $(MicrosoftNETBuildTasksDirectoryRoot)$(MicrosoftNETBuildTasksTFM)\Microsoft.DotNet.PackageValidation.dll + $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.PackageValidation.dll + $(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.DotNet.PackageValidation.dll