public void pack_run(ChocolateyConfiguration config) { string nuspecFilePath = validate_and_return_package_file(config, Constants.ManifestExtension); var nuspecDirectory = _fileSystem.get_full_path(_fileSystem.get_directory_name(nuspecFilePath)); if (string.IsNullOrWhiteSpace(nuspecDirectory)) { nuspecDirectory = _fileSystem.get_current_directory(); } IDictionary <string, string> properties = new Dictionary <string, string>(); // Set the version property if the flag is set if (!string.IsNullOrWhiteSpace(config.Version)) { properties["version"] = config.Version; } // Initialize the property provider based on what was passed in using the properties flag var propertyProvider = new DictionaryPropertyProvider(properties); var basePath = nuspecDirectory; if (config.Information.PlatformType != PlatformType.Windows) { //bug with nuspec and tools/** folder location on Windows. basePath = "./"; } var builder = new PackageBuilder(nuspecFilePath, basePath, propertyProvider, includeEmptyDirectories: true); if (!string.IsNullOrWhiteSpace(config.Version)) { builder.Version = new SemanticVersion(config.Version); } string outputFile = builder.Id + "." + builder.Version + Constants.PackageExtension; string outputPath = _fileSystem.combine_paths(_fileSystem.get_current_directory(), outputFile); this.Log().Info(() => "Attempting to build package from '{0}'.".format_with(_fileSystem.get_file_name(nuspecFilePath))); //IPackage package = NugetPack.BuildPackage(builder, _fileSystem, outputPath); //todo: v1 analyze package //if (package != null) //{ // AnalyzePackage(package); //} this.Log().Info(ChocolateyLoggers.Important, () => "Successfully created package '{0}'".format_with(outputFile)); }
private IEnumerable <ChocolateyConfiguration> get_packages_from_config(string packageConfigFile, ChocolateyConfiguration config, ConcurrentDictionary <string, PackageResult> packageInstalls) { IList <ChocolateyConfiguration> packageConfigs = new List <ChocolateyConfiguration>(); if (!_fileSystem.file_exists(_fileSystem.get_full_path(packageConfigFile))) { var logMessage = "Could not find '{0}' in the location specified.".format_with(packageConfigFile); this.Log().Error(ChocolateyLoggers.Important, logMessage); var results = packageInstalls.GetOrAdd(packageConfigFile, new PackageResult(packageConfigFile, null, null)); results.Messages.Add(new ResultMessage(ResultType.Error, logMessage)); return(packageConfigs); } var settings = _xmlService.deserialize <PackagesConfigFileSettings>(_fileSystem.get_full_path(packageConfigFile)); foreach (var pkgSettings in settings.Packages.or_empty_list_if_null()) { if (!pkgSettings.Disabled) { var packageConfig = config.deep_copy(); packageConfig.PackageNames = pkgSettings.Id; packageConfig.Sources = string.IsNullOrWhiteSpace(pkgSettings.Source) ? packageConfig.Sources : pkgSettings.Source; packageConfig.Version = pkgSettings.Version; packageConfig.InstallArguments = string.IsNullOrWhiteSpace(pkgSettings.InstallArguments) ? packageConfig.InstallArguments : pkgSettings.InstallArguments; packageConfig.PackageParameters = string.IsNullOrWhiteSpace(pkgSettings.PackageParameters) ? packageConfig.PackageParameters : pkgSettings.PackageParameters; if (pkgSettings.ForceX86) { packageConfig.ForceX86 = true; } if (pkgSettings.AllowMultipleVersions) { packageConfig.AllowMultipleVersions = true; } if (pkgSettings.IgnoreDependencies) { packageConfig.IgnoreDependencies = true; } packageConfigs.Add(packageConfig); } } return(packageConfigs); }