parent
b84832bd8d
commit
dd51836aac
10 changed files with 248 additions and 39 deletions
|
@ -21,8 +21,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.ProjectMod
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.Testing.Abstractions", "src\Microsoft.Extensions.Testing.Abstractions\Microsoft.Extensions.Testing.Abstractions.xproj", "{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.Testing.Abstractions", "src\Microsoft.Extensions.Testing.Abstractions\Microsoft.Extensions.Testing.Abstractions.xproj", "{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.ProjectModel.Loader", "src\Microsoft.DotNet.ProjectModel.Loader\Microsoft.DotNet.ProjectModel.Loader.xproj", "{C7AF0290-EF0D-44DC-9EDC-600803B664F8}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{0722D325-24C8-4E83-B5AF-0A083E7F0749}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{0722D325-24C8-4E83-B5AF-0A083E7F0749}"
|
||||||
|
@ -113,6 +111,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "shared-build-targets-utils"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "update-dependencies", "build_projects\update-dependencies\update-dependencies.xproj", "{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "update-dependencies", "build_projects\update-dependencies\update-dependencies.xproj", "{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.ProjectModel.Loader", "src\Microsoft.DotNet.ProjectModel.Loader\Microsoft.DotNet.ProjectModel.Loader.xproj", "{1C599FFD-FB52-4279-A8E5-465D3EC499E1}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.ProjectModel.Loader.Tests", "test\Microsoft.DotNet.ProjectModel.Loader.Tests\Microsoft.DotNet.ProjectModel.Loader.Tests.xproj", "{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -205,22 +207,6 @@ Global
|
||||||
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||||
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||||
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
|
||||||
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85}.Debug|x64.ActiveCfg = Debug|Any CPU
|
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
@ -813,6 +799,54 @@ Global
|
||||||
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||||
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||||
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -823,7 +857,6 @@ Global
|
||||||
{A16958E1-24C7-4F1E-B317-204AD91625DD} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
{A16958E1-24C7-4F1E-B317-204AD91625DD} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||||
{BD7833F8-3209-4682-BF75-B4BCA883E279} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
{BD7833F8-3209-4682-BF75-B4BCA883E279} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||||
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||||
{C7AF0290-EF0D-44DC-9EDC-600803B664F8} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
|
||||||
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85} = {0722D325-24C8-4E83-B5AF-0A083E7F0749}
|
{08A68C6A-86F6-4ED2-89A7-B166D33E9F85} = {0722D325-24C8-4E83-B5AF-0A083E7F0749}
|
||||||
{688870C8-9843-4F9E-8576-D39290AD0F25} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
{688870C8-9843-4F9E-8576-D39290AD0F25} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
|
{65741CB1-8AEE-4C66-8198-10A7EA0E4258} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
|
||||||
|
@ -866,5 +899,8 @@ Global
|
||||||
{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
||||||
{B768BD29-12BF-4C7C-B093-03193FE244D1} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
{B768BD29-12BF-4C7C-B093-03193FE244D1} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
||||||
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
||||||
|
{1DBB7542-0345-4F4B-A84B-3B00B185D416} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
|
||||||
|
{1C599FFD-FB52-4279-A8E5-465D3EC499E1} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||||
|
{5DF6C9DA-6909-4EC0-909E-6913580BB4A4} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -7,14 +7,19 @@ namespace TestProjectWithCultureSpecificResource
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
// This method is consumed by load context tests
|
||||||
|
public static string GetMessage()
|
||||||
{
|
{
|
||||||
var rm = new ResourceManager(
|
var rm = new ResourceManager(
|
||||||
"TestProjectWithCultureSpecificResource.Strings",
|
"TestProjectWithCultureSpecificResource.Strings",
|
||||||
typeof(Program).GetTypeInfo().Assembly);
|
typeof(Program).GetTypeInfo().Assembly);
|
||||||
|
|
||||||
Console.WriteLine(rm.GetString("hello"));
|
return rm.GetString("hello") + Environment.NewLine + rm.GetString("hello", new CultureInfo("fr"));
|
||||||
Console.WriteLine(rm.GetString("hello", new CultureInfo("fr")));
|
}
|
||||||
|
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine(GetMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Loader;
|
using System.Runtime.Loader;
|
||||||
|
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||||
|
using Microsoft.Extensions.DependencyModel;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.ProjectModel.Loader
|
namespace Microsoft.DotNet.ProjectModel.Loader
|
||||||
{
|
{
|
||||||
|
@ -12,38 +15,87 @@ namespace Microsoft.DotNet.ProjectModel.Loader
|
||||||
{
|
{
|
||||||
public static AssemblyLoadContext CreateLoadContext(
|
public static AssemblyLoadContext CreateLoadContext(
|
||||||
this ProjectContext context,
|
this ProjectContext context,
|
||||||
string configuration = "Debug",
|
string configuration) => CreateLoadContext(context, context.RuntimeIdentifier, configuration);
|
||||||
string outputPath = null)
|
|
||||||
|
public static AssemblyLoadContext CreateLoadContext(
|
||||||
|
this ProjectContext context,
|
||||||
|
string runtimeIdentifier,
|
||||||
|
string configuration) => CreateLoadContext(context, runtimeIdentifier, configuration);
|
||||||
|
|
||||||
|
public static AssemblyLoadContext CreateLoadContext(
|
||||||
|
this ProjectContext context,
|
||||||
|
string runtimeIdentifier,
|
||||||
|
string configuration,
|
||||||
|
string outputPath)
|
||||||
{
|
{
|
||||||
var exporter = context.CreateExporter(configuration);
|
var exporter = context.CreateExporter(configuration);
|
||||||
var assemblies = new Dictionary<AssemblyName, string>(AssemblyNameComparer.OrdinalIgnoreCase);
|
var assemblies = new Dictionary<AssemblyName, string>(AssemblyNameComparer.OrdinalIgnoreCase);
|
||||||
var dllImports = new Dictionary<string, string>();
|
var nativeLibs = new Dictionary<string, string>();
|
||||||
|
var rids = DependencyContext.Default?.RuntimeGraph ?? Enumerable.Empty<RuntimeFallbacks>();
|
||||||
|
var fallbacks = rids.FirstOrDefault(r => r.Runtime.Equals(runtimeIdentifier));
|
||||||
|
|
||||||
foreach (var export in exporter.GetAllExports())
|
foreach (var export in exporter.GetAllExports())
|
||||||
{
|
{
|
||||||
// TODO: Handle resource assemblies
|
// Process managed assets
|
||||||
foreach (var asset in export.RuntimeAssemblyGroups.GetDefaultAssets())
|
var group = string.IsNullOrEmpty(runtimeIdentifier) ?
|
||||||
|
export.RuntimeAssemblyGroups.GetDefaultGroup() :
|
||||||
|
GetGroup(export.RuntimeAssemblyGroups, runtimeIdentifier, fallbacks);
|
||||||
|
if(group != null)
|
||||||
{
|
{
|
||||||
// REVIEW: Should we use the following?
|
foreach(var asset in group.Assets)
|
||||||
// AssemblyLoadContext.GetAssemblyName(asset.ResolvedPath);
|
{
|
||||||
var assemblyName = new AssemblyName(asset.Name);
|
assemblies[asset.GetAssemblyName()] = asset.ResolvedPath;
|
||||||
assemblies[assemblyName] = asset.ResolvedPath;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var asset in export.NativeLibraryGroups.GetDefaultAssets())
|
// Process native assets
|
||||||
|
group = string.IsNullOrEmpty(runtimeIdentifier) ?
|
||||||
|
export.NativeLibraryGroups.GetDefaultGroup() :
|
||||||
|
GetGroup(export.NativeLibraryGroups, runtimeIdentifier, fallbacks);
|
||||||
|
if(group != null)
|
||||||
{
|
{
|
||||||
dllImports[asset.Name] = asset.ResolvedPath;
|
foreach(var asset in group.Assets)
|
||||||
|
{
|
||||||
|
nativeLibs[asset.Name] = asset.ResolvedPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process resource assets
|
||||||
|
foreach(var asset in export.ResourceAssemblies)
|
||||||
|
{
|
||||||
|
var name = asset.Asset.GetAssemblyName();
|
||||||
|
name.CultureName = asset.Locale;
|
||||||
|
assemblies[name] = asset.Asset.ResolvedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ProjectLoadContext(
|
return new ProjectLoadContext(
|
||||||
assemblies,
|
assemblies,
|
||||||
dllImports,
|
nativeLibs,
|
||||||
|
|
||||||
// Add the project's output directory path to ensure project-to-project references get located
|
// Add the project's output directory path to ensure project-to-project references get located
|
||||||
new[] { context.GetOutputPaths(configuration, outputPath: outputPath).CompilationOutputPath });
|
new[] { context.GetOutputPaths(configuration, outputPath: outputPath).CompilationOutputPath });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static LibraryAssetGroup GetGroup(IEnumerable<LibraryAssetGroup> groups, string runtimeIdentifier, RuntimeFallbacks fallbacks)
|
||||||
|
{
|
||||||
|
IEnumerable<string> rids = new[] { runtimeIdentifier };
|
||||||
|
if(fallbacks != null)
|
||||||
|
{
|
||||||
|
rids = Enumerable.Concat(rids, fallbacks.Fallbacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(var rid in rids)
|
||||||
|
{
|
||||||
|
var group = groups.GetRuntimeGroup(rid);
|
||||||
|
if(group != null)
|
||||||
|
{
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private class AssemblyNameComparer : IEqualityComparer<AssemblyName>
|
private class AssemblyNameComparer : IEqualityComparer<AssemblyName>
|
||||||
{
|
{
|
||||||
public static readonly IEqualityComparer<AssemblyName> OrdinalIgnoreCase = new AssemblyNameComparer();
|
public static readonly IEqualityComparer<AssemblyName> OrdinalIgnoreCase = new AssemblyNameComparer();
|
||||||
|
|
|
@ -6,12 +6,11 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>c7af0290-ef0d-44dc-9edc-600803b664f8</ProjectGuid>
|
<ProjectGuid>1c599ffd-fb52-4279-a8e5-465d3ec499e1</ProjectGuid>
|
||||||
<RootNamespace>Microsoft.DotNet.ProjectModel.Loader</RootNamespace>
|
<RootNamespace>Microsoft.DotNet.ProjectModel.Loader</RootNamespace>
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
|
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
// 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.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.ProjectModel.Compilation
|
namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
{
|
{
|
||||||
public static class LibraryAssetExtensions
|
public static class LibraryAssetExtensions
|
||||||
{
|
{
|
||||||
|
private const string NativeImageSufix = ".ni";
|
||||||
|
|
||||||
|
public static AssemblyName GetAssemblyName(this LibraryAsset asset)
|
||||||
|
{
|
||||||
|
var name = asset.Name;
|
||||||
|
if (asset.Name.EndsWith(NativeImageSufix))
|
||||||
|
{
|
||||||
|
name = name.Substring(0, name.Length - NativeImageSufix.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AssemblyName(name);
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetTransformedFile(this LibraryAsset asset, string tempLocation, string tempName = null)
|
public static string GetTransformedFile(this LibraryAsset asset, string tempLocation, string tempName = null)
|
||||||
{
|
{
|
||||||
if (asset.Transform == null)
|
if (asset.Transform == null)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>5df6c9da-6909-4ec0-909e-6913580bb4a4</ProjectGuid>
|
||||||
|
<RootNamespace>Microsoft.DotNet.ProjectModel.Loader.Tests</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
using Microsoft.Extensions.DependencyModel;
|
||||||
|
using NuGet.Frameworks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.ProjectModel.Loader.Tests
|
||||||
|
{
|
||||||
|
public class ProjectLoadContextTest : TestBase
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void LoadContextCanLoadProjectOutput()
|
||||||
|
{
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance("TestProjectWithResource")
|
||||||
|
.WithLockFiles()
|
||||||
|
.WithBuildArtifacts();
|
||||||
|
|
||||||
|
var rid = DependencyContext.Default.Target.Runtime;
|
||||||
|
|
||||||
|
var context = ProjectContext.Create(testInstance.TestRoot, NuGetFramework.Parse("netcoreapp1.0"), new[] { rid });
|
||||||
|
var loadContext = context.CreateLoadContext(rid, Constants.DefaultConfiguration);
|
||||||
|
|
||||||
|
// Load the project assembly
|
||||||
|
var asm = loadContext.LoadFromAssemblyName(new AssemblyName("TestProjectWithResource"));
|
||||||
|
|
||||||
|
// Call Program.GetMessage() and assert the output
|
||||||
|
var message = (string)asm.GetType("TestProjectWithCultureSpecificResource").GetRuntimeMethod("GetMessage", Type.EmptyTypes).Invoke(null, new object[0]);
|
||||||
|
Assert.Equal("Hello World!" + Environment.NewLine + "Bonjour!", message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Microsoft.DotNet.ProjectModel.Loader.Tests")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("5df6c9da-6909-4ec0-909e-6913580bb4a4")]
|
29
test/Microsoft.DotNet.ProjectModel.Loader.Tests/project.json
Normal file
29
test/Microsoft.DotNet.ProjectModel.Loader.Tests/project.json
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"keyFile": "../../tools/test_key.snk"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0-rc3-004363"
|
||||||
|
},
|
||||||
|
"Microsoft.DotNet.ProjectModel.Loader": {
|
||||||
|
"target": "project"
|
||||||
|
},
|
||||||
|
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
||||||
|
"target": "project"
|
||||||
|
},
|
||||||
|
"xunit": "2.1.0",
|
||||||
|
"dotnet-test-xunit": "1.0.0-rc2-192208-24"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": [
|
||||||
|
"dotnet5.4",
|
||||||
|
"portable-net451+win8"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"testRunner": "xunit"
|
||||||
|
}
|
Loading…
Reference in a new issue