-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract bundled files when IncludeAllContentForSelfExtract is set #42435
Changes from 1 commit
a2feaec
83a1109
fab74ef
788e046
459c10e
2917ca5
42bc99b
02b975d
ac2b539
fe7c2cd
9334a7d
9289687
fcc222f
48563cf
7595e5f
9449607
e52837c
7ec7fd3
19ea932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using BundleTests.Helpers; | ||
using Microsoft.DotNet.Cli.Build.Framework; | ||
using Microsoft.DotNet.CoreSetup.Test; | ||
using Microsoft.NET.HostModel.Bundle; | ||
using Xunit; | ||
|
||
namespace AppHost.Bundle.Tests | ||
{ | ||
public class NetCoreApp3CompatModeTests : IClassFixture<NetCoreApp3CompatModeTests.SharedTestState> | ||
{ | ||
private SharedTestState sharedTestState; | ||
|
||
public NetCoreApp3CompatModeTests(SharedTestState fixture) | ||
{ | ||
sharedTestState = fixture; | ||
} | ||
|
||
[Fact] | ||
public void Bundle_Is_Extracted() | ||
{ | ||
var fixture = sharedTestState.TestFixture.Copy(); | ||
string singleFile; | ||
Bundler bundler = BundleHelper.BundleApp(fixture, out singleFile, BundleOptions.BundleAllContent); | ||
var extractionBaseDir = BundleHelper.GetExtractionRootDir(fixture); | ||
|
||
Command.Create(singleFile) | ||
.CaptureStdErr() | ||
.CaptureStdOut() | ||
.EnvironmentVariable(BundleHelper.DotnetBundleExtractBaseEnvVariable, extractionBaseDir.FullName) | ||
.Execute() | ||
.Should() | ||
.Pass() | ||
.And | ||
.HaveStdOutContaining("Hello World"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any way we could also confirm that the assemblies are actually loaded from the extraction location and not the bundle? Perhaps by printing the result of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should definitely test for this. I think we always set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the most recent changes bundle probe should return false for all queries - I checked that the runtime behavior in that case is the same as without bundle probe in the case of assembly resolution. Note that it's not the same in other cases - especially Environment.GetCommandLineArguments[0] should still return the .exe path, not the main .dll path. I also checked all the other places in runtime where we somehow react to bundle probe, and they all look correct to me. |
||
|
||
var extractionDir = BundleHelper.GetExtractionDir(fixture, bundler); | ||
var bundleFiles = BundleHelper.GetBundleDir(fixture).GetFiles().Select(file => file.Name).ToArray(); | ||
var publishedFiles = Directory.GetFiles(BundleHelper.GetPublishPath(fixture), searchPattern: "*", searchOption: SearchOption.AllDirectories) | ||
.Select(file => Path.GetFileName(file)) | ||
.Except(bundleFiles) | ||
.ToArray(); | ||
var bundlerFiles = BundleHelper.GetBundleDir(fixture).GetFiles(); | ||
elinor-fung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extractionDir.Should().HaveFiles(publishedFiles); | ||
} | ||
|
||
public class SharedTestState : IDisposable | ||
{ | ||
public TestProjectFixture TestFixture { get; set; } | ||
public RepoDirectoriesProvider RepoDirectories { get; set; } | ||
|
||
public SharedTestState() | ||
{ | ||
RepoDirectories = new RepoDirectoriesProvider(); | ||
TestFixture = new TestProjectFixture("StandaloneApp", RepoDirectories); | ||
TestFixture | ||
.EnsureRestoredForRid(TestFixture.CurrentRid, RepoDirectories.CorehostPackages) | ||
.PublishProject(runtime: TestFixture.CurrentRid, outputDirectory: BundleHelper.GetPublishPath(TestFixture)); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
TestFixture.Dispose(); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are a number of other places in this file that are wrong (
locate
, et al). I think a safer approach than trying to modify all the use sites is to havefile_entry_t::read
take an extraforce_extract
parameter, then pass it through to eachfile_entry_t
constructor and store it in a field. Then we can check the field inneeds_extraction
and avoid changing all the call sitesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - the problem is everywhere we call
entry.needs_extraction
, so it would be easier to bake it into theneeds_extraction
itself. It would feel cleaner if we stored something likeextracted
on each file entry.