-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adding arch option to tool install command #19370
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
using Microsoft.DotNet.Cli; | ||
using Microsoft.DotNet.Cli.NuGetPackageDownloader; | ||
using Microsoft.DotNet.Cli.Utils; | ||
using Microsoft.DotNet.ToolPackage; | ||
using Microsoft.Extensions.EnvironmentAbstractions; | ||
using NuGet.Frameworks; | ||
using LocalizableStrings = Microsoft.DotNet.Tools.Tool.Install.LocalizableStrings; | ||
|
||
namespace Microsoft.DotNet.ShellShim | ||
{ | ||
internal class ShellShimTemplateFinder | ||
{ | ||
private readonly DirectoryPath _tempDir; | ||
private readonly INuGetPackageDownloader _nugetPackageDownloader; | ||
private readonly PackageSourceLocation _packageSourceLocation; | ||
|
||
public ShellShimTemplateFinder( | ||
INuGetPackageDownloader nugetPackageDownloader, | ||
DirectoryPath tempDir, | ||
PackageSourceLocation packageSourceLocation) | ||
{ | ||
_tempDir = tempDir; | ||
_nugetPackageDownloader = nugetPackageDownloader; | ||
_packageSourceLocation = packageSourceLocation; | ||
} | ||
|
||
public async Task<string> ResolveAppHostSourceDirectoryAsync(string archOption, string targetFramework) | ||
{ | ||
string rid; | ||
var validRids = new string[] { "win-x64", "win-arm64", "osx-x64", "osx-arm64" }; | ||
if (string.IsNullOrEmpty(archOption)) | ||
{ | ||
if (!string.IsNullOrEmpty(targetFramework) && new NuGetFramework(targetFramework).Version < new Version("6.0") | ||
&& (OperatingSystem.IsWindows() || OperatingSystem.IsMacOS()) && !RuntimeInformation.ProcessArchitecture.Equals(Architecture.X64)) | ||
{ | ||
rid = OperatingSystem.IsWindows() ? "win-x64" : "osx-x64"; | ||
} | ||
else | ||
{ | ||
// Use the default app host | ||
return GetDefaultAppHostSourceDirectory(); | ||
} | ||
} | ||
else | ||
{ | ||
rid = CommonOptions.ResolveRidShorthandOptionsToRuntimeIdentifier(null, archOption); | ||
} | ||
|
||
if (!validRids.Contains(rid)) | ||
{ | ||
throw new GracefulException(string.Format(LocalizableStrings.InvalidRuntimeIdentifier, rid, string.Join(" ", validRids))); | ||
} | ||
|
||
var packageId = new PackageId($"microsoft.netcore.app.host.{rid}"); | ||
var packagePath = await _nugetPackageDownloader.DownloadPackageAsync(packageId, packageSourceLocation: _packageSourceLocation); | ||
var content = await _nugetPackageDownloader.ExtractPackageAsync(packagePath, _tempDir); | ||
|
||
return Path.Combine(_tempDir.Value, "runtimes", rid, "native"); | ||
} | ||
|
||
public static string GetDefaultAppHostSourceDirectory() | ||
{ | ||
return Path.Combine(AppContext.BaseDirectory, "AppHostTemplate"); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.