Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Layout/redist/targets/BuildToolsetTasks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<UsingTask TaskName="ChangeEntryPointLibraryName" AssemblyFile="$(ToolsetTaskDll)"/>
<UsingTask TaskName="GetCurrentRuntimeInformation" AssemblyFile="$(ToolsetTaskDll)"/>
<UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(ToolsetTaskDll)"/>
<UsingTask TaskName="OverrideAndCreateBundledNETCoreAppPackageVersion" AssemblyFile="$(ToolsetTaskDll)"/>

</Project>
6 changes: 5 additions & 1 deletion src/Layout/redist/targets/OverlaySdkOnLKG.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

<ItemGroup>
<OverlaySDK Include="$(_DotNetHiveRoot)/**/*" Exclude="$(_DotNetHiveRoot)sdk/**/*"/>
<OverlaySdkFilesFromStage0 Include="$(_DotNetHiveRoot)/sdk/$(Stage0SdkVersion)/Microsoft.NETCoreSdk.BundledVersions.props" />
<OverlaySdkFilesFromStage0 Include="$(_DotNetHiveRoot)/sdk/$(Stage0SdkVersion)/Microsoft.NETCoreSdk.BundledCliTools.props" />
<OverlaySdkFilesFromStage0 Include="$(_DotNetHiveRoot)/sdk/$(Stage0SdkVersion)/RuntimeIdentifierGraph.json" />
<OverlaySdkFilesFromStage0 Include="$(_DotNetHiveRoot)/sdk/$(Stage0SdkVersion)/DotnetTools/**/*" RelativeDestination="DotnetTools"/>
Expand All @@ -30,6 +29,11 @@
<Copy SourceFiles="@(OverlaySdkFilesFromStage0)"
DestinationFiles="@(OverlaySdkFilesFromStage0->'$(SdkOutputDirectory)\%(RelativeDestination)\%(RecursiveDir)%(Filename)%(Extension)')"/>

<OverrideAndCreateBundledNETCoreAppPackageVersion
Stage0MicrosoftNETCoreAppRefPackageVersionPath="$(_DotNetHiveRoot)/sdk/$(Stage0SdkVersion)/Microsoft.NETCoreSdk.BundledVersions.props"
MicrosoftNETCoreAppRefPackageVersion="$(MicrosoftNETCoreAppRefPackageVersion)"
OutputPath="$(SdkOutputDirectory)/Microsoft.NETCoreSdk.BundledVersions.props"/>

<Copy SourceFiles="@(ToolsetToOverlay)"
DestinationFiles="@(ToolsetToOverlay->'$(SdkOutputDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" />

Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 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.
/// </summary>
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();
}
}
}
4 changes: 2 additions & 2 deletions src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ The following are names of parameters or literal values and should not be transl
<value>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.</value>
<comment>{StrBegin="NETSDK1134: "}</comment>
</data>
<data name="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion" xml:space="preserve">
<value>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</value>
<data name="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion" xml:space="preserve">
<value>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</value>
<comment>{StrBegin="NETSDK1135: "}</comment>
</data>
<data name="WindowsDesktopTargetPlatformMustBeWindows" xml:space="preserve">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: Nelze najít informace o projektu pro {0}. Může to znamenat chybějící odkaz na projekt.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: Die Projektinformationen für "{0}" wurden nicht gefunden. Dies ist möglicherweise auf einen fehlenden Projektverweis zurückzuführen.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: No se encuentra la información de proyecto de "{0}". Esto puede indicar que falta una referencia de proyecto.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: Les informations relatives au projet sont introuvables pour '{0}'. Cela peut indiquer une référence de projet manquante.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: le informazioni del progetto per '{0}' non sono state trovate. Questo errore può indicare la mancanza di un riferimento al progetto.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: '{0}' のプロジェクト情報が見つかりません。これは、プロジェクト参照がないことを示している可能性があります。</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: '{0}'에 대한 프로젝트 정보를 찾을 수 없습니다. 프로젝트 참조가 없음을 나타낼 수 있습니다.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: Nie odnaleziono informacji o projekcie dla elementu „{0}”. Może to wskazywać na brakujące odwołanie do projektu.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: Não é possível localizar informações do projeto para '{0}'. Isso pode indicar a ausência de uma referência de projeto.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: не удается найти сведения о проекте "{0}". Возможно, отсутствует ссылка на проект.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: '{0}' için proje bilgisi bulunamıyor. Bu durum, bir proje başvurusunun eksik olduğunu gösteriyor olabilir.</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<target state="translated">NETSDK1007: 找不到“{0}”的项目信息。这可以指示缺少一个项目引用。</target>
<note>{StrBegin="NETSDK1007: "}</note>
</trans-unit>
<trans-unit id="CannotHaveMinimumOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: MinimumOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<trans-unit id="CannotHaveSupportedOSPlatformHigherThanTargetPlatformVersion">
<source>NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</source>
<target state="new">NETSDK1135: SupportedOSPlatform {0} cannot be higher than TargetPlatformVersion {1}.</target>
<note>{StrBegin="NETSDK1135: "}</note>
</trans-unit>
<trans-unit id="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget">
Expand Down
Loading