Skip to content

Commit

Permalink
Fixes #1478: Platform not supported error
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Oct 4, 2017
1 parent 2c85a42 commit 4461cd3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
Expand Up @@ -26,7 +26,7 @@ public class NetCoreAssemblyDependencyResolver : IDisposable
: RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "unix"
: "unknown";

Dictionary<string, RuntimeLibrary> assemblyFileNameToLibraryMap;
Dictionary<string, Tuple<RuntimeLibrary, RuntimeAssetGroup>> assemblyFileNameToLibraryMap;
string assemblyFolder;
ICompilationAssemblyResolver assemblyResolver;
DependencyContext dependencyContext;
Expand Down Expand Up @@ -69,9 +69,9 @@ void Initialize(Assembly assembly)
dependencyContext.RuntimeLibraries
.Where(lib => lib.RuntimeAssemblyGroups?.Count > 0)
.Select(lib => Tuple.Create(lib, lib.RuntimeAssemblyGroups.FirstOrDefault(grp => grp.Runtime == CurrentRuntime || string.IsNullOrEmpty(grp.Runtime))))
.Where(tuple => tuple.Item2 != null && tuple.Item2.AssetPaths != null)
.SelectMany(tuple => tuple.Item2.AssetPaths.Where(x => x != null).Select(path => Tuple.Create(tuple.Item1, Path.GetFileNameWithoutExtension(path))))
.ToDictionaryIgnoringDuplicateKeys(tuple => tuple.Item2, tuple => tuple.Item1, StringComparer.OrdinalIgnoreCase);
.Where(tuple => tuple.Item2?.AssetPaths != null)
.SelectMany(tuple => tuple.Item2.AssetPaths.Where(x => x != null).Select(path => Tuple.Create(Path.GetFileNameWithoutExtension(path), Tuple.Create(tuple.Item1, tuple.Item2))))
.ToDictionaryIgnoringDuplicateKeys(tuple => tuple.Item1, tuple => tuple.Item2, StringComparer.OrdinalIgnoreCase);

assemblyResolver = new XunitPackageCompilationAssemblyResolver();
loadContext = AssemblyLoadContext.GetLoadContext(assembly);
Expand All @@ -85,11 +85,12 @@ public void Dispose()
Assembly OnResolving(AssemblyLoadContext context, AssemblyName name)
{
// Try to find dependency from .deps.json
if (assemblyFileNameToLibraryMap.TryGetValue(name.Name, out var library))
if (assemblyFileNameToLibraryMap.TryGetValue(name.Name, out var libraryTuple))
{
var library = libraryTuple.Item1;
var assetGroup = libraryTuple.Item2;
var wrapper = new CompilationLibrary(library.Type, library.Name, library.Version, library.Hash,
library.RuntimeAssemblyGroups.SelectMany(g => g.AssetPaths),
library.Dependencies, library.Serviceable);
assetGroup.AssetPaths, library.Dependencies, library.Serviceable);

var assemblies = new List<string>();
if (assemblyResolver.TryResolveAssemblyPaths(wrapper, assemblies))
Expand Down
30 changes: 30 additions & 0 deletions test/test.harness/test.harness.csproj
Expand Up @@ -15,11 +15,41 @@
<ProjectReference Include="..\test.testcasefilter\test.testcasefilter.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="App.config">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>App.cs</LastGenOutput>
</None>
<None Update="PerfTests.tt" Generator="TextTemplatingFileGenerator" LastGenOutput="PerfTests.cs" />
<None Update="Properties\launchSettings.json">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>launchSettings.cs</LastGenOutput>
</None>
<None Update="readme.txt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>readme.cs</LastGenOutput>
</None>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Compile Update="App.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>App.config</DependentUpon>
</Compile>
<Compile Update="PerfTests.cs" DesignTime="True" AutoGen="True" DependentUpon="PerfTests.tt" />
<Compile Update="Properties\launchSettings.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>launchSettings.json</DependentUpon>
</Compile>
<Compile Update="readme.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>readme.txt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<Import Project="..\..\src\xunit.core\build\xunit.core.targets" />
</Project>

0 comments on commit 4461cd3

Please sign in to comment.