Merge pull request #2016 from dotnet/pakrym/signature
Add runtime signature into deps.json
This commit is contained in:
commit
7a82a98e4c
15 changed files with 187 additions and 78 deletions
|
@ -83,6 +83,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "update-dependencies", "scri
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Cli.Utils.Tests", "test\Microsoft.DotNet.Cli.Utils.Tests\Microsoft.DotNet.Cli.Utils.Tests.xproj", "{09C52F96-EFDD-4448-95EC-6D362DD60BAA}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RuntimeGraphGenerator", "tools\RuntimeGraphGenerator\RuntimeGraphGenerator.xproj", "{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -591,6 +593,22 @@ Global
|
|||
{09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -629,5 +647,6 @@ Global
|
|||
{60C33D0A-A5D8-4AB0-9956-1F804654DF05} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
|
||||
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
||||
{09C52F96-EFDD-4448-95EC-6D362DD60BAA} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
|
||||
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25} = {0722D325-24C8-4E83-B5AF-0A083E7F0749}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"projects": [ "src", "test" ]
|
||||
"projects": [ "src", "test", "tools" ]
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
|
@ -49,16 +51,41 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
var compilationOptions = compilerOptions != null
|
||||
? GetCompilationOptions(compilerOptions)
|
||||
: CompilationOptions.Default;
|
||||
|
||||
var runtimeSignature = GenerateRuntimeSignature(runtimeExports);
|
||||
|
||||
return new DependencyContext(
|
||||
target.DotNetFrameworkName,
|
||||
runtime,
|
||||
portable,
|
||||
new TargetInfo(target.DotNetFrameworkName, runtime, runtimeSignature, portable),
|
||||
compilationOptions,
|
||||
GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>(),
|
||||
GetLibraries(runtimeExports, dependencyLookup, runtime: true).Cast<RuntimeLibrary>(),
|
||||
new RuntimeFallbacks[] {});
|
||||
}
|
||||
|
||||
private static string GenerateRuntimeSignature(IEnumerable<LibraryExport> runtimeExports)
|
||||
{
|
||||
var sha1 = SHA1.Create();
|
||||
var builder = new StringBuilder();
|
||||
var packages = runtimeExports
|
||||
.Where(libraryExport => libraryExport.Library.Identity.Type == LibraryType.Package);
|
||||
var seperator = "|";
|
||||
foreach (var libraryExport in packages)
|
||||
{
|
||||
builder.Append(libraryExport.Library.Identity.Name);
|
||||
builder.Append(seperator);
|
||||
builder.Append(libraryExport.Library.Identity.Version.ToString());
|
||||
builder.Append(seperator);
|
||||
}
|
||||
var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString()));
|
||||
|
||||
builder.Clear();
|
||||
foreach (var b in hash)
|
||||
{
|
||||
builder.AppendFormat("{0:x2}", b);
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static CompilationOptions GetCompilationOptions(CommonCompilerOptions compilerOptions)
|
||||
{
|
||||
return new CompilationOptions(compilerOptions.Defines,
|
||||
|
|
|
@ -10,21 +10,47 @@ using Microsoft.Extensions.PlatformAbstractions;
|
|||
|
||||
namespace Microsoft.Extensions.DependencyModel
|
||||
{
|
||||
public class TargetInfo
|
||||
{
|
||||
public TargetInfo(string framework,
|
||||
string runtime,
|
||||
string runtimeSignature,
|
||||
bool isPortable)
|
||||
{
|
||||
if (string.IsNullOrEmpty(framework))
|
||||
{
|
||||
throw new ArgumentException(nameof(framework));
|
||||
}
|
||||
|
||||
Framework = framework;
|
||||
Runtime = runtime;
|
||||
RuntimeSignature = runtimeSignature;
|
||||
IsPortable = isPortable;
|
||||
}
|
||||
|
||||
public string Framework { get; }
|
||||
|
||||
public string Runtime { get; }
|
||||
|
||||
public string RuntimeSignature { get; }
|
||||
|
||||
public bool IsPortable { get; }
|
||||
|
||||
}
|
||||
|
||||
public class DependencyContext
|
||||
{
|
||||
private static readonly Lazy<DependencyContext> _defaultContext = new Lazy<DependencyContext>(LoadDefault);
|
||||
|
||||
public DependencyContext(string targetFramework,
|
||||
string runtime,
|
||||
bool isPortable,
|
||||
public DependencyContext(TargetInfo target,
|
||||
CompilationOptions compilationOptions,
|
||||
IEnumerable<CompilationLibrary> compileLibraries,
|
||||
IEnumerable<RuntimeLibrary> runtimeLibraries,
|
||||
IEnumerable<RuntimeFallbacks> runtimeGraph)
|
||||
{
|
||||
if (string.IsNullOrEmpty(targetFramework))
|
||||
if (target == null)
|
||||
{
|
||||
throw new ArgumentException(nameof(targetFramework));
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
}
|
||||
if (compilationOptions == null)
|
||||
{
|
||||
|
@ -43,9 +69,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
throw new ArgumentNullException(nameof(runtimeGraph));
|
||||
}
|
||||
|
||||
TargetFramework = targetFramework;
|
||||
Runtime = runtime;
|
||||
IsPortable = isPortable;
|
||||
Target = target;
|
||||
CompilationOptions = compilationOptions;
|
||||
CompileLibraries = compileLibraries.ToArray();
|
||||
RuntimeLibraries = runtimeLibraries.ToArray();
|
||||
|
@ -54,11 +78,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
public static DependencyContext Default => _defaultContext.Value;
|
||||
|
||||
public string TargetFramework { get; }
|
||||
|
||||
public string Runtime { get; }
|
||||
|
||||
public bool IsPortable { get; }
|
||||
public TargetInfo Target { get; }
|
||||
|
||||
public CompilationOptions CompilationOptions { get; }
|
||||
|
||||
|
@ -76,9 +96,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
|
||||
return new DependencyContext(
|
||||
TargetFramework,
|
||||
Runtime,
|
||||
IsPortable,
|
||||
Target,
|
||||
CompilationOptions,
|
||||
CompileLibraries.Union(other.CompileLibraries, new LibraryMergeEqualityComparer<CompilationLibrary>()),
|
||||
RuntimeLibraries.Union(other.RuntimeLibraries, new LibraryMergeEqualityComparer<RuntimeLibrary>()),
|
||||
|
|
|
@ -35,8 +35,22 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
var runtime = string.Empty;
|
||||
var target = string.Empty;
|
||||
var isPortable = true;
|
||||
string runtimeTargetName = null;
|
||||
string runtimeSignature = null;
|
||||
|
||||
var runtimeTargetName = root[DependencyContextStrings.RuntimeTargetPropertyName]?.Value<string>();
|
||||
var runtimeTargetInfo = root[DependencyContextStrings.RuntimeTargetPropertyName];
|
||||
|
||||
// This fallback is temporary
|
||||
if (runtimeTargetInfo is JValue)
|
||||
{
|
||||
runtimeTargetName = runtimeTargetInfo.Value<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
var runtimeTargetObject = (JObject) runtimeTargetInfo;
|
||||
runtimeTargetName = runtimeTargetObject?[DependencyContextStrings.RuntimeTargetNamePropertyName]?.Value<string>();
|
||||
runtimeSignature = runtimeTargetObject?[DependencyContextStrings.RuntimeTargetSignaturePropertyName]?.Value<string>();
|
||||
}
|
||||
|
||||
var libraryStubs = ReadLibraryStubs((JObject)root[DependencyContextStrings.LibrariesPropertyName]);
|
||||
var targetsObject = (JObject)root[DependencyContextStrings.TargetsPropertyName];
|
||||
|
@ -98,9 +112,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
|
||||
return new DependencyContext(
|
||||
target,
|
||||
runtime,
|
||||
isPortable,
|
||||
new TargetInfo(target, runtime, runtimeSignature, isPortable),
|
||||
ReadCompilationOptions((JObject)root[DependencyContextStrings.CompilationOptionsPropertName]),
|
||||
ReadLibraries(compileTarget, false, libraryStubs).Cast<CompilationLibrary>().ToArray(),
|
||||
ReadLibraries(runtimeTarget, true, libraryStubs).Cast<RuntimeLibrary>().ToArray(),
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
context = LoadAssemblyContext(assembly);
|
||||
}
|
||||
|
||||
if (context?.IsPortable == true)
|
||||
if (context?.Target.IsPortable == true)
|
||||
{
|
||||
var runtimeContext = LoadRuntimeContext();
|
||||
if (runtimeContext != null)
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
internal const string RuntimeTargetNamePropertyName = "name";
|
||||
|
||||
internal const string RuntimeTargetSignaturePropertyName = "signature";
|
||||
|
||||
internal const string RuntimesPropertyName = "runtimes";
|
||||
|
||||
internal const string RuntimeTargetsPropertyName = "runtimeTargets";
|
||||
|
|
|
@ -48,11 +48,18 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
return contextObject;
|
||||
}
|
||||
|
||||
private string WriteRuntimeTargetInfo(DependencyContext context)
|
||||
private JObject WriteRuntimeTargetInfo(DependencyContext context)
|
||||
{
|
||||
return context.IsPortable ?
|
||||
context.TargetFramework :
|
||||
context.TargetFramework + DependencyContextStrings.VersionSeperator + context.Runtime;
|
||||
return new JObject(
|
||||
new JProperty(DependencyContextStrings.RuntimeTargetNamePropertyName,
|
||||
context.Target.IsPortable ?
|
||||
context.Target.Framework :
|
||||
context.Target.Framework + DependencyContextStrings.VersionSeperator + context.Target.Runtime
|
||||
),
|
||||
new JProperty(DependencyContextStrings.RuntimeTargetSignaturePropertyName,
|
||||
context.Target.RuntimeSignature
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private JObject WriteRuntimeGraph(DependencyContext context)
|
||||
|
@ -93,16 +100,16 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
private JObject WriteTargets(DependencyContext context)
|
||||
{
|
||||
if (context.IsPortable)
|
||||
if (context.Target.IsPortable)
|
||||
{
|
||||
return new JObject(
|
||||
new JProperty(context.TargetFramework, WritePortableTarget(context.RuntimeLibraries, context.CompileLibraries))
|
||||
new JProperty(context.Target.Framework, WritePortableTarget(context.RuntimeLibraries, context.CompileLibraries))
|
||||
);
|
||||
}
|
||||
|
||||
return new JObject(
|
||||
new JProperty(context.TargetFramework, WriteTarget(context.CompileLibraries)),
|
||||
new JProperty(context.TargetFramework + DependencyContextStrings.VersionSeperator + context.Runtime,
|
||||
new JProperty(context.Target.Framework, WriteTarget(context.CompileLibraries)),
|
||||
new JProperty(context.Target.Framework + DependencyContextStrings.VersionSeperator + context.Target.Runtime,
|
||||
WriteTarget(context.RuntimeLibraries))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -336,7 +336,10 @@ bool deps_json_t::load(bool portable, const pal::string_t& deps_path, const rid_
|
|||
const auto json = json_value::parse(file);
|
||||
|
||||
const auto& runtime_target = json.at(_X("runtimeTarget"));
|
||||
const pal::string_t& name = runtime_target.as_string();
|
||||
|
||||
const pal::string_t& name = runtime_target.is_string()?
|
||||
runtime_target.as_string():
|
||||
runtime_target.at(_X("name")).as_string();
|
||||
|
||||
trace::verbose(_X("Loading deps file... %s as portable=[%d]"), deps_path.c_str(), portable);
|
||||
|
||||
|
|
|
@ -84,15 +84,15 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
{
|
||||
var context = Build(portable: true);
|
||||
|
||||
context.IsPortable.Should().BeTrue();
|
||||
context.Target.IsPortable.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FillsRuntimeAndTarget()
|
||||
{
|
||||
var context = Build(target: new NuGetFramework("SomeFramework",new Version(1,2)), runtime: "win8-x86");
|
||||
context.Runtime.Should().Be("win8-x86");
|
||||
context.TargetFramework.Should().Be("SomeFramework,Version=v1.2");
|
||||
context.Target.Runtime.Should().Be("win8-x86");
|
||||
context.Target.Framework.Should().Be("SomeFramework,Version=v1.2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -291,6 +291,19 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
lib.Dependencies.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesRuntimeSignatureOutOfPackageNamesAndVersions()
|
||||
{
|
||||
var context = Build(runtimeExports: new[]
|
||||
{
|
||||
Export(PackageDescription("Pack.Age", new NuGetVersion(1, 2, 3))),
|
||||
Export(PackageDescription("Pack.Age", new NuGetVersion(1, 2, 3))),
|
||||
});
|
||||
|
||||
context.Target.RuntimeSignature.Should().Be("d0fc00006ed69e4aae80383dda08599a6892fd31");
|
||||
}
|
||||
|
||||
|
||||
private LibraryExport Export(
|
||||
LibraryDescription description,
|
||||
IEnumerable<LibraryAsset> compilationAssemblies = null,
|
||||
|
|
|
@ -25,14 +25,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
{
|
||||
var context = Read(
|
||||
@"{
|
||||
""runtimeTarget"": "".NETStandardApp,Version=v1.5/osx.10.10-x64"",
|
||||
""runtimeTarget"": {
|
||||
""name"":"".NETStandardApp,Version=v1.5/osx.10.10-x64""
|
||||
},
|
||||
""targets"": {
|
||||
"".NETStandardApp,Version=v1.5/osx.10.10-x64"": {},
|
||||
}
|
||||
}");
|
||||
context.IsPortable.Should().BeFalse();
|
||||
context.TargetFramework.Should().Be(".NETStandardApp,Version=v1.5");
|
||||
context.Runtime.Should().Be("osx.10.10-x64");
|
||||
context.Target.IsPortable.Should().BeFalse();
|
||||
context.Target.Framework.Should().Be(".NETStandardApp,Version=v1.5");
|
||||
context.Target.Runtime.Should().Be("osx.10.10-x64");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -44,7 +46,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"".NETStandardApp,Version=v1.5"": {}
|
||||
}
|
||||
}");
|
||||
context.IsPortable.Should().BeTrue();
|
||||
context.Target.IsPortable.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -52,12 +54,14 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
{
|
||||
var context = Read(
|
||||
@"{
|
||||
""runtimeTarget"": "".NETStandardApp,Version=v1.5/osx.10.10-x64"",
|
||||
""runtimeTarget"": {
|
||||
""name"": "".NETStandardApp,Version=v1.5/osx.10.10-x64""
|
||||
},
|
||||
""targets"": {
|
||||
"".NETStandardApp,Version=v1.5/osx.10.10-x64"": {}
|
||||
}
|
||||
}");
|
||||
context.IsPortable.Should().BeFalse();
|
||||
context.Target.IsPortable.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -69,7 +73,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"".NETStandardApp,Version=v1.5"": {}
|
||||
}
|
||||
}");
|
||||
context.TargetFramework.Should().Be(".NETStandardApp,Version=v1.5");
|
||||
context.Target.Framework.Should().Be(".NETStandardApp,Version=v1.5");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -152,7 +156,9 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
{
|
||||
var context = Read(
|
||||
@"{
|
||||
""runtimeTarget"": "".NETStandardApp,Version=v1.5"",
|
||||
""runtimeTarget"": {
|
||||
""name"": "".NETStandardApp,Version=v1.5""
|
||||
},
|
||||
""targets"": {
|
||||
"".NETStandardApp,Version=v1.5"": {
|
||||
""MyApp/1.0.1"": {
|
||||
|
|
|
@ -37,12 +37,14 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
CompilationOptions compilationOptions = null,
|
||||
CompilationLibrary[] compileLibraries = null,
|
||||
RuntimeLibrary[] runtimeLibraries = null,
|
||||
IReadOnlyList<RuntimeFallbacks> runtimeGraph = null)
|
||||
IReadOnlyList<RuntimeFallbacks> runtimeGraph = null,
|
||||
string runtimeSignature = null)
|
||||
{
|
||||
return new DependencyContext(
|
||||
return new DependencyContext(new TargetInfo(
|
||||
target ?? "DefaultTarget",
|
||||
runtime ?? string.Empty,
|
||||
isPortable ?? false,
|
||||
runtimeSignature ?? string.Empty,
|
||||
isPortable ?? false),
|
||||
compilationOptions ?? CompilationOptions.Default,
|
||||
compileLibraries ?? new CompilationLibrary[0],
|
||||
runtimeLibraries ?? new RuntimeLibrary[0],
|
||||
|
@ -80,10 +82,13 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
var result = Save(Create(
|
||||
"Target",
|
||||
"runtime",
|
||||
false)
|
||||
false,
|
||||
runtimeSignature: "runtimeSignature")
|
||||
);
|
||||
|
||||
result.Should().HavePropertyValue("runtimeTarget", "Target/runtime");
|
||||
result.Should().HavePropertyAsObject("runtimeTarget")
|
||||
.Which.Should().HavePropertyValue("name", "Target/runtime");
|
||||
result.Should().HavePropertyAsObject("runtimeTarget")
|
||||
.Which.Should().HavePropertyValue("signature", "runtimeSignature");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -92,9 +97,13 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
var result = Save(Create(
|
||||
"Target",
|
||||
"runtime",
|
||||
true)
|
||||
true,
|
||||
runtimeSignature: "runtimeSignature")
|
||||
);
|
||||
result.Should().HavePropertyValue("runtimeTarget", "Target");
|
||||
result.Should().HavePropertyAsObject("runtimeTarget")
|
||||
.Which.Should().HavePropertyValue("name", "Target");
|
||||
result.Should().HavePropertyAsObject("runtimeTarget")
|
||||
.Which.Should().HavePropertyValue("signature", "runtimeSignature");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -39,18 +39,14 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
};
|
||||
|
||||
var context = new DependencyContext(
|
||||
"Framework",
|
||||
"runtime",
|
||||
true,
|
||||
CreateTargetInfo(),
|
||||
CompilationOptions.Default,
|
||||
compilationLibraries,
|
||||
runtimeLibraries,
|
||||
new RuntimeFallbacks[] { });
|
||||
|
||||
var contextRedist = new DependencyContext(
|
||||
"Framework",
|
||||
"runtime",
|
||||
true,
|
||||
CreateTargetInfo(),
|
||||
CompilationOptions.Default,
|
||||
compilationLibrariesRedist,
|
||||
runtimeLibrariesRedist,
|
||||
|
@ -76,9 +72,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
public void MergeMergesRuntimeGraph()
|
||||
{
|
||||
var context = new DependencyContext(
|
||||
"Framework",
|
||||
"runtime",
|
||||
true,
|
||||
CreateTargetInfo(),
|
||||
CompilationOptions.Default,
|
||||
Enumerable.Empty<CompilationLibrary>(),
|
||||
Enumerable.Empty<RuntimeLibrary>(),
|
||||
|
@ -88,9 +82,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
});
|
||||
|
||||
var contextRedist = new DependencyContext(
|
||||
"Framework",
|
||||
"runtime",
|
||||
true,
|
||||
CreateTargetInfo(),
|
||||
CompilationOptions.Default,
|
||||
Enumerable.Empty<CompilationLibrary>(),
|
||||
Enumerable.Empty<RuntimeLibrary>(),
|
||||
|
@ -106,6 +98,15 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
Subject.Fallbacks.Should().BeEquivalentTo("win7-x64", "win7-x86");
|
||||
}
|
||||
|
||||
private TargetInfo CreateTargetInfo()
|
||||
{
|
||||
return new TargetInfo(
|
||||
"Framework",
|
||||
"runtime",
|
||||
"runtimeSignature",
|
||||
true);
|
||||
}
|
||||
|
||||
private CompilationLibrary CreateCompilation(string name)
|
||||
{
|
||||
return new CompilationLibrary(
|
||||
|
|
|
@ -16,10 +16,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
[InlineData("FlibbidyFlob", "FlibbidyFlob")]
|
||||
public void GetRuntimeAssemblyNamesExtractsCorrectAssemblyName(string path, string expected)
|
||||
{
|
||||
var context = new DependencyContext(
|
||||
".NETStandard,Version=v1.3",
|
||||
string.Empty,
|
||||
isPortable: true,
|
||||
var context = new DependencyContext(new TargetInfo(".NETStandard,Version=v1.3", string.Empty, string.Empty, true),
|
||||
compilationOptions: CompilationOptions.Default,
|
||||
compileLibraries: new CompilationLibrary[] { },
|
||||
runtimeLibraries: new[] {
|
||||
|
@ -94,10 +91,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
|
||||
private DependencyContext BuildTestContext()
|
||||
{
|
||||
return new DependencyContext(
|
||||
".NETStandard,Version=v1.3",
|
||||
string.Empty,
|
||||
isPortable: true,
|
||||
return new DependencyContext(new TargetInfo(".NETStandard,Version=v1.3", string.Empty, string.Empty, true),
|
||||
compilationOptions: CompilationOptions.Default,
|
||||
compileLibraries: new[]
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace RuntimeGraphGenerator
|
|||
{
|
||||
context = new DependencyContextJsonReader().Read(depsStream);
|
||||
}
|
||||
var framework = NuGetFramework.Parse(context.TargetFramework);
|
||||
var framework = NuGetFramework.Parse(context.Target.Framework);
|
||||
var projectContext = ProjectContext.Create(projectDirectory, framework);
|
||||
|
||||
// Configuration is used only for P2P dependencies so were don't care
|
||||
|
@ -79,9 +79,7 @@ namespace RuntimeGraphGenerator
|
|||
var expandedGraph = manager.Expand(graph, runtimes);
|
||||
|
||||
context = new DependencyContext(
|
||||
context.TargetFramework,
|
||||
context.Runtime,
|
||||
context.IsPortable,
|
||||
context.Target,
|
||||
context.CompilationOptions,
|
||||
context.CompileLibraries,
|
||||
context.RuntimeLibraries,
|
||||
|
|
Loading…
Reference in a new issue