Skip to content

Commit 95c4909

Browse files
committed
fix setting ContainerAppCommand
1 parent 976c7dd commit 95c4909

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@
110110

111111
<ItemGroup Label="AppCommand Assignment" Condition="'$(ContainerAppCommandInstruction)' != 'None'">
112112
<!-- For self-contained, invoke the native executable as a single arg -->
113-
<ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and '$(UseAppHost)' == 'true' and !$(_ContainerIsTargetingWindows)" Include="$(ContainerWorkingDirectory)/$(AssemblyName)" />
114-
<ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and '$(UseAppHost)' == 'true' and $(_ContainerIsTargetingWindows)" Include="$(AssemblyName)$(_NativeExecutableExtension)" />
113+
<ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and '$(_ContainerIsSelfContained)' == 'true' and !$(_ContainerIsTargetingWindows)" Include="$(ContainerWorkingDirectory)/$(AssemblyName)" />
114+
<ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and '$(_ContainerIsSelfContained)' == 'true' and $(_ContainerIsTargetingWindows)" Include="$(AssemblyName)$(_NativeExecutableExtension)" />
115115
<!-- For non self-contained, invoke `dotnet` `app.dll` as separate args -->
116116
<ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0" Include="dotnet;$(TargetFileName)" />
117117
</ItemGroup>

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/EndToEndTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,39 @@ public void EndToEnd_NoAPI_Console()
688688
privateNuGetAssets.Delete(true);
689689
}
690690

691+
[DockerAvailableFact]
692+
public void EndToEnd_SingleArch_NoRid()
693+
{
694+
// Create a new console project
695+
DirectoryInfo newProjectDir = CreateNewProject("console");
696+
697+
string imageName = NewImageName();
698+
string imageTag = "1.0";
699+
700+
// Run PublishContainer for multi-arch
701+
CommandResult commandResult = new DotnetCommand(
702+
_testOutput,
703+
"publish",
704+
"/t:PublishContainer",
705+
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
706+
$"/p:ContainerRepository={imageName}",
707+
$"/p:ContainerImageTag={imageTag}",
708+
"/p:EnableSdkContainerSupport=true")
709+
.WithWorkingDirectory(newProjectDir.FullName)
710+
.Execute();
711+
commandResult.Should().Pass();
712+
713+
// Check that the containers can be run
714+
CommandResult processResultX64 = ContainerCli.RunCommand(
715+
_testOutput,
716+
"--rm",
717+
"--name",
718+
$"test-container-singlearch-norid",
719+
$"{imageName}:{imageTag}")
720+
.Execute();
721+
processResultX64.Should().Pass().And.HaveStdOut("Hello, World!");
722+
}
723+
691724
[DockerSupportsArchFact("linux/arm64")]
692725
public void EndToEndMultiArch_LocalRegistry()
693726
{

0 commit comments

Comments
 (0)