[ExcludeFromCodeCoverage] // depends on Nuget class implementations private void AddBindingRedirects() { IEnumerable <global::NuGet.Runtime.AssemblyBinding> assemblyBindings; AppDomain domain = AppDomain.CreateDomain("referencesDomain", null, Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "", false); try { if (_projectSystem is NuGetMsBuildProjectSystem) { var referencePaths = ((NuGetMsBuildProjectSystem)_projectSystem).GetAssemblyReferencePaths(); assemblyBindings = global::NuGet.Runtime.BindingRedirectResolver.GetBindingRedirects(referencePaths, domain); } else { // use all binaries in the bin folder assemblyBindings = global::NuGet.Runtime.BindingRedirectResolver.GetBindingRedirects(Path.Combine(_projectSystem.Root, "bin"), domain); } string configFile = _projectSystem.FileExistsInProject("web.config") ? "web.config" : "app.config"; global::NuGet.Runtime.BindingRedirectManager bindingManager = new global::NuGet.Runtime.BindingRedirectManager(_projectSystem, configFile); bindingManager.AddBindingRedirects(assemblyBindings); } finally { AppDomain.Unload(domain); } }
[ExcludeFromCodeCoverage] // depends on Nuget class implementations private void AddBindingRedirects() { IEnumerable<global::NuGet.Runtime.AssemblyBinding> assemblyBindings; AppDomain domain = AppDomain.CreateDomain("referencesDomain", null, Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "", false); try { if(_projectSystem is NuGetMsBuildProjectSystem) { var referencePaths = ((NuGetMsBuildProjectSystem)_projectSystem).GetAssemblyReferencePaths(); assemblyBindings = global::NuGet.Runtime.BindingRedirectResolver.GetBindingRedirects(referencePaths, domain); } else { // use all binaries in the bin folder assemblyBindings = global::NuGet.Runtime.BindingRedirectResolver.GetBindingRedirects(Path.Combine(_projectSystem.Root, "bin"), domain); } string configFile = _projectSystem.FileExistsInProject("web.config") ? "web.config" : "app.config"; global::NuGet.Runtime.BindingRedirectManager bindingManager = new global::NuGet.Runtime.BindingRedirectManager(_projectSystem, configFile); bindingManager.AddBindingRedirects(assemblyBindings); } finally { AppDomain.Unload(domain); } }