Skip to content

Commit 339a4a8

Browse files
authored
Merge branch 'release/9.0.1xx' into FixBuffer1xx
2 parents aadf9d1 + 40c57de commit 339a4a8

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,9 @@ Copyright (c) .NET Foundation. All rights reserved.
790790

791791
<!--
792792
============================================================
793-
_GetAppHostPaths
794-
Gets the path to apphost (restored via packages or in an apphost pack),
795-
and computes the path for the destination apphost.
793+
_GetAppHostCreationConfiguration
794+
Computes the properties for configuration of apphost creation
795+
during either build or publish
796796
============================================================
797797
-->
798798
<Target Name="_GetAppHostCreationConfiguration"
@@ -981,7 +981,7 @@ Copyright (c) .NET Foundation. All rights reserved.
981981
============================================================
982982
-->
983983
<Target Name="_ComputeNETCoreBuildOutputFiles"
984-
DependsOnTargets="_GetAppHostPaths;_GetComHostPaths;_GetIjwHostPaths"
984+
DependsOnTargets="_GetAppHostPaths;_GetAppHostCreationConfiguration;_GetComHostPaths;_GetIjwHostPaths"
985985
BeforeTargets="AssignTargetPaths"
986986
Condition="'$(ComputeNETCoreBuildOutputFiles)' == 'true'">
987987

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,44 @@ public void It_does_not_rewrite_the_single_file_unnecessarily()
551551
fileWriteTimeAfterSecondRun.Should().Be(fileWriteTimeAfterFirstRun);
552552
}
553553

554+
[RequiresMSBuildVersionFact("16.8.0")]
555+
public void It_uses_appropriate_host_on_selfcontained_publish_with_no_build()
556+
{
557+
var testProject = new TestProject()
558+
{
559+
Name = "SingleFileTest",
560+
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
561+
RuntimeIdentifier = RuntimeInformation.RuntimeIdentifier,
562+
IsExe = true,
563+
};
564+
testProject.AdditionalProperties.Add("SelfContained", "true");
565+
TestAsset testAsset = _testAssetsManager.CreateTestProject(testProject);
566+
567+
// Build will create app using apphost
568+
var buildCommand = new BuildCommand(testAsset);
569+
buildCommand
570+
.Execute()
571+
.Should()
572+
.Pass();
573+
574+
// Publish without build should create app using singlefilehost
575+
var publishCommand = new PublishCommand(testAsset);
576+
publishCommand
577+
.Execute(PublishSingleFile, "/p:NoBuild=true")
578+
.Should()
579+
.Pass();
580+
string singleFilePath = Path.Combine(
581+
GetPublishDirectory(publishCommand).FullName,
582+
$"{testProject.Name}{Constants.ExeSuffix}");
583+
584+
// Make sure published app runs correctly
585+
var command = new RunExeCommand(Log, singleFilePath);
586+
command.Execute()
587+
.Should()
588+
.Pass()
589+
.And.HaveStdOutContaining("Hello World");
590+
}
591+
554592
[RequiresMSBuildVersionFact("16.8.0")]
555593
public void It_rewrites_the_apphost_for_single_file_publish()
556594
{

0 commit comments

Comments
 (0)