public void AddPackageReferencesToGlobalPackages(MsBuildProject project, IEnumerable <PackageReference> packageReferences)
        {
            using var projectCollection = new ProjectCollection();
            var packagesProject = ProjectUtility.OpenProjectForEditing(GetCentralPackagesFile(project), projectCollection);

            AddPackageReferences(packagesProject, packageReferences);
            packagesProject.Save();
        }
Example #2
0
        public void ManipulateProject(string projectFilePath, ProjectModification modification)
        {
            using var projectCollection = new ProjectCollection();
            var project = ProjectUtility.OpenProjectForEditing(projectFilePath, projectCollection);

            _projectSdkManipulator.AddSdksToProject(project, modification.SdksToAdd);
            AddPackageReferencesToProject(project, modification.PackageReferencesToAdd);
            project.Save();
        }