-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Single-File: Update Bundler Invocation. #11586
Conversation
74183f6
to
0523052
Compare
This change updates the SDK to: * Pass the correct target-OS settings to the bundler * Copy files excluded by the Bundler to the publish directory. * In .net 5, single-file apps will leave native binaries unbundled in the publish directory by default. * Since Single-file bundles are processed in the framework, hostpolicy and hostfxr DLLs cannot themselves be in the bundle (until statically linked singlefilehost is supported).
CC: @MSLukeWest |
Regarding
In these situations, It is not possible to accurately compute the list of published files without inspecting the file. For example, ILLink walks the IL in assemblies to determine reachability and drops assemblies that are unnecessary. (CC: @sbomer) The constraints for PublishedItemsOutputGroup required by WPF are:
@MSLukeWest verified that the constraints are met after the change. |
@dsplaisted @wli3 I'd like to get this fix in for Preview5. Thanks. |
<GenerateBundle FilesToBundle="@(_FilesToBundle)" | ||
AppHostName="$(PublishedSingleFileName)" | ||
IncludeSymbols="$(IncludeSymbolsInSingleFile)" | ||
IncludeNativeLibraries="$(IncludeNativeLibrariesInSingleFile)" |
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.
There are 4 new inputs. But there in only 1 set of tests.
Also if IncludeNativeLibraries is not currently used, let's not add it today
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.
OK Thanks @wli3, I've fixed this now.
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.
Hi @wli3, the PR tests have passed after the fix you recommended. Can you please take a look again? Thanks.
<TraceSingleFileBundler Condition="'$(TraceSingleFileBundler)' == ''">false</TraceSingleFileBundler> | ||
<IncludeSymbolsInSingleFile Condition="'$(IncludeSymbolsInSingleFile)' == ''">false</IncludeSymbolsInSingleFile> | ||
<IncludeNativeLibrariesInSingleFile Condition="'$(IncludeNativeLibrariesInSingleFile)' == ''">false</IncludeNativeLibrariesInSingleFile> | ||
<IncludeAllContentInSingleFile Condition="'$(IncludeAllContentInSingleFile)' == ''">false</IncludeAllContentInSingleFile> |
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.
IncludeAllContentInSingleFile not used?
<PropertyGroup> | ||
<TraceSingleFileBundler Condition="'$(TraceSingleFileBundler)' == ''">false</TraceSingleFileBundler> | ||
<IncludeSymbolsInSingleFile Condition="'$(IncludeSymbolsInSingleFile)' == ''">false</IncludeSymbolsInSingleFile> | ||
<IncludeNativeLibrariesInSingleFile Condition="'$(IncludeNativeLibrariesInSingleFile)' == ''">false</IncludeNativeLibrariesInSingleFile> |
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.
not used?
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.
Thanks, removed the initialization.
[InlineData("netcoreapp3.1", true)] | ||
[InlineData("netcoreapp5.0", false)] | ||
[InlineData("netcoreapp5.0", true)] | ||
public void It_runs_single_file_apps(string targetFramework, bool selfContained) |
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.
Could you change the assertion(assert different files are present or not) to reflect:
In .net 5, single-file apps will leave native binaries unbundled in the publish directory by default.
Since Single-file bundles are processed in the framework, hostpolicy and hostfxr DLLs cannot themselves be in the bundle (until statically linked singlefilehost is supported).
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.
@wli3 I've added a new test It_leaves_host_components_unbundled_when_necessary
for this.
I thought about this, but I originally didn't add the test here because it is a temporary idiosyncrasy of the host/hostmodel, and not a requirement for the SDK.
The host-tests do test for this:
https://github.com/dotnet/runtime/blob/master/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs#L58
https://github.com/dotnet/runtime/blob/master/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs#L63-L66
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.
If this is covered in runtime we can skip that. These are very slow tests * 6.
Maybe just have one test to ensure
ExcludedFiles = FilesToBundle.Zip(fileSpec, (item, spec) => (spec.Excluded) ? item : null).Where(x => x != null).ToArray();
works. As in assert one file in one tfm that should be exclude not being there.
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.
And is all these TFM combination necessary? Again, these are really slow tests. There is no SDK logic have if-else about TFM. Only one test in SDK is enough. Other coverage should be in dotnet/Runtime
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.
OK @wli3. I'll keep the one interesting case of .net5 self-contained in the It_rewrites_the_apphost_for_non_single_file_publish
test.
I think it is useful to have all the cases in the It_runs_single_file_apps
case.
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.
…en_necessary test
} | ||
|
||
// Core MSBuild only due to https://github.com/dotnet/sdk/issues/4244 | ||
[CoreMSBuildOnlyTheory] |
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.
are all these combinations necessary too?
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.
Yes, for It_runs_single_file_apps
I think we should have all combinations.
This guards against incompatibility between SDK and hostmodel that creates single-file apps that don't run correctly. I'm planning to add this test to integration tests in the installer branch, as recommended by Daniel.
/azp run dotnet-sdk-public-ci (Build Darwin Build_Release) |
No pipelines are associated with this pull request. |
This change updates the SDK to: