public void It_packs_successfully() { var helloWorldAsset = _testAssetsManager .CopyTestAsset("HelloWorld", "PackHelloWorld") .WithSource(); var packCommand = new PackCommand(Log, helloWorldAsset.TestRoot); packCommand .Execute() .Should() .Pass(); // Validate the contents of the NuGet package by looking at the generated .nuspec file, as that's simpler // than unzipping and inspecting the .nupkg string nuspecPath = packCommand.GetIntermediateNuspecPath(); var nuspec = XDocument.Load(nuspecPath); var ns = nuspec.Root.Name.Namespace; XElement filesSection = nuspec.Root.Element(ns + "files"); var fileTargets = filesSection.Elements().Select(files => files.Attribute("target").Value).ToList(); var expectedFileTargets = new[] { @"lib\netcoreapp2.1\HelloWorld.runtimeconfig.json", @"lib\netcoreapp2.1\HelloWorld.dll" }.Select(p => p.Replace('\\', Path.DirectorySeparatorChar)); fileTargets.Should().BeEquivalentTo(expectedFileTargets); }
private XDocument PackAndGetNuspec(TestProject testProject) { var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name); var packCommand = new PackCommand(Log, testProjectInstance.TestRoot, testProject.Name); packCommand.Execute() .Should() .Pass(); string nuspecPath = packCommand.GetIntermediateNuspecPath(); var nuspec = XDocument.Load(nuspecPath); return(nuspec); }
private string PackAndGetNuspecPath(TestProject testProject, Action <XDocument> xmlAction = null) { var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name); if (xmlAction != null) { testProjectInstance = testProjectInstance.WithProjectChanges(xmlAction); } var packCommand = new PackCommand(Log, testProjectInstance.TestRoot, testProject.Name); packCommand.Execute() .Should() .Pass(); string nuspecPath = packCommand.GetIntermediateNuspecPath(); return(nuspecPath); }
List <XElement> PackAndGetDependencyGroups(TestProject testProject, out XNamespace ns) { var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name) .Restore(Log, testProject.Name); var packCommand = new PackCommand(Log, testProjectInstance.TestRoot, testProject.Name); packCommand.Execute() .Should() .Pass(); string nuspecPath = packCommand.GetIntermediateNuspecPath(); var nuspec = XDocument.Load(nuspecPath); ns = nuspec.Root.Name.Namespace; var dependencyGroups = nuspec.Root .Element(ns + "metadata") .Element(ns + "dependencies") .Elements() .ToList(); return(dependencyGroups); }