Esempio n. 1
0
        public static async Task AddBindingRedirectsAsync(
            VSSolutionManager vsSolutionManager,
            EnvDTEProject envDTEProject,
            IVsFrameworkMultiTargeting frameworkMultiTargeting,
            INuGetProjectContext nuGetProjectContext)
        {
            // Create a new app domain so we can load the assemblies without locking them in this app domain
            AppDomain domain = AppDomain.CreateDomain("assembliesDomain");

            try
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // Keep track of visited projects
                if (EnvDTEProjectUtility.SupportsBindingRedirects(envDTEProject))
                {
                    // Get the dependentEnvDTEProjectsDictionary once here, so that, it is not called for every single project
                    var dependentEnvDTEProjectsDictionary = await vsSolutionManager.GetDependentEnvDTEProjectsDictionaryAsync();
                    await AddBindingRedirectsAsync(vsSolutionManager, envDTEProject, domain,
                                                   frameworkMultiTargeting, dependentEnvDTEProjectsDictionary, nuGetProjectContext);
                }
            }
            finally
            {
                QueueUnloadAndForget(domain);
            }
        }
Esempio n. 2
0
        public static void AddBindingRedirects(
            VSSolutionManager vsSolutionManager,
            EnvDTEProject envDTEProject,
            IVsFrameworkMultiTargeting frameworkMultiTargeting,
            INuGetProjectContext nuGetProjectContext)
        {
            // Create a new app domain so we can load the assemblies without locking them in this app domain
            AppDomain domain = AppDomain.CreateDomain("assembliesDomain");

            try
            {
                // Keep track of visited projects
                if (EnvDTEProjectUtility.SupportsBindingRedirects(envDTEProject))
                {
                    // Get the dependentEnvDTEProjectsDictionary once here, so that, it is not called for every single project
                    var dependentEnvDTEProjectsDictionary = vsSolutionManager.GetDependentEnvDTEProjectsDictionary();
                    AddBindingRedirects(vsSolutionManager, envDTEProject, domain,
                                        frameworkMultiTargeting, dependentEnvDTEProjectsDictionary, nuGetProjectContext);
                }
            }
            finally
            {
                AppDomain.Unload(domain);
            }
        }
Esempio n. 3
0
        private static async Task AddBindingRedirectsAsync(VSSolutionManager vsSolutionManager,
                                                           EnvDTEProject envDTEProject,
                                                           AppDomain domain,
                                                           HashSet <string> visitedProjects,
                                                           Dictionary <string, HashSet <string> > projectAssembliesCache,
                                                           IVsFrameworkMultiTargeting frameworkMultiTargeting,
                                                           IDictionary <string, List <EnvDTEProject> > dependentEnvDTEProjectsDictionary,
                                                           INuGetProjectContext nuGetProjectContext)
        {
            // Need to be on the UI thread

            string envDTEProjectUniqueName = EnvDTEProjectUtility.GetUniqueName(envDTEProject);

            if (visitedProjects.Contains(envDTEProjectUniqueName))
            {
                return;
            }

            if (EnvDTEProjectUtility.SupportsBindingRedirects(envDTEProject))
            {
                await AddBindingRedirectsAsync(vsSolutionManager, envDTEProject, domain, projectAssembliesCache, frameworkMultiTargeting, nuGetProjectContext);
            }

            // Add binding redirects to all envdteprojects that are referencing this one
            foreach (EnvDTEProject dependentEnvDTEProject in VSSolutionManager.GetDependentEnvDTEProjects(dependentEnvDTEProjectsDictionary, envDTEProject))
            {
                await AddBindingRedirectsAsync(
                    vsSolutionManager,
                    dependentEnvDTEProject,
                    domain,
                    visitedProjects,
                    projectAssembliesCache,
                    frameworkMultiTargeting,
                    dependentEnvDTEProjectsDictionary,
                    nuGetProjectContext);
            }

            visitedProjects.Add(envDTEProjectUniqueName);
        }