Changing the rules on when to use the CLI's BuildRid.
Use the CLI's BuildRid when the current machine is not supported by the shared framework.
This commit is contained in:
parent
ce6c29676d
commit
283bf7139e
3 changed files with 70 additions and 9 deletions
45
src/Microsoft.DotNet.Cli.Utils/FrameworkDependencyFile.cs
Normal file
45
src/Microsoft.DotNet.Cli.Utils/FrameworkDependencyFile.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
// 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.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the .deps.json file in the shared framework
|
||||
/// that the CLI is running against.
|
||||
/// </summary>
|
||||
internal class FrameworkDependencyFile
|
||||
{
|
||||
private readonly string _depsFilePath;
|
||||
|
||||
public FrameworkDependencyFile()
|
||||
{
|
||||
_depsFilePath = Muxer.GetDataFromAppDomain("FX_DEPS_FILE");
|
||||
}
|
||||
|
||||
public bool IsCurrentRuntimeSupported()
|
||||
{
|
||||
return IsRuntimeSupported(RuntimeEnvironment.GetRuntimeIdentifier());
|
||||
}
|
||||
|
||||
public bool IsRuntimeSupported(string runtimeIdentifier)
|
||||
{
|
||||
DependencyContext fxDependencyContext = CreateDependencyContext();
|
||||
|
||||
return fxDependencyContext.RuntimeGraph.Any(g => g.Runtime == runtimeIdentifier);
|
||||
}
|
||||
|
||||
private DependencyContext CreateDependencyContext()
|
||||
{
|
||||
using (Stream depsFileStream = File.OpenRead(_depsFilePath))
|
||||
using (DependencyContextJsonReader reader = new DependencyContextJsonReader())
|
||||
{
|
||||
return reader.Read(depsFileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue