Skip to content

Commit

Permalink
Improve the dependency resolution process
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavien committed Jul 10, 2016
1 parent 42e3041 commit d7e769e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/Openchain.Server/Models/DependencyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyModel;
using Microsoft.Extensions.Logging;
using Openchain.Infrastructure;

Expand Down Expand Up @@ -91,13 +91,9 @@ public async Task<Func<IServiceProvider, T>> Build()

private static IList<Assembly> LoadAllAssemblies(string projectPath)
{
return Directory.EnumerateFiles(projectPath)
.Where(name =>
Path.GetFileName(name).StartsWith("Openchain.", StringComparison.OrdinalIgnoreCase)
&& Path.GetFileNameWithoutExtension(name) != "Openchain.Server"
&& !Path.GetFileNameWithoutExtension(name).Equals("Openchain", StringComparison.OrdinalIgnoreCase)
&& Path.GetExtension(name).Equals(".dll", StringComparison.OrdinalIgnoreCase))
.Select(file => AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.Combine(projectPath, file)))
return DependencyContext.Default.RuntimeLibraries
.Where(library => library.Name.StartsWith("Openchain.", StringComparison.OrdinalIgnoreCase))
.Select(library => Assembly.Load(new AssemblyName(library.Name)))
.ToList();
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Openchain.Server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},

"dependencies": {
"System.Runtime.Loader": "4.0.0",
"Microsoft.AspNetCore.Mvc.Cors": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0",
Expand All @@ -41,6 +40,9 @@
"dnxcore50",
"portable-net45+win8"
]
},

"net451": {
}
}
}

0 comments on commit d7e769e

Please sign in to comment.