Skip to content

Commit

Permalink
Add switch to disable apphost pack restore (#29137)
Browse files Browse the repository at this point in the history
* Add switch to disable apphost pack restore

Contributes to dotnet/runtime#58109

In dotnet/runtime we live build targeting packs, runtime packs and app host packs. For the former two, switches already exist to disable nuget restore:
- EnableTargetingPackDownload
- EnableRuntimePackDownload

The latter one doesn't yet have such a switch and therefore is always restored by NuGet. In the cases where want to use the live built apphost pack, restore fails, i.e. from a runtime build:

`artifacts/bin/trimmingTests/projects/Microsoft.Extensions.DependencyInjection.TrimmingTests/ActivatorUtilitiesTests/osx-x64/project.csproj(0,0): error NU1102: (NETCORE_ENGINEERING_TELEMETRY=Build) Unable to find package Microsoft.NETCore.App.Host.osx-x64 with version (= 8.0.0)`
  • Loading branch information
ViktorHofer authored Nov 21, 2022
1 parent 2b804b8 commit bb61c2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Tasks/Microsoft.NET.Build.Tasks/ResolveAppHosts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class ResolveAppHosts : TaskBase
public bool NuGetRestoreSupported { get; set; } = true;

public string NetCoreTargetingPackRoot { get; set; }

public bool EnableAppHostPackDownload { get; set; } = true;

[Output]
public ITaskItem[] PackagesToDownload { get; set; }
Expand Down Expand Up @@ -276,7 +278,6 @@ private ITaskItem GetHostItem(string runtimeIdentifier,
string hostRelativePathInPackage = Path.Combine("runtimes", bestAppHostRuntimeIdentifier, "native",
hostNameWithoutExtension + (isExecutable ? ExecutableExtension.ForRuntimeIdentifier(bestAppHostRuntimeIdentifier) : ".dll"));


TaskItem appHostItem = new TaskItem(itemName);
string appHostPackPath = null;
if (!string.IsNullOrEmpty(TargetingPackRoot))
Expand All @@ -289,7 +290,7 @@ private ITaskItem GetHostItem(string runtimeIdentifier,
appHostItem.SetMetadata(MetadataKeys.PackageDirectory, appHostPackPath);
appHostItem.SetMetadata(MetadataKeys.Path, Path.Combine(appHostPackPath, hostRelativePathInPackage));
}
else
else if (EnableAppHostPackDownload)
{
// C++/CLI does not support package download && dedup error
if (!NuGetRestoreSupported && !packagesToDownload.ContainsKey(hostPackName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Copyright (c) .NET Foundation. All rights reserved.
RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)"
KnownAppHostPacks="@(KnownAppHostPack)"
NuGetRestoreSupported="$(_NuGetRestoreSupported)"
EnableAppHostPackDownload="$(EnableAppHostPackDownload)"
NetCoreTargetingPackRoot="$(NetCoreTargetingPackRoot)">

<Output TaskParameter="PackagesToDownload" ItemName="_PackageToDownload" />
Expand Down

0 comments on commit bb61c2e

Please sign in to comment.