@@ -780,6 +780,112 @@ public void EndToEndMultiArch_LocalRegistry()
780
780
newProjectDir . Delete ( true ) ;
781
781
}
782
782
783
+ [ DockerAvailableFact ]
784
+ public void MultiArchStillAllowsSingleRID ( )
785
+ {
786
+ string imageName = NewImageName ( ) ;
787
+ string imageTag = "1.0" ;
788
+ string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
789
+ string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
790
+
791
+ // Create a new console project
792
+ DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
793
+
794
+ // Run PublishContainer for multi-arch-capable, but single-arch actual
795
+ CommandResult commandResult = new DotnetCommand (
796
+ _testOutput ,
797
+ "publish" ,
798
+ "/t:PublishContainer" ,
799
+ // make it so the app is _able_ to target both linux TFMs
800
+ "/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
801
+ // and that it opts into to multi-targeting containers for both of those linux TFMs
802
+ "/p:ContainerRuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
803
+ // but then only actually publishes for one of them
804
+ "/p:ContainerRuntimeIdentifier=linux-x64" ,
805
+ $ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
806
+ $ "/p:ContainerRepository={ imageName } ",
807
+ $ "/p:ContainerImageTag={ imageTag } ",
808
+ "/p:EnableSdkContainerSupport=true" ,
809
+ "/bl" )
810
+ . WithWorkingDirectory ( newProjectDir . FullName )
811
+ . Execute ( ) ;
812
+
813
+ // Check that the app was published for each RID,
814
+ // images were created locally for each RID
815
+ // and image index was NOT created
816
+ commandResult . Should ( ) . Pass ( )
817
+ . And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
818
+ . And . NotHaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
819
+ . And . HaveStdOutContaining ( $ "Pushed image '{ imageX64 } ' to local registry")
820
+ . And . NotHaveStdOutContaining ( $ "Pushed image '{ imageArm64 } ' to local registry")
821
+ . And . NotHaveStdOutContaining ( "Pushed image index" ) ;
822
+
823
+ // Check that the containers can be run
824
+ CommandResult processResultX64 = ContainerCli . RunCommand (
825
+ _testOutput ,
826
+ "--rm" ,
827
+ "--name" ,
828
+ $ "test-container-{ imageName } -x64",
829
+ imageX64 )
830
+ . Execute ( ) ;
831
+ processResultX64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
832
+
833
+ // Cleanup
834
+ newProjectDir . Delete ( true ) ;
835
+ }
836
+
837
+ [ DockerAvailableFact ]
838
+ public void MultiArchStillAllowsSingleRIDUsingJustRIDProperties ( )
839
+ {
840
+ string imageName = NewImageName ( ) ;
841
+ string imageTag = "1.0" ;
842
+ string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
843
+ string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
844
+
845
+ // Create a new console project
846
+ DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
847
+
848
+ // Run PublishContainer for multi-arch-capable, but single-arch actual
849
+ CommandResult commandResult = new DotnetCommand (
850
+ _testOutput ,
851
+ "publish" ,
852
+ "/t:PublishContainer" ,
853
+ // make it so the app is _able_ to target both linux TFMs
854
+ "/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
855
+ // but then only actually publishes for one of them
856
+ "-r linux-x64" ,
857
+ $ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
858
+ $ "/p:ContainerRepository={ imageName } ",
859
+ $ "/p:ContainerImageTag={ imageTag } ",
860
+ "/p:EnableSdkContainerSupport=true" ,
861
+ "/bl" )
862
+ . WithWorkingDirectory ( newProjectDir . FullName )
863
+ . Execute ( ) ;
864
+
865
+ // Check that the app was published for each RID,
866
+ // images were created locally for each RID
867
+ // and image index was NOT created
868
+ commandResult . Should ( ) . Pass ( )
869
+ . And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
870
+ . And . NotHaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
871
+ . And . HaveStdOutContaining ( $ "Pushed image '{ imageX64 } ' to local registry")
872
+ . And . NotHaveStdOutContaining ( $ "Pushed image '{ imageArm64 } ' to local registry")
873
+ . And . NotHaveStdOutContaining ( "Pushed image index" ) ;
874
+
875
+ // Check that the containers can be run
876
+ CommandResult processResultX64 = ContainerCli . RunCommand (
877
+ _testOutput ,
878
+ "--rm" ,
879
+ "--name" ,
880
+ $ "test-container-{ imageName } -x64",
881
+ imageX64 )
882
+ . Execute ( ) ;
883
+ processResultX64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
884
+
885
+ // Cleanup
886
+ newProjectDir . Delete ( true ) ;
887
+ }
888
+
783
889
private DirectoryInfo CreateNewProject ( string template , [ CallerMemberName ] string callerMemberName = "" )
784
890
{
785
891
DirectoryInfo newProjectDir = new DirectoryInfo ( Path . Combine ( TestSettings . TestArtifactsDirectory , callerMemberName ) ) ;
0 commit comments