Skip to content

Commit

Permalink
Interpret DOTNET_BUNDLE_EXTRACT_BASE_DIR without dir separator as rel…
Browse files Browse the repository at this point in the history
…ative path (#39331)

* Get absolute path
  • Loading branch information
mateoatr authored Jul 16, 2020
1 parent aff5cf7 commit 950ef6f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/installer/corehost/cli/bundle/extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ pal::string_t& extractor_t::extraction_dir()
}

pal::string_t host_name = strip_executable_ext(get_filename(m_bundle_path));
if (!pal::is_path_rooted(m_extraction_dir))
{
pal::string_t current_dir = _X(".");
pal::string_t relative_path(m_extraction_dir);
m_extraction_dir = pal::realpath(&current_dir);
append_path(&m_extraction_dir, relative_path.c_str());
}

append_path(&m_extraction_dir, host_name.c_str());
append_path(&m_extraction_dir, m_bundle_id.c_str());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ private void Bundle_Extraction_To_Specific_Path_Succeeds()
extractDir.Should().NotHaveFiles(BundleHelper.GetFilesNeverExtracted(fixture));
}

[InlineData("./foo")]
[InlineData("../foo")]
[InlineData("foo")]
[InlineData("foo/bar")]
[Theory]
private void Bundle_Extraction_To_Relative_Path_Succeeds (string relativePath)
{
var fixture = sharedTestState.TestFixture.Copy();
var singleFile = BundleHelper.BundleApp(fixture, BundleOptions.None);

// Run the bundled app (extract files to <path>)
Command.Create(singleFile)
.CaptureStdErr()
.CaptureStdOut()
.EnvironmentVariable(BundleHelper.DotnetBundleExtractBaseEnvVariable, relativePath)
.Execute()
.Should()
.Pass()
.And
.HaveStdOutContaining("Hello World");
}

[Fact]
private void Bundle_extraction_is_reused()
{
Expand Down

0 comments on commit 950ef6f

Please sign in to comment.