From f810e184d30e38a19c1307ebb898f5a109f29a99 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Fri, 10 Apr 2015 09:07:00 -0500 Subject: [PATCH 1/3] (GH-164) Fix "The path is not of a legal form" When file_system.get_full_path is passed an empty string resulting from grabbing the directory name, it would throw the error above. Instead, allow it to return immediately, then use the current directory instead. This usually happens when calling `choco pack some.nuspec`. --- src/chocolatey/infrastructure.app/services/NugetService.cs | 1 + src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index cf28d204b5..a118d586ae 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -134,6 +134,7 @@ 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 properties = new Dictionary(); // Set the version property if the flag is set diff --git a/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs b/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs index 6f16dfc224..41cde09571 100644 --- a/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs +++ b/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs @@ -66,6 +66,8 @@ public string combine_paths(string leftItem, params string[] rightItems) public string get_full_path(string path) { + if (string.IsNullOrWhiteSpace(path)) return path; + return Path.GetFullPath(path); } From f21091c661b9d44aa8558f47b56376726413001e Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Fri, 10 Apr 2015 09:07:19 -0500 Subject: [PATCH 2/3] (GH-232) Pack includes files from nuspec directory Instead of starting at the current directory to use files for the nuspec, use the nuspec directory as the starting path to look at files. --- src/chocolatey/infrastructure.app/services/NugetService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index a118d586ae..f1b36c59e2 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -146,7 +146,7 @@ public void pack_run(ChocolateyConfiguration config) // Initialize the property provider based on what was passed in using the properties flag var propertyProvider = new DictionaryPropertyProvider(properties); - var basePath = _fileSystem.get_current_directory(); + var basePath = nuspecDirectory; if (config.Information.PlatformType != PlatformType.Windows) { //bug with nuspec and tools/** folder location on Windows. From d0b2336cbdd9626234f47a147f0eb1f2b409c93f Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Fri, 10 Apr 2015 09:07:35 -0500 Subject: [PATCH 3/3] (GH-231) nupkg should be created in current directory When running choco pack, the resulting nupkg used to be created in the current directory and not necessarily in the same directory as the nuspec file. The previous behavior is preferred. Allow for the package to be created in the current working directory instead of the nuspec directory. --- src/chocolatey/infrastructure.app/services/NugetService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index f1b36c59e2..b39a7c54b6 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -160,7 +160,7 @@ public void pack_run(ChocolateyConfiguration config) } string outputFile = builder.Id + "." + builder.Version + Constants.PackageExtension; - string outputPath = _fileSystem.combine_paths(nuspecDirectory, outputFile); + 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)));