Skip to content

Commit a85ed8e

Browse files
committed
FB
1 parent a27945a commit a85ed8e

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ public class ProcessFrameworkReferences : TaskBase
9999
public ITaskItem[] Crossgen2Packs { get; set; }
100100

101101
[Output]
102-
public ITaskItem[] ILCompilerPacks { get; set; }
102+
public ITaskItem[] HostILCompilerPacks { get; set; }
103103

104104
[Output]
105-
public ITaskItem[] ILCompilerPacks2 { get; set; }
105+
public ITaskItem[] TargetILCompilerPacks { get; set; }
106106

107107
// Runtime packs which aren't available for the specified RuntimeIdentifier
108108
[Output]
@@ -620,20 +620,28 @@ private bool AddAotOrR2RRuntimePackage(AotPackageType packageType, Version norma
620620
}
621621
else
622622
{
623-
ILCompilerPacks = new[] { newItem };
623+
HostILCompilerPacks = new[] { newItem };
624624
// ILCompiler supports cross target compilation. If there is a cross-target request, we need to download that package as well
625-
var targetsRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, RuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph2);
626-
if (!hostRuntimeIdentifier.Equals(targetsRuntimeIdentifier))
627-
{
628-
var runtimeIlcPackName = packPattern.Replace("**RID**", targetsRuntimeIdentifier);
629-
TaskItem runtime2PackToDownload = new TaskItem(runtimeIlcPackName);
630-
runtime2PackToDownload.SetMetadata(MetadataKeys.Version, packVersion);
631-
packagesToDownload.Add(runtime2PackToDownload);
632-
633-
var newItem2 = new TaskItem(runtimeIlcPackName);
634-
newItem2.SetMetadata(MetadataKeys.NuGetPackageId, runtimeIlcPackName);
635-
newItem2.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);
636-
ILCompilerPacks2 = new[] { newItem2 };
625+
// We expect RuntimeIdentifier to be defined during publish but can allow during build
626+
if (RuntimeIdentifier != null)
627+
{
628+
var targetsRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, RuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph2);
629+
if (targetsRuntimeIdentifier == null)
630+
{
631+
return false;
632+
}
633+
if (!hostRuntimeIdentifier.Equals(targetsRuntimeIdentifier))
634+
{
635+
var runtimeIlcPackName = packPattern.Replace("**RID**", targetsRuntimeIdentifier);
636+
TaskItem runtime2PackToDownload = new TaskItem(runtimeIlcPackName);
637+
runtime2PackToDownload.SetMetadata(MetadataKeys.Version, packVersion);
638+
packagesToDownload.Add(runtime2PackToDownload);
639+
640+
var newItem2 = new TaskItem(runtimeIlcPackName);
641+
newItem2.SetMetadata(MetadataKeys.NuGetPackageId, runtimeIlcPackName);
642+
newItem2.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);
643+
TargetILCompilerPacks = new[] { newItem2 };
644+
}
637645
}
638646
}
639647

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ Copyright (c) .NET Foundation. All rights reserved.
120120
<Output TaskParameter="TargetingPacks" ItemName="TargetingPack" />
121121
<Output TaskParameter="RuntimePacks" ItemName="RuntimePack" />
122122
<Output TaskParameter="Crossgen2Packs" ItemName="Crossgen2Pack" />
123-
<Output TaskParameter="ILCompilerPacks" ItemName="ILCompilerPack" />
124-
<Output TaskParameter="ILCompilerPacks2" ItemName="ILCompilerPack2" />
123+
<Output TaskParameter="HostILCompilerPacks" ItemName="HostILCompilerPack" />
124+
<Output TaskParameter="TargetILCompilerPacks" ItemName="TargetILCompilerPack" />
125125
<Output TaskParameter="UnavailableRuntimePacks" ItemName="UnavailableRuntimePack" />
126126

127127
</ProcessFrameworkReferences>
@@ -253,17 +253,17 @@ Copyright (c) .NET Foundation. All rights reserved.
253253
</GetPackageDirectory>
254254

255255
<GetPackageDirectory
256-
Items="@(ILCompilerPack)"
256+
Items="@(HostILCompilerPack)"
257257
PackageFolders="@(AssetsFilePackageFolder)">
258258

259259
<Output TaskParameter="Output" ItemName="ResolvedILCompilerPack" />
260260
</GetPackageDirectory>
261261

262262
<GetPackageDirectory
263-
Items="@(ILCompilerPack2)"
263+
Items="@(TargetILCompilerPack)"
264264
PackageFolders="@(AssetsFilePackageFolder)">
265265

266-
<Output TaskParameter="Output" ItemName="ResolvedILCompilerPack2" />
266+
<Output TaskParameter="Output" ItemName="ResolvedTargetILCompilerPack" />
267267
</GetPackageDirectory>
268268

269269
<GetPackageDirectory

src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string
280280
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
281281
{
282282
testProject.AdditionalProperties["StripSymbols"] = "true";
283-
testProject.AdditionalProperties["ObjCopyName"] = "objcopy";
284283
}
285284
var testAsset = _testAssetsManager.CreateTestProject(testProject);
286285

@@ -328,7 +327,6 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_empty(string t
328327
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
329328
{
330329
testProject.AdditionalProperties["StripSymbols"] = "true";
331-
testProject.AdditionalProperties["ObjCopyName"] = "objcopy";
332330
}
333331
var testAsset = _testAssetsManager.CreateTestProject(testProject);
334332

0 commit comments

Comments
 (0)