Skip to content
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

Merged
merged 4 commits into from
May 15, 2020
Merged

Conversation

swaroop-sridhar
Copy link
Contributor

@swaroop-sridhar swaroop-sridhar commented May 8, 2020

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).

@swaroop-sridhar swaroop-sridhar force-pushed the params branch 6 times, most recently from 74183f6 to 0523052 Compare May 12, 2020 23:29
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).
@swaroop-sridhar
Copy link
Contributor Author

CC: @MSLukeWest

@swaroop-sridhar
Copy link
Contributor Author

Regarding PublishedItemsOutputGroup and FilesCopiedToPublishDir items, when the list is computed without actually building the output, the list of files computed may be inaccurate in the following situations:

  • PublishTrimmed=true
  • PublishSingleFile=true without IncludeAllContentInSingleFile=true,

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:

  • Design time build where the build files don't exist:
    • Computed list of items doesn't reflect final list,
    • The targets that need the build files to exist get skipped using a condition
    • The computed list correctly identifies the KeyOutput.
  • Full build: Computed list of items is correct

@MSLukeWest verified that the constraints are met after the change.

@swaroop-sridhar
Copy link
Contributor Author

@dsplaisted @wli3 I'd like to get this fix in for Preview5. Thanks.

<GenerateBundle FilesToBundle="@(_FilesToBundle)"
AppHostName="$(PublishedSingleFileName)"
IncludeSymbols="$(IncludeSymbolsInSingleFile)"
IncludeNativeLibraries="$(IncludeNativeLibrariesInSingleFile)"
Copy link

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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>
Copy link

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>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used?

Copy link
Contributor Author

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)
Copy link

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).

Copy link
Contributor Author

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

Copy link

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.

Copy link

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wli3 This is done in 85c42de

}

// Core MSBuild only due to https://github.com/dotnet/sdk/issues/4244
[CoreMSBuildOnlyTheory]
Copy link

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?

Copy link
Contributor Author

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.

@swaroop-sridhar
Copy link
Contributor Author

@wli3 I published the PR against Preview 5 branch here: #11659

@swaroop-sridhar
Copy link
Contributor Author

/azp run dotnet-sdk-public-ci (Build Darwin Build_Release)

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@wli3 wli3 merged commit 7d3fecc into dotnet:master May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants