-
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
Changes from 2 commits
b78bd59
8f99f05
a2c068e
85c42de
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 |
---|---|---|
|
@@ -947,9 +947,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |
|
||
<ItemGroup> | ||
<ResolvedFileToPublish Remove="@(_FilesToBundle)"/> | ||
<!-- ResolvedFileToPublish shouldn't include PublishedSingleFilePath, since the single-file bundle is written directly to the publish directory --> | ||
</ItemGroup> | ||
|
||
</Target> | ||
|
||
<UsingTask TaskName="GenerateBundle" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" /> | ||
|
@@ -959,12 +957,28 @@ Copyright (c) .NET Foundation. All rights reserved. | |
Inputs="@(_FilesToBundle)" | ||
Outputs="$(PublishedSingleFilePath)"> | ||
|
||
<PropertyGroup> | ||
<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 commentThe reason will be displayed to describe this comment to others. Learn more. IncludeAllContentInSingleFile not used? |
||
</PropertyGroup> | ||
|
||
<GenerateBundle FilesToBundle="@(_FilesToBundle)" | ||
AppHostName="$(PublishedSingleFileName)" | ||
IncludeSymbols="$(IncludeSymbolsInSingleFile)" | ||
TargetFrameworkVersion="$(_TargetFrameworkVersionWithoutV)" | ||
RuntimeIdentifier="$(RuntimeIdentifier)" | ||
OutputDir="$(PublishDir)" | ||
ShowDiagnosticOutput="false"/> | ||
|
||
ShowDiagnosticOutput="$(TraceSingleFileBundler)"> | ||
<Output TaskParameter="ExcludedFiles" ItemName="_FilesExcludedFromBundle"/> | ||
</GenerateBundle> | ||
|
||
<ItemGroup> | ||
<ResolvedFileToPublish Include="@(_FilesExcludedFromBundle)"/> | ||
<!-- ResolvedFileToPublish shouldn't include PublishedSingleFilePath, since the single-file bundle is written directly to the publish directory --> | ||
</ItemGroup> | ||
|
||
</Target> | ||
|
||
<!-- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,9 +66,9 @@ private PublishCommand GetPublishCommand() | |
return new PublishCommand(Log, testAsset.TestRoot); | ||
} | ||
|
||
private DirectoryInfo GetPublishDirectory(PublishCommand publishCommand) | ||
private DirectoryInfo GetPublishDirectory(PublishCommand publishCommand, string targetFramework = "netcoreapp3.0") | ||
{ | ||
return publishCommand.GetOutputDirectory(targetFramework: "netcoreapp3.0", | ||
return publishCommand.GetOutputDirectory(targetFramework: targetFramework, | ||
runtimeIdentifier: RuntimeInformation.RuntimeIdentifier); | ||
} | ||
|
||
|
@@ -352,5 +352,41 @@ public void It_rewrites_the_apphost_for_non_single_file_publish() | |
|
||
appHostSize.Should().BeLessThan(singleFileSize); | ||
} | ||
|
||
[CoreMSBuildOnlyTheory] | ||
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. are all these combinations necessary too? 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. Yes, for |
||
[InlineData("netcoreapp3.0", false)] | ||
[InlineData("netcoreapp3.0", true)] | ||
[InlineData("netcoreapp3.1", false)] | ||
[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 commentThe 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. 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. @wli3 I've added a new test 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. 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. If this is covered in runtime we can skip that. These are very slow tests * 6. Maybe just have one test to ensure
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. 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 commentThe 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 I think it is useful to have all the cases in the 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. |
||
{ | ||
var testProject = new TestProject() | ||
{ | ||
Name = "SingleFileTest", | ||
TargetFrameworks = targetFramework, | ||
IsSdkProject = true, | ||
IsExe = true, | ||
}; | ||
testProject.AdditionalProperties.Add("SelfContained", $"{selfContained}"); | ||
|
||
var testAsset = _testAssetsManager.CreateTestProject(testProject); | ||
var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); | ||
|
||
publishCommand.Execute(PublishSingleFile, RuntimeIdentifier) | ||
.Should() | ||
.Pass(); | ||
|
||
var publishDir = GetPublishDirectory(publishCommand, targetFramework).FullName; | ||
var singleFilePath = Path.Combine(publishDir, $"{testProject.Name}{Constants.ExeSuffix}"); | ||
|
||
var command = new RunExeCommand(Log, singleFilePath); | ||
command.Execute() | ||
.Should() | ||
.Pass() | ||
.And | ||
.HaveStdOutContaining("Hello World"); | ||
} | ||
} | ||
} |
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.