@@ -181,7 +181,7 @@ public async Task ApiEndToEndWithArchiveWritingAndLoad()
181181
182182 [ DockerAvailableFact ]
183183 public async Task TarballsHaveCorrectStructure ( )
184- {
184+ {
185185 var archiveFile = Path . Combine ( TestSettings . TestArtifactsDirectory ,
186186 nameof ( TarballsHaveCorrectStructure ) , "app.tar.gz" ) ;
187187
@@ -190,7 +190,7 @@ public async Task TarballsHaveCorrectStructure()
190190 await BuildDockerImageWithArciveDestinationAsync ( archiveFile , [ "latest" ] , nameof ( TarballsHaveCorrectStructure ) ) ;
191191
192192 await destinationReference . LocalRegistry ! . LoadAsync ( dockerImage , sourceReference , destinationReference , default ) . ConfigureAwait ( false ) ;
193-
193+
194194 Assert . True ( File . Exists ( archiveFile ) , $ "File.Exists({ archiveFile } )") ;
195195
196196 CheckDockerTarballStructure ( archiveFile ) ;
@@ -778,6 +778,112 @@ public void EndToEndMultiArch_LocalRegistry()
778778 newProjectDir . Delete ( true ) ;
779779 }
780780
781+ [ DockerAvailableFact ]
782+ public void MultiArchStillAllowsSingleRID ( )
783+ {
784+ string imageName = NewImageName ( ) ;
785+ string imageTag = "1.0" ;
786+ string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
787+ string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
788+
789+ // Create a new console project
790+ DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
791+
792+ // Run PublishContainer for multi-arch-capable, but single-arch actual
793+ CommandResult commandResult = new DotnetCommand (
794+ _testOutput ,
795+ "publish" ,
796+ "/t:PublishContainer" ,
797+ // make it so the app is _able_ to target both linux TFMs
798+ "/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
799+ // and that it opts into to multi-targeting containers for both of those linux TFMs
800+ "/p:ContainerRuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
801+ // but then only actually publishes for one of them
802+ "/p:ContainerRuntimeIdentifier=linux-x64" ,
803+ $ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
804+ $ "/p:ContainerRepository={ imageName } ",
805+ $ "/p:ContainerImageTag={ imageTag } ",
806+ "/p:EnableSdkContainerSupport=true" ,
807+ "/bl" )
808+ . WithWorkingDirectory ( newProjectDir . FullName )
809+ . Execute ( ) ;
810+
811+ // Check that the app was published for each RID,
812+ // images were created locally for each RID
813+ // and image index was NOT created
814+ commandResult . Should ( ) . Pass ( )
815+ . And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
816+ . And . NotHaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
817+ . And . HaveStdOutContaining ( $ "Pushed image '{ imageX64 } ' to local registry")
818+ . And . NotHaveStdOutContaining ( $ "Pushed image '{ imageArm64 } ' to local registry")
819+ . And . NotHaveStdOutContaining ( "Pushed image index" ) ;
820+
821+ // Check that the containers can be run
822+ CommandResult processResultX64 = ContainerCli . RunCommand (
823+ _testOutput ,
824+ "--rm" ,
825+ "--name" ,
826+ $ "test-container-{ imageName } -x64",
827+ imageX64 )
828+ . Execute ( ) ;
829+ processResultX64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
830+
831+ // Cleanup
832+ newProjectDir . Delete ( true ) ;
833+ }
834+
835+ [ DockerAvailableFact ]
836+ public void MultiArchStillAllowsSingleRIDUsingJustRIDProperties ( )
837+ {
838+ string imageName = NewImageName ( ) ;
839+ string imageTag = "1.0" ;
840+ string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
841+ string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
842+
843+ // Create a new console project
844+ DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
845+
846+ // Run PublishContainer for multi-arch-capable, but single-arch actual
847+ CommandResult commandResult = new DotnetCommand (
848+ _testOutput ,
849+ "publish" ,
850+ "/t:PublishContainer" ,
851+ // make it so the app is _able_ to target both linux TFMs
852+ "/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
853+ // but then only actually publishes for one of them
854+ "-r linux-x64" ,
855+ $ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
856+ $ "/p:ContainerRepository={ imageName } ",
857+ $ "/p:ContainerImageTag={ imageTag } ",
858+ "/p:EnableSdkContainerSupport=true" ,
859+ "/bl" )
860+ . WithWorkingDirectory ( newProjectDir . FullName )
861+ . Execute ( ) ;
862+
863+ // Check that the app was published for each RID,
864+ // images were created locally for each RID
865+ // and image index was NOT created
866+ commandResult . Should ( ) . Pass ( )
867+ . And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
868+ . And . NotHaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
869+ . And . HaveStdOutContaining ( $ "Pushed image '{ imageX64 } ' to local registry")
870+ . And . NotHaveStdOutContaining ( $ "Pushed image '{ imageArm64 } ' to local registry")
871+ . And . NotHaveStdOutContaining ( "Pushed image index" ) ;
872+
873+ // Check that the containers can be run
874+ CommandResult processResultX64 = ContainerCli . RunCommand (
875+ _testOutput ,
876+ "--rm" ,
877+ "--name" ,
878+ $ "test-container-{ imageName } -x64",
879+ imageX64 )
880+ . Execute ( ) ;
881+ processResultX64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
882+
883+ // Cleanup
884+ newProjectDir . Delete ( true ) ;
885+ }
886+
781887 private DirectoryInfo CreateNewProject ( string template , [ CallerMemberName ] string callerMemberName = "" )
782888 {
783889 DirectoryInfo newProjectDir = new DirectoryInfo ( Path . Combine ( TestSettings . TestArtifactsDirectory , callerMemberName ) ) ;
@@ -839,8 +945,8 @@ public void EndToEndMultiArch_ArchivePublishing()
839945 . And . HaveStdOutContaining ( $ "Pushed image '{ imageArm64 } ' to local archive at '{ imageArm64Tarball } '")
840946 . And . NotHaveStdOutContaining ( "Pushed image index" ) ;
841947
842- // Check that tarballs were created
843- File . Exists ( imageX64Tarball ) . Should ( ) . BeTrue ( ) ;
948+ // Check that tarballs were created
949+ File . Exists ( imageX64Tarball ) . Should ( ) . BeTrue ( ) ;
844950 File . Exists ( imageArm64Tarball ) . Should ( ) . BeTrue ( ) ;
845951
846952 // Load the images from the tarballs
@@ -886,7 +992,7 @@ public void EndToEndMultiArch_RemoteRegistry()
886992
887993 // Create a new console project
888994 DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
889-
995+
890996 // Run PublishContainer for multi-arch with ContainerRegistry
891997 CommandResult commandResult = new DotnetCommand (
892998 _testOutput ,
0 commit comments