public IEnumerable <IVsPackageMetadata> GetInstalledPackages() { try { var packages = new HashSet <IVsPackageMetadata>(new VsPackageMetadataComparer()); return(_threadingService.JoinableTaskFactory.Run(async delegate { // Calls may occur in the template wizard before the solution is actually created, // in that case return no projects if (_solutionManager != null && !string.IsNullOrEmpty(await _solutionManager.GetSolutionDirectoryAsync())) { //switch to background thread await TaskScheduler.Default; NuGetPackageManager nuGetPackageManager = CreateNuGetPackageManager(); foreach (var project in (await _solutionManager.GetNuGetProjectsAsync())) { FallbackPackagePathResolver pathResolver = null; var buildIntegratedProject = project as BuildIntegratedNuGetProject; if (buildIntegratedProject != null) { pathResolver = await GetPackagesPathResolverAsync(buildIntegratedProject); } var installedPackages = await project.GetInstalledPackagesAsync(CancellationToken.None); foreach (var package in installedPackages) { var identity = package.PackageIdentity; if (!identity.HasVersion) { // Currently we are not supporting floating versions // because of that we will skip this package continue; } // find packages using the solution level packages folder string installPath; if (buildIntegratedProject != null) { installPath = pathResolver.GetPackageDirectory(identity.Id, identity.Version); } else { installPath = nuGetPackageManager .PackagesFolderNuGetProject .GetInstalledPath(identity); } var metadata = new VsPackageMetadata(package.PackageIdentity, installPath); packages.Add(metadata); } } } return packages; })); } catch (Exception exception) { _telemetryProvider.PostFault(exception, typeof(VsPackageInstallerServices).FullName); throw; } }