public static void NuGetPack(this ICakeContext context, FilePath filePath, NuGetPackSettings settings) { if (context == null) { throw new ArgumentNullException("context"); } var resolver = new NuGetToolResolver(context.FileSystem, context.Environment, context.Tools); var packer = new NuGetPacker(context.FileSystem, context.Environment, context.ProcessRunner, context.Log, context.Tools, resolver); packer.Pack(filePath, settings); }
public static void NuGetPack(this ICakeContext context, FilePath nuspecFilePath, NuGetPackSettings settings) { if (context == null) { throw new ArgumentNullException("context"); } var packer = new NuGetPacker(context.FileSystem, context.Environment, context.Globber, context.ProcessRunner, context.Log); packer.Pack(nuspecFilePath, settings); }
public string Pack() { string content = null; ProcessRunner.When(p => p.Start(Arg.Any <FilePath>(), Arg.Any <ProcessSettings>())) .Do(info => { content = GetContent(info[1] as ProcessSettings); }); var tool = new NuGetPacker(FileSystem, Environment, ProcessRunner, Log, Globber, NuGetToolResolver); tool.Pack(NuSpecFilePath, Settings); // Return the content. return(content); }
public void CreatePackagesForAllNuSpecOutputToArtifactsFolder(string fullVersion) { var files = _globber.GetFiles("./**/*.nuspec").ToList(); if (files.Count == 0) { throw new Exception("No .nuspec files found to create packages from"); } var nuGetToolResolver = new NuGetToolResolver(_fileSystem, _environment, _tools); var packer = new NuGetPacker(_fileSystem, _environment, _processRunner, _log, _tools, nuGetToolResolver); var output = new DirectoryPath("./Artifacts"); var directory = _fileSystem.GetDirectory(output); if (!directory.Exists) { directory.Create(); } var nuGetPackSettings = new NuGetPackSettings { Version = fullVersion, OutputDirectory = output.FullPath, IncludeReferencedProjects = true, Properties = new Dictionary <string, string> { { "Configuration", Configuration } }, }; foreach (var nuspec in files) { _log.Information(nuspec.FullPath); var csproj = nuspec.ChangeExtension(".csproj"); _log.Information(csproj.FullPath); packer.Pack(csproj.FullPath, nuGetPackSettings); } }
public void Pack() { var tool = new NuGetPacker(FileSystem, Environment, ProcessRunner, Log, NuGetToolResolver); tool.Pack(NuSpecFilePath, Settings); }
protected override void RunTool() { var tool = new NuGetPacker(FileSystem, Environment, ProcessRunner, Log, Globber, Resolver); tool.Pack(ProjectFilePath, Settings); }
protected override void RunTool() { var tool = new NuGetPacker(FileSystem, Environment, ProcessRunner, Log, Tools, Resolver); tool.Pack(Settings); }
public static Command Tool(ILogger logger, IFileSystem fileSystem, CancellationToken cancellationToken) { var tool = new Command("pack", Strings.PackNuSpecPackCommand); Command NuSpec() { var command = new Command( "nuspec", Strings.PackNuSpec); command.AddOption(NuSpecFile); command.AddOption(PackageDirectory); command.Handler = CommandHandler.Create <string, string>(Bind); return(command); } Task <int> Bind(string?nuSpecFile, string?packageDirectory) { if (string.IsNullOrWhiteSpace(nuSpecFile)) { logger.Error("Missing expected --{Arg} argument", NuSpecFile.Aliases.FirstOrDefault()); return(Task.FromResult(result: 1)); } if (string.IsNullOrWhiteSpace(packageDirectory)) { logger.Error("Missing expected --{Arg} argument", PackageDirectory.Aliases.FirstOrDefault()); return(Task.FromResult(result: 2)); } return(BindInternal(nuSpecFile, packageDirectory)); } async Task <int> BindInternal(string nuSpecFile, string packageDirectory) { var nuSpecFileEntry = fileSystem.GetFileEntry(nuSpecFile.ParseAsPath()); string normalizedVersion; string packageId; await using (var nuSpecStream = nuSpecFileEntry.Open(FileMode.Open, FileAccess.Read)) { var manifest = Manifest.ReadFrom(nuSpecStream, validateSchema: true); normalizedVersion = manifest.Metadata.Version.ToNormalizedString(); packageId = manifest.Metadata.Id; } string packageFileName = $"{packageId}.{normalizedVersion}.nupkg"; var packageFilePath = packageDirectory.ParseAsPath() / packageFileName; return(await NuGetPacker.PackNuSpec( nuSpecFileEntry, packageFilePath, logger, cancellationToken).ConfigureAwait(continueOnCapturedContext: false)); } tool.AddCommand(NuSpec()); return(tool); }