public void MultipleTargetFrameworks() { string[] targetFrameworks = { "net45", "net46", }; PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out Package packageA) .ForEach( targetFrameworks, (targetFramework, feed) => { feed.Library(targetFramework) .ReferenceAssembly(targetFramework); }) .Save(); foreach (string targetFramework in targetFrameworks) { ValidateAssembly(packageA, Path.Combine("lib", targetFramework, "PackageA.dll"), "PackageA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "PackageA.PackageA_Class"); ValidateAssembly(packageA, Path.Combine("ref", targetFramework, "PackageA.dll"), "PackageA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "PackageA.PackageA_Class"); } }
public void BasicPackageWithDependency() { using PackageFeed packageFeed = PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out _, "John Smith", "Custom Description", true) .Library("net45") .Dependency("net45", "PackageB", "2.0.0") .Save(); Package packageA = packageFeed.Packages.ShouldHaveSingleItem(); packageA.Author.ShouldBe("John Smith"); packageA.Description.ShouldBe("Custom Description"); packageA.DevelopmentDependency.ShouldBeTrue(); packageA.Id.ShouldBe("PackageA"); packageA.Version.ShouldBe("1.0.0"); NuspecReader nuspec = GetNuspec(packageA); nuspec.Authors.ShouldBe("John Smith"); nuspec.Description.ShouldBe("Custom Description"); nuspec.Id.ShouldBe("PackageA"); nuspec.Version.ShouldBe("1.0.0"); (string targetFramework, System.Collections.Generic.IEnumerable <PackageDependency> dependencies) = nuspec.DependencyGroups.ToList().ShouldHaveSingleItem(); targetFramework.ShouldBe("net45"); PackageDependency dependency = dependencies.ShouldHaveSingleItem(); dependency.Id.ShouldBe("PackageB"); dependency.Version.ShouldBe("2.0.0"); dependency.ExcludeAssets.ShouldBe("Build, Analyzers"); }
public void FileTextThrowsIfNoPackageAdded() { ShouldThrowExceptionIfNoPackageAdded(() => { PackageFeed.Create(FeedRootPath) .FileText("something.txt", string.Empty); }); }
public void ReferenceAssemblyThrowsIfNoPackageAdded() { ShouldThrowExceptionIfNoPackageAdded(() => { PackageFeed.Create(FeedRootPath) .ReferenceAssembly("net45"); }); }
public void LibraryThrowsIfNoPackageAdded() { ShouldThrowExceptionIfNoPackageAdded(() => { PackageFeed.Create(FeedRootPath) .Library("net45"); }); }
public void ReferenceAssemblyDefault() { PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out Package packageA) .ReferenceAssembly("net45") .Save(); ValidateAssembly(packageA, Path.Combine("ref", "net45", "PackageA.dll"), "PackageA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "PackageA.PackageA_Class"); }
public void ReferenceAssemblyCustom() { PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out Package packageA) .ReferenceAssembly("net45", "CustomFile.dll", "Custom.Namespace", "CustomClass", "2.3.4.5") .Save(); ValidateAssembly(packageA, Path.Combine("ref", "net45", "CustomFile.dll"), "CustomFile, Version=2.3.4.5, Culture=neutral, PublicKeyToken=null", "Custom.Namespace.CustomClass"); }
public void LibraryDefault(string packageName) { PackageFeed.Create(FeedRootPath) .Package(packageName, "1.0.0", out Package packageA) .Library("net45") .Save(); ValidateAssembly(packageA, Path.Combine("lib", "net45", $"{packageName}.dll"), $"{packageName}, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", $"{packageName}.{packageName.Replace(".", "_")}_Class"); }
public void FileCustomDoesNotExist() { Should.Throw <FileNotFoundException>(() => { FileInfo fileInfo = new FileInfo(Path.Combine(TestRootPath, "foo.txt")); PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0") .FileCustom("foo.txt", fileInfo) .Save(); }); }
public void ContentFileTextDefault() { PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out Package packageA) .ContentFileText("file.txt", "F1BE6E0E408141459C9728FBE0CD5751", "net45") .Save(); VerifyContentFile( packageA, "file.txt", "F1BE6E0E408141459C9728FBE0CD5751", "net45", expectedBuildAction: "Content", expectedCopyToOutput: true); }
public void FileText() { string relativePath = Path.Combine("something", "nothing.txt"); PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out Package packageA) .FileText(relativePath, "607779BADE3645F8A288543213BFE948") .Save(); GetFileContents(packageA.FullPath, relativePath) .ShouldBe("607779BADE3645F8A288543213BFE948"); GetNuspec(packageA) .DependencyGroups .ShouldBeEmpty(); }
public void ContentFileTextCustom() { const string language = "cs"; PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out Package packageA) .ContentFileText("file.cs", "A1CF42B9F20B4155B6B70753784615B5", "netstandard2.0", "Compile", copyToOutput: false, flatten: true, language) .Save(); VerifyContentFile( packageA, "file.cs", "A1CF42B9F20B4155B6B70753784615B5", "netstandard2.0", expectedBuildAction: "Compile", expectedCopyToOutput: false, expectedFlatten: true, expectedLanguage: language); }
/// <summary> /// Adds the feed location. /// </summary> /// <param name="feedCollection"> The feed collection. </param> /// <param name="feedLocation"> The feed location. </param> /// <returns> </returns> /// <remarks> /// NOTE: This is probably gettin' refactored PFQ /// </remarks> internal static Task AddFeedLocation(this ObservableCollection <PackageFeed> feedCollection, string feedLocation) { if (!(from feed in feedCollection where feed.Location.Equals(feedLocation, StringComparison.CurrentCultureIgnoreCase) select feed).Any()) { return(PackageFeed.GetPackageFeedFromLocation(feedLocation).ContinueWith(antecedent => { if (antecedent.Result != null) { if ( !(from feed in feedCollection where feed.Location.Equals(feedLocation, StringComparison.CurrentCultureIgnoreCase) select feed).Any()) { feedCollection.Add(antecedent.Result); } } }, TaskContinuationOptions.AttachedToParent)); } return(Task.Factory.StartNew(() => { })); }
public void FileCustom() { string fileName = $"{Guid.NewGuid():N}.txt"; FileInfo sourceFileInfo = new FileInfo(Path.Combine(TestRootPath, fileName)); string relativePath = Path.Combine("tools", "net46", fileName); File.WriteAllText(sourceFileInfo.FullName, "585B55DD5AC54A10B841B3D9A00129D8"); PackageFeed.Create(FeedRootPath) .Package("PackageA", "1.0.0", out Package packageA) .FileCustom(relativePath, sourceFileInfo) .Save(); GetFileContents(packageA.FullPath, relativePath) .ShouldBe("585B55DD5AC54A10B841B3D9A00129D8"); GetNuspec(packageA) .DependencyGroups.Select(i => i.TargetFramework).ToList() .ShouldContain("net46"); }
protected void when_reading_feed() { Feed = NuFeedReader.Read(_xFeed.CreateReader()); }
public static async Task Main(string[] args) { try { var isHelp = false; var parameters = new DownloaderParameters { PackageOutputPath = GetTemporaryOutputPath(), }; var options = new OptionSet { { "help|h", "Displays this help screen", s => isHelp = true }, { "solution|s=", "Path to the {solution}", s => parameters.SolutionPath = s }, { "output|o=", "Path where to extract the packages; optional, defaults to a temporary folder", s => parameters.PackageOutputPath = s }, { "sourceFeed=|sf=", "The NuGet feed from where to download the packages; a private feed can be specified with the format {url|accessToken}", s => parameters.Source = PackageFeed.FromString(s) }, { "targetFeed=|tf=", "The NuGet feed where to push the packages; a private feed can be specified with the format {url|accessToken}; optional", s => parameters.Target = PackageFeed.FromString(s) }, }; options.Parse(args); if (isHelp) { Console.WriteLine("NuGet Downloader is a tool allowing the download of the NuGet packages found in a solution"); Console.WriteLine(); options.WriteOptionDescriptions(Console.Out); } var result = await NuGetDownloader.RunAsync(CancellationToken.None, parameters, ConsoleLogger.Instance); Console.WriteLine($"{result.DownloadedPackages.Length} packages have been downloaded under {parameters.PackageOutputPath}"); if (parameters.Target != null) { Console.WriteLine($"{result.PushedPackages?.Length ?? 0} packages have been pushed to {parameters.Target.Url}"); } } catch (Exception ex) { Console.Error.WriteLine($"Failed to download nuget packages: {ex.Message}"); Console.Error.WriteLine($"{ex}"); } }