Skip to content

Commit

Permalink
(chocolateyGH-906) Fix source path used when installing from nuspec f…
Browse files Browse the repository at this point in the history
…ile.

Previously when the install target was a nuspec file and the output
folder was not set to the folder that contained the nuspec file then
the installation failed because the nupkg file could not be found.
Update sets the sources parameter to the output folder during the
packaging of the nuspec file.
  • Loading branch information
Paul Hunt committed Jan 4, 2017
1 parent 7ff013f commit b79b5ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/chocolatey.tests.integration/scenarios/PackScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public void generated_package_should_be_in_current_directory()

File.Exists(package_path).ShouldBeTrue();
}

[Fact]
public void sources_should_be_set_to_current_directory()
{
Configuration.Sources.ShouldEqual(Scenario.get_top_level());
}
}

[Concern(typeof(ChocolateyPackCommand))]
Expand Down Expand Up @@ -100,6 +106,12 @@ public void generated_package_should_be_in_specified_output_directory()

File.Exists(package_path).ShouldBeTrue();
}

[Fact]
public void sources_should_be_set_to_specified_output_directory()
{
Configuration.Sources.ShouldEqual("PackageOutput");
}
}

private const string NuspecContent = @"<?xml version=""1.0"" encoding=""utf-8""?>
Expand Down
5 changes: 4 additions & 1 deletion src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ public void pack_run(ChocolateyConfiguration config)
}

string outputFile = builder.Id + "." + builder.Version + Constants.PackageExtension;
string outputPath = _fileSystem.combine_paths(config.OutputDirectory ?? _fileSystem.get_current_directory(), outputFile);
string outputFolder = config.OutputDirectory ?? _fileSystem.get_current_directory();
string outputPath = _fileSystem.combine_paths(outputFolder, outputFile);

config.Sources = outputFolder;

this.Log().Info(() => "Attempting to build package from '{0}'.".format_with(_fileSystem.get_file_name(nuspecFilePath)));

Expand Down

0 comments on commit b79b5ad

Please sign in to comment.