Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch to disable apphost pack restore #29137

Merged
merged 6 commits into from
Nov 21, 2022
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
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we set the default value for something like this in an MSBuild property. I'm not entirely sure that this works correctly if the MSBuild property is empty, though if it didn't work there would probably some test failures.

Copy link
Member Author

@ViktorHofer ViktorHofer Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested that and it works as expected. Also, I just mimicked the NuGetRestoreSupported property which also sets a default property value and is already used.


[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