public void UpdatePackageFromUI() { // Arrange EnsureVisualStudioHost(); var dte = VisualStudio.Dte; var solutionService = VisualStudio.Get <SolutionService>(); solutionService.CreateEmptySolution(); var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.ClassLibrary, ProjectTargetFramework.V46, "TestProject"); VisualStudio.ClearWindows(); // Act dte.ExecuteCommand("Project.ManageNuGetPackages"); var nugetTestService = GetNuGetTestService(); var uiwindow = nugetTestService.GetUIWindowfromProject(project); uiwindow.InstallPackageFromUI("newtonsoft.json", "9.0.1"); project.Build(); // Assert Assert.True(uiwindow.IsPackageInstalled("newtonsoft.json", "9.0.1")); VisualStudio.AssertNoErrors(); // Act VisualStudio.ClearWindows(); uiwindow.UpdatePackageFromUI("newtonsoft.json", "10.0.3"); project.Build(); // Assert Assert.True(uiwindow.IsPackageInstalled("newtonsoft.json", "10.0.3")); VisualStudio.AssertNoErrors(); }
public async Task WithSourceMappingEnabled_InstallPackageFromPMUIAndNoSourcesFound_Fails(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var simpleTestPathContext = new SimpleTestPathContext()) { string solutionDirectory = simpleTestPathContext.SolutionRoot; var privateRepositoryPath = Path.Combine(solutionDirectory, "PrivateRepository"); Directory.CreateDirectory(privateRepositoryPath); var externalRepositoryPath = Path.Combine(solutionDirectory, "ExternalRepository"); Directory.CreateDirectory(externalRepositoryPath); var packageName = "Contoso.a"; var packageVersion = "1.0.0"; await CommonUtility.CreatePackageInSourceAsync(externalRepositoryPath, packageName, packageVersion); // Create nuget.config with Package source mapping filtering rules before project is created. CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.Config"), $@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <packageSources> <add key=""ExternalRepository"" value=""{externalRepositoryPath}"" /> <add key=""PrivateRepository"" value=""{privateRepositoryPath}"" /> </packageSources> <packageSourceMapping> <packageSource key=""externalRepository""> <package pattern=""External.*"" /> <package pattern=""Others.*"" /> </packageSource> <packageSource key=""PrivateRepository""> <package pattern=""contoso.*"" /> <package pattern=""Test.*"" /> </packageSource> <packageSource key=""nuget""> <package pattern=""Microsoft.*"" /> <package pattern=""NetStandard*"" /> </packageSource> </packageSourceMapping> </configuration>"); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext)) { VisualStudio.AssertNoErrors(); // Act CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, XunitLogger); var nugetTestService = GetNuGetTestService(); var uiwindow = nugetTestService.GetUIWindowfromProject(testContext.SolutionService.Projects[0]); uiwindow.InstallPackageFromUI(packageName, packageVersion); // Assert CommonUtility.AssertPackageReferenceDoesNotExist(VisualStudio, testContext.SolutionService.Projects[0], packageName, packageVersion, XunitLogger); } } }
public void CreateNetCoreProject_RestoresNewProject(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { VisualStudio.AssertNoErrors(); } }
public void CreateNetCoreProject_AddProjectReference(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { var project2 = testContext.SolutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, ProjectTargetFramework.V46, "TestProject2"); project2.Build(); testContext.Project.References.Dte.AddProjectReference(project2); testContext.SolutionService.SaveAll(); testContext.SolutionService.Build(); Assert.True(testContext.Project.References.TryFindReferenceByName("TestProject2", out var result)); VisualStudio.AssertNoErrors(); } }
public void CreateNetCoreProject_AddProjectReference(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, addNetStandardFeeds: true)) { var project2 = testContext.SolutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, ProjectTargetFramework.V46, "TestProject2"); project2.Build(); testContext.Project.References.Dte.AddProjectReference(project2); testContext.SolutionService.SaveAll(); testContext.SolutionService.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); VisualStudio.AssertNoErrors(); CommonUtility.AssertPackageInAssetsFile(VisualStudio, testContext.Project, "TestProject2", "1.0.0", XunitLogger); } }
public void SearchPackageFromUI() { // Arrange EnsureVisualStudioHost(); var dte = VisualStudio.Dte; var solutionService = VisualStudio.Get <SolutionService>(); solutionService.CreateEmptySolution(); var project = solutionService.AddProject(ProjectLanguage.CSharp, ProjectTemplate.ClassLibrary, ProjectTargetFramework.V46, "TestProject"); VisualStudio.ClearOutputWindow(); // Act dte.ExecuteCommand("Project.ManageNuGetPackages"); var nugetTestService = GetNuGetTestService(); var uiwindow = nugetTestService.GetUIWindowfromProject(project); uiwindow.SwitchTabToBrowse(); uiwindow.SeachPackgeFromUI("newtonsoft.json"); // Assert VisualStudio.AssertNoErrors(); }