diff --git a/src/Layout/redist/targets/BuildToolsetTasks.targets b/src/Layout/redist/targets/BuildToolsetTasks.targets index 407c01e3a66a..f69982ea08fc 100644 --- a/src/Layout/redist/targets/BuildToolsetTasks.targets +++ b/src/Layout/redist/targets/BuildToolsetTasks.targets @@ -25,5 +25,6 @@ + diff --git a/src/Layout/redist/targets/OverlaySdkOnLKG.targets b/src/Layout/redist/targets/OverlaySdkOnLKG.targets index d2a2f6b4ddb1..496cbbb1af13 100644 --- a/src/Layout/redist/targets/OverlaySdkOnLKG.targets +++ b/src/Layout/redist/targets/OverlaySdkOnLKG.targets @@ -12,7 +12,6 @@ - @@ -30,6 +29,11 @@ + + diff --git a/src/Layout/toolset-tasks/OverrideAndCreateBundledNETCoreAppPackageVersion.cs b/src/Layout/toolset-tasks/OverrideAndCreateBundledNETCoreAppPackageVersion.cs new file mode 100644 index 000000000000..56884c447678 --- /dev/null +++ b/src/Layout/toolset-tasks/OverrideAndCreateBundledNETCoreAppPackageVersion.cs @@ -0,0 +1,102 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Text.RegularExpressions; +using System.Xml.Linq; +using System.Xml.XPath; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.DotNet.Build.Tasks +{ + /// + /// Use the runtime in dotnet/sdk instead of in the stage 0 to avoid circular dependency. + /// If there is a change depended on the latest runtime. Without override the runtime version in BundledNETCoreAppPackageVersion + /// we would need to somehow get this change in without the test, and then insertion dotnet/installer + /// and then update the stage 0 back. + /// + /// Use a task to override since it was generated as a string literal replace anyway. + /// And using C# can have better error when anything goes wrong. + /// + public sealed class OverrideAndCreateBundledNETCoreAppPackageVersion : Task + { + private static string _messageWhenMismatch = + "{0} version {1} does not match BundledNETCoreAppPackageVersion {2}. " + + "The schema of https://github.com/dotnet/installer/blob/master/src/redist/targets/GenerateBundledVersions.targets might change. " + + "We need to ensure we can swap the runtime version from what's in stage0 to what dotnet/sdk used successfully"; + + [Required] public string Stage0MicrosoftNETCoreAppRefPackageVersionPath { get; set; } + + [Required] public string MicrosoftNETCoreAppRefPackageVersion { get; set; } + + [Required] public string OutputPath { get; set; } + + public override bool Execute() + { + File.WriteAllText(OutputPath, + ExecuteInternal(File.ReadAllText(Stage0MicrosoftNETCoreAppRefPackageVersionPath), + MicrosoftNETCoreAppRefPackageVersion)); + return true; + } + + public static string ExecuteInternal( + string stage0MicrosoftNETCoreAppRefPackageVersionContent, + string microsoftNETCoreAppRefPackageVersion) + { + var projectXml = XDocument.Parse(stage0MicrosoftNETCoreAppRefPackageVersionContent); + + var ns = projectXml.Root.Name.Namespace; + + var propertyGroup = projectXml.Root.Elements(ns + "PropertyGroup").First(); + + var originalBundledNETCoreAppPackageVersion = + propertyGroup.Element(ns + "BundledNETCoreAppPackageVersion").Value; + propertyGroup.Element(ns + "BundledNETCoreAppPackageVersion").Value = microsoftNETCoreAppRefPackageVersion; + + void CheckAndReplaceElement(XElement element) + { + if (element.Value != originalBundledNETCoreAppPackageVersion) + { + throw new ApplicationException(string.Format( + _messageWhenMismatch, + element.ToString(), element.Value, originalBundledNETCoreAppPackageVersion)); + } + + element.Value = microsoftNETCoreAppRefPackageVersion; + } + + void CheckAndReplaceAttribute(XAttribute attribute) + { + if (attribute.Value != originalBundledNETCoreAppPackageVersion) + { + throw new ApplicationException(string.Format( + _messageWhenMismatch, + attribute.Parent.ToString() + " --- " + attribute.ToString(), attribute.Value, + originalBundledNETCoreAppPackageVersion)); + } + + attribute.Value = microsoftNETCoreAppRefPackageVersion; + } + + CheckAndReplaceElement(propertyGroup.Element(ns + "BundledNETCorePlatformsPackageVersion")); + + var itemGroup = projectXml.Root.Elements(ns + "ItemGroup").First(); + + CheckAndReplaceAttribute(itemGroup + .Elements(ns + "KnownFrameworkReference").First().Attribute("DefaultRuntimeFrameworkVersion")); + CheckAndReplaceAttribute(itemGroup + .Elements(ns + "KnownFrameworkReference").First().Attribute("LatestRuntimeFrameworkVersion")); + CheckAndReplaceAttribute(itemGroup + .Elements(ns + "KnownFrameworkReference").First().Attribute("TargetingPackVersion")); + CheckAndReplaceAttribute(itemGroup + .Elements(ns + "KnownAppHostPack").First().Attribute("AppHostPackVersion")); + + return projectXml.ToString(); + } + } +} diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index 56213d3c7b15..12bd70ad5979 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -641,8 +641,8 @@ The following are names of parameters or literal values and should not be transl NETSDK1134: Building a solution with a specific RuntimeIdentifier is not supported. If you would like to publish for a single RID, specifiy the RID at the individual project level instead. {StrBegin="NETSDK1134: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index 34a32b3091e7..749341b26280 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -107,9 +107,9 @@ NETSDK1007: Nelze najít informace o projektu pro {0}. Může to znamenat chybějící odkaz na projekt. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index 94db10ff7230..3791958c30d2 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -107,9 +107,9 @@ NETSDK1007: Die Projektinformationen für "{0}" wurden nicht gefunden. Dies ist möglicherweise auf einen fehlenden Projektverweis zurückzuführen. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 383bbe31368b..afee572262df 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -107,9 +107,9 @@ NETSDK1007: No se encuentra la información de proyecto de "{0}". Esto puede indicar que falta una referencia de proyecto. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index 52c90f9b66f8..c859aa077ea5 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -107,9 +107,9 @@ NETSDK1007: Les informations relatives au projet sont introuvables pour '{0}'. Cela peut indiquer une référence de projet manquante. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index 9c5f11bddd09..8f00f18f70f9 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -107,9 +107,9 @@ NETSDK1007: le informazioni del progetto per '{0}' non sono state trovate. Questo errore può indicare la mancanza di un riferimento al progetto. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index dfb11b09800f..4f4f1081b298 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -107,9 +107,9 @@ NETSDK1007: '{0}' のプロジェクト情報が見つかりません。これは、プロジェクト参照がないことを示している可能性があります。 {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index 360a4987afe3..5196bed25521 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -107,9 +107,9 @@ NETSDK1007: '{0}'에 대한 프로젝트 정보를 찾을 수 없습니다. 프로젝트 참조가 없음을 나타낼 수 있습니다. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index 4554e7f5e319..ccfc4213f0cc 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -107,9 +107,9 @@ NETSDK1007: Nie odnaleziono informacji o projekcie dla elementu „{0}”. Może to wskazywać na brakujące odwołanie do projektu. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index db6d3856b069..7c89a1dcf33c 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -107,9 +107,9 @@ NETSDK1007: Não é possível localizar informações do projeto para '{0}'. Isso pode indicar a ausência de uma referência de projeto. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index 0475cad77d27..4ec204dfa4b4 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -107,9 +107,9 @@ NETSDK1007: не удается найти сведения о проекте "{0}". Возможно, отсутствует ссылка на проект. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index a15c71f9e929..2e795f2ccc2e 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -107,9 +107,9 @@ NETSDK1007: '{0}' için proje bilgisi bulunamıyor. Bu durum, bir proje başvurusunun eksik olduğunu gösteriyor olabilir. {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index a8b093357bee..b9e6325fbf95 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -107,9 +107,9 @@ NETSDK1007: 找不到“{0}”的项目信息。这可以指示缺少一个项目引用。 {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index 0ffd66eeb2fc..3299c9bf5704 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -107,9 +107,9 @@ NETSDK1007: 找不到 '{0}' 的專案資訊。這可能表示遺漏專案參考。 {StrBegin="NETSDK1007: "} - - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. - NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. + NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}. {StrBegin="NETSDK1135: "} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateAssemblyInfo.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateAssemblyInfo.targets index 28bcccbbb8f7..999f731cb774 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateAssemblyInfo.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateAssemblyInfo.targets @@ -117,11 +117,11 @@ Copyright (c) .NET Foundation. All rights reserved. - - <_Parameter1>$(TargetPlatformIdentifier)$(MinimumOSPlatform) + + <_Parameter1>$(TargetPlatformIdentifier)$(SupportedOSPlatform) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets index c731a14b406f..4fb5a15e190d 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets @@ -76,9 +76,9 @@ Copyright (c) .NET Foundation. All rights reserved. <_UnsupportedTargetFrameworkError>true - - - $(TargetPlatformVersion) + + + $(TargetPlatformVersion)