public async Task MsbuildRestore_PackagesConfigDependencyAsync() { // Arrange using (var pathContext = new SimpleTestPathContext()) { // Set up solution, project, and packages var solution = new SimpleTestSolutionContext(pathContext.SolutionRoot); var net461 = NuGetFramework.Parse("net461"); var projectA = new SimpleTestProjectContext( "a", ProjectStyle.PackagesConfig, pathContext.SolutionRoot); projectA.Frameworks.Add(new SimpleTestProjectFrameworkContext(net461)); var packageX = new SimpleTestPackageContext() { Id = "x", Version = "1.0.0" }; packageX.Files.Clear(); packageX.AddFile("lib/net461/a.dll"); solution.Projects.Add(projectA); solution.Create(pathContext.SolutionRoot); using (var writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(projectA.ProjectPath), "packages.config"))) { writer.Write( @"<packages> <package id=""x"" version=""1.0.0"" targetFramework=""net461"" /> </packages>"); } await SimpleTestPackageUtility.CreateFolderFeedV3Async( pathContext.PackageSource, packageX); // Act var result = _msbuildFixture.RunMsBuild(pathContext.WorkingDirectory, $"/t:restore {pathContext.SolutionRoot} /p:RestorePackagesConfig=true", ignoreExitCode: true); // Assert Assert.True(result.ExitCode == 0, result.AllOutput); Assert.Contains("Added package 'x.1.0.0' to folder", result.AllOutput); } }
public async Task GenerateRestoreGraphFile_WithMixedProjectSolution_BothStaticGraphAndStandard_AreEqual() { // Arrange using (var pathContext = new SimpleTestPathContext()) { // Set up solution, project, and packages var solution = new SimpleTestSolutionContext(pathContext.SolutionRoot); var net461 = NuGetFramework.Parse("net461"); var packageX = new SimpleTestPackageContext() { Id = "x", Version = "1.0.0" }; packageX.Files.Clear(); packageX.AddFile("lib/net461/a.dll"); var projectA = SimpleTestProjectContext.CreateLegacyPackageReference( "a", pathContext.SolutionRoot, net461); projectA.AddPackageToAllFrameworks(packageX); solution.Projects.Add(projectA); solution.Create(pathContext.SolutionRoot); await SimpleTestPackageUtility.CreateFolderFeedV3Async( pathContext.PackageSource, packageX); var standardDgSpecFile = Path.Combine(pathContext.WorkingDirectory, "standard.dgspec.json"); var staticGraphDgSpecFile = Path.Combine(pathContext.WorkingDirectory, "staticGraph.dgspec.json"); var targetPath = projectA.ProjectPath; _msbuildFixture.RunMsBuild(pathContext.WorkingDirectory, $"/t:GenerateRestoreGraphFile /p:RestoreGraphOutputPath=\"{standardDgSpecFile}\" {targetPath}"); _msbuildFixture.RunMsBuild(pathContext.WorkingDirectory, $"/t:GenerateRestoreGraphFile /p:RestoreGraphOutputPath=\"{staticGraphDgSpecFile}\" /p:RestoreUseStaticGraphEvaluation=true {targetPath}"); var regularDgSpec = File.ReadAllText(standardDgSpecFile); var staticGraphDgSpec = File.ReadAllText(staticGraphDgSpecFile); regularDgSpec.Should().BeEquivalentTo(staticGraphDgSpec); } }