/// <summary> /// Creates a NuGet package from the specified settings. /// </summary> /// <param name="settings">The settings.</param> public void Pack(NuGetPackSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.OutputDirectory == null || !_fileSystem.Exist(settings.OutputDirectory)) { throw new CakeException("Required setting OutputDirectory not specified or doesn't exists."); } if (string.IsNullOrWhiteSpace(settings.Id)) { throw new CakeException("Required setting Id not specified."); } if (string.IsNullOrWhiteSpace(settings.Version)) { throw new CakeException("Required setting Version not specified."); } if (settings.Authors == null || settings.Authors.Count == 0) { throw new CakeException("Required setting Authors not specified."); } if (string.IsNullOrWhiteSpace(settings.Description)) { throw new CakeException("Required setting Description not specified."); } if ((settings.Files == null || settings.Files.Count == 0) && (settings.Dependencies == null || settings.Dependencies.Count == 0)) { throw new CakeException("Required setting Files not specified."); } Pack(settings, () => _processor.Process(settings)); }
/// <summary> /// Creates a NuGet package from the specified Nuspec file. /// </summary> /// <param name="nuspecFilePath">The nuspec file path.</param> /// <param name="settings">The settings.</param> public void Pack(FilePath nuspecFilePath, NuGetPackSettings settings) { if (nuspecFilePath == null) { throw new ArgumentNullException("nuspecFilePath"); } if (settings == null) { throw new ArgumentNullException("settings"); } FilePath procesedNuspecFilePath = null; try { // Transform the nuspec and return the new filename. procesedNuspecFilePath = _processor.Process(nuspecFilePath, settings); // Start the process. Run(settings, GetArguments(procesedNuspecFilePath, settings), settings.ToolPath); } finally { if (procesedNuspecFilePath != null) { // Delete the processed file. var file = _fileSystem.GetFile(procesedNuspecFilePath); if (file.Exists) { file.Delete(); } } } }