Skip to content

Commit 8286b19

Browse files
sbomerdsplaisted
andauthored
Use linker matching TFM (#29441)
Use a linker based on the current TargetFramework. This relies on KnownILLinkPack and the implicit packagereference mechanism used also for NativeAot to restore the right version of illink. The 7.0 version will continue to be used when targeting .net7 or below. Co-authored-by: Daniel Plaisted <[email protected]>
1 parent ce9cb77 commit 8286b19

24 files changed

+258
-61
lines changed

src/Layout/redist/targets/BundledSdks.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
<BundledSdk Include="Microsoft.NET.Sdk.WindowsDesktop" Version="$(MicrosoftNETSdkWindowsDesktopPackageVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'" />
55
<BundledSdk Include="FSharp.NET.Sdk" Version="1.0.4-bundled-0100" />
66
<BundledSdk Include="Microsoft.Docker.Sdk" Version="1.1.0" />
7-
<BundledSdk Include="Microsoft.NET.ILLink.Tasks" Version="$(MicrosoftNETILLinkTasksPackageVersion)" />
87
</ItemGroup>
98
</Project>

src/Layout/redist/targets/OverlaySdkOnLKG.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<OverrideAndCreateBundledNETCoreAppPackageVersion
6363
Stage0MicrosoftNETCoreAppRefPackageVersionPath="$(_DotNetHiveRoot)/sdk/$(Stage0SdkVersion)/Microsoft.NETCoreSdk.BundledVersions.props"
6464
MicrosoftNETCoreAppRefPackageVersion="$(MicrosoftNETCoreAppRefPackageVersion)"
65+
MicrosoftNETILLinkTasksPackageVersion="$(MicrosoftNETILLinkTasksPackageVersion)"
6566
NewSDKVersion="$(Version)"
6667
OutputPath="$(SdkOutputDirectory)/Microsoft.NETCoreSdk.BundledVersions.props"/>
6768

src/Layout/toolset-tasks/OverrideAndCreateBundledNETCoreAppPackageVersion.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public sealed class OverrideAndCreateBundledNETCoreAppPackageVersion : Task
3535
[Required] public string Stage0MicrosoftNETCoreAppRefPackageVersionPath { get; set; }
3636

3737
[Required] public string MicrosoftNETCoreAppRefPackageVersion { get; set; }
38+
39+
// TODO: remove this once linker packages are produced from dotnet/runtime
40+
// and replace it with MicrosoftNETCoreAppRefPackageVersion.
41+
[Required] public string MicrosoftNETILLinkTasksPackageVersion { get; set; }
42+
3843
[Required] public string NewSDKVersion { get; set; }
3944

4045
[Required] public string OutputPath { get; set; }
@@ -45,13 +50,15 @@ public override bool Execute()
4550
ExecuteInternal(
4651
File.ReadAllText(Stage0MicrosoftNETCoreAppRefPackageVersionPath),
4752
MicrosoftNETCoreAppRefPackageVersion,
53+
MicrosoftNETILLinkTasksPackageVersion,
4854
NewSDKVersion));
4955
return true;
5056
}
5157

5258
public static string ExecuteInternal(
5359
string stage0MicrosoftNETCoreAppRefPackageVersionContent,
5460
string microsoftNETCoreAppRefPackageVersion,
61+
string microsoftNETILLinkTasksPackageVersion,
5562
string newSDKVersion)
5663
{
5764
var projectXml = XDocument.Parse(stage0MicrosoftNETCoreAppRefPackageVersionContent);
@@ -126,6 +133,24 @@ void CheckAndReplaceAttribute(XAttribute attribute)
126133
CheckAndReplaceAttribute(itemGroup
127134
.Elements(ns + "KnownRuntimePack").First().Attribute("LatestRuntimeFrameworkVersion"));
128135

136+
// TODO: remove this once we're using an SDK that contains KnownILLinkPack: https://github.com/dotnet/installer/pull/15106
137+
{
138+
itemGroup.Add(new XElement(ns + "KnownILLinkPack",
139+
new XAttribute("Include", "Microsoft.NET.ILLink.Tasks"),
140+
new XAttribute("TargetFramework", "net8.0"),
141+
new XAttribute("ILLinkPackVersion", microsoftNETILLinkTasksPackageVersion)));
142+
143+
// Use 7.0 linker when targeting supported RIDS <= net7.0.
144+
var net70Version = "7.0.100-1.22579.2";
145+
146+
foreach (var tfm in new[] { "net7.0", "net6.0", "net5.0", "netcoreapp3.1", "netcoreapp3.0" }) {
147+
itemGroup.Add(new XElement(ns + "KnownILLinkPack",
148+
new XAttribute("Include", "Microsoft.NET.ILLink.Tasks"),
149+
new XAttribute("TargetFramework", tfm),
150+
new XAttribute("ILLinkPackVersion", net70Version)));
151+
}
152+
}
153+
129154
return projectXml.ToString();
130155
}
131156

src/Tasks/Common/Resources/Strings.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,4 +883,8 @@ You may need to build the project on another operating system or architecture, o
883883
<value>NETSDK1194: The "--output" option isn't supported when building a solution.</value>
884884
<comment>{StrBegin="NETSDK1194: "}</comment>
885885
</data>
886+
<data name="ILLinkNoValidRuntimePackageError" xml:space="preserve">
887+
<value>NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</value>
888+
<comment>{StrBegin="NETSDK1195: "}</comment>
889+
</data>
886890
</root>

src/Tasks/Common/Resources/xlf/Strings.cs.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
<target state="translated">NETSDK1144: Optimalizace velikosti sestavení neproběhla úspěšně. Optimalizaci je možné zakázat tím, že se nastaví vlastnost PublishTrimmed na false.</target>
455455
<note>{StrBegin="NETSDK1144: "}</note>
456456
</trans-unit>
457+
<trans-unit id="ILLinkNoValidRuntimePackageError">
458+
<source>NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</source>
459+
<target state="new">NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</target>
460+
<note>{StrBegin="NETSDK1195: "}</note>
461+
</trans-unit>
457462
<trans-unit id="ILLinkNotSupportedError">
458463
<source>NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.</source>
459464
<target state="translated">NETSDK1102: Pro vybranou konfiguraci publikování se optimalizace velikosti sestavení nepodporuje. Ujistěte se, že publikujete samostatnou aplikaci.</target>

src/Tasks/Common/Resources/xlf/Strings.de.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
<target state="translated">NETSDK1144: Fehler bei der Größenoptimierung von Assemblys. Die Optimierung kann durch Festlegen der PublishTrimmed-Eigenschaft auf FALSE deaktiviert werden.</target>
455455
<note>{StrBegin="NETSDK1144: "}</note>
456456
</trans-unit>
457+
<trans-unit id="ILLinkNoValidRuntimePackageError">
458+
<source>NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</source>
459+
<target state="new">NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</target>
460+
<note>{StrBegin="NETSDK1195: "}</note>
461+
</trans-unit>
457462
<trans-unit id="ILLinkNotSupportedError">
458463
<source>NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.</source>
459464
<target state="translated">NETSDK1102: Die Größenoptimierung von Assemblys wird für die ausgewählte Veröffentlichungskonfiguration nicht unterstützt. Stellen Sie sicher, dass Sie eine eigenständige App veröffentlichen.</target>

src/Tasks/Common/Resources/xlf/Strings.es.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
<target state="translated">NETSDK1144: Error al optimizar el tamaño de los ensamblados. Para deshabilitar la optimización, establezca la propiedad PublishTrimmed en false.</target>
455455
<note>{StrBegin="NETSDK1144: "}</note>
456456
</trans-unit>
457+
<trans-unit id="ILLinkNoValidRuntimePackageError">
458+
<source>NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</source>
459+
<target state="new">NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</target>
460+
<note>{StrBegin="NETSDK1195: "}</note>
461+
</trans-unit>
457462
<trans-unit id="ILLinkNotSupportedError">
458463
<source>NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.</source>
459464
<target state="translated">NETSDK1102: No se admite la optimización de tamaño de los ensamblados para la configuración de publicación seleccionada. Asegúrese de que está publicando una aplicación autónoma.</target>

src/Tasks/Common/Resources/xlf/Strings.fr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
<target state="translated">NETSDK1144: L'optimisation de la taille des assemblys a échoué. Vous pouvez désactiver l'optimisation en affectant à la propriété PublishTrimmed la valeur false.</target>
455455
<note>{StrBegin="NETSDK1144: "}</note>
456456
</trans-unit>
457+
<trans-unit id="ILLinkNoValidRuntimePackageError">
458+
<source>NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</source>
459+
<target state="new">NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</target>
460+
<note>{StrBegin="NETSDK1195: "}</note>
461+
</trans-unit>
457462
<trans-unit id="ILLinkNotSupportedError">
458463
<source>NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.</source>
459464
<target state="translated">NETSDK1102: l'optimisation de la taille des assemblys n'est pas prise en charge pour la configuration de publication sélectionnée. Vérifiez que vous publiez une application autonome.</target>

src/Tasks/Common/Resources/xlf/Strings.it.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
<target state="translated">NETSDK1144: l'ottimizzazione degli assembly per le dimensioni non è riuscita. È possibile disabilitare l'ottimizzazione impostando la proprietà PublishTrimmed su false.</target>
455455
<note>{StrBegin="NETSDK1144: "}</note>
456456
</trans-unit>
457+
<trans-unit id="ILLinkNoValidRuntimePackageError">
458+
<source>NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</source>
459+
<target state="new">NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</target>
460+
<note>{StrBegin="NETSDK1195: "}</note>
461+
</trans-unit>
457462
<trans-unit id="ILLinkNotSupportedError">
458463
<source>NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.</source>
459464
<target state="translated">NETSDK1102: l'ottimizzazione degli assembly per le dimensioni non è supportata per la configurazione di pubblicazione selezionata. Assicurarsi di pubblicare un'app indipendente.</target>

src/Tasks/Common/Resources/xlf/Strings.ja.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
<target state="translated">NETSDK1144: アセンブリのサイズを最適化できませんでした。PublishTrimmed プロパティを false に設定することにより、最適化を無効にすることができます。</target>
455455
<note>{StrBegin="NETSDK1144: "}</note>
456456
</trans-unit>
457+
<trans-unit id="ILLinkNoValidRuntimePackageError">
458+
<source>NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</source>
459+
<target state="new">NETSDK1195: Unable to optimize assemblies for size: a valid runtime package was not found. Either set the PublishTrimmed property to false, or use a supported target framework when publishing.</target>
460+
<note>{StrBegin="NETSDK1195: "}</note>
461+
</trans-unit>
457462
<trans-unit id="ILLinkNotSupportedError">
458463
<source>NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.</source>
459464
<target state="translated">NETSDK1102: アセンブリのサイズの最適化は、選択された公開構成に対してはサポートされていません。自己完結型のアプリを公開していることをご確認ください。</target>

0 commit comments

Comments
 (0)