protected async Task CheckPackageManagementFormat() { bool packagesConfigAndSupportsPackageReferences = false; if (Project.ProjectStyle == ProjectModel.ProjectStyle.PackagesConfig) { packagesConfigAndSupportsPackageReferences = Project.ProjectServices.Capabilities.SupportsPackageReferences; } // The Project is compatible with, but is currently not a PackageReference-style project, and no packages are currently installed. if (packagesConfigAndSupportsPackageReferences && !(await Project.GetInstalledPackagesAsync(Token)).Any()) { var packageManagementFormat = new PackageManagementFormat(ConfigSettings); // The "Default Package Management Format" setting is PackageReference, so we can migrate this NuGet Project. if (packageManagementFormat.SelectedPackageManagementFormat == 1) { var newProject = await VsSolutionManager.UpgradeProjectToPackageReferenceAsync(Project); if (newProject != null) { Project = newProject; } } } }
protected async Task CheckPackageManagementFormat() { // check if Project has any packages installed if (!(await Project.GetInstalledPackagesAsync(Token)).Any()) { var packageManagementFormat = new PackageManagementFormat(ConfigSettings); // if default format is PackageReference then update NuGet Project if (packageManagementFormat.SelectedPackageManagementFormat == 1) { var newProject = await VsSolutionManager.UpgradeProjectToPackageReferenceAsync(Project); if (newProject != null) { Project = newProject; } } } }