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(); }
public Task ManipulateProject(string projectFilePath, ProjectModification modification) { _microsoftBuildAssemblyLoader.LoadMicrosoftBuildIfNecessary(); WrapExceptions(projectFilePath, () => _projectManipulator.ManipulateProject(projectFilePath, modification)); return(Task.CompletedTask); }
public async Task AppliesModificationsSuccessfully(string expectedProject, string existingProject, ProjectModification modification) { using var testEnvironment = new TestEnvironmentProvider(); var projectFilePath = Path.Combine(testEnvironment.RootDirectory, ProjectFileName); await File.WriteAllTextAsync(projectFilePath, existingProject); var projectManipulator = CreateProjectManipulator(); await projectManipulator.ManipulateProject(projectFilePath, modification); Assert.Equal(expectedProject, await File.ReadAllTextAsync(projectFilePath)); }