@@ -85,7 +85,7 @@ private string GetNativeDll(string baseName)
8585 private DirectoryInfo GetPublishDirectory ( PublishCommand publishCommand , string targetFramework = ToolsetInfo . CurrentTargetFramework , string runtimeIdentifier = null )
8686 {
8787 return publishCommand . GetOutputDirectory ( targetFramework : targetFramework ,
88- runtimeIdentifier : runtimeIdentifier ?? RuntimeInformation . RuntimeIdentifier ) ;
88+ runtimeIdentifier : runtimeIdentifier ?? RuntimeInformation . RuntimeIdentifier ) ;
8989 }
9090
9191 [ Fact ]
@@ -416,7 +416,7 @@ public void It_generates_a_single_file_with_all_content_for_self_contained_apps(
416416 }
417417
418418 // https://github.com/dotnet/sdk/issues/49665
419- // error NETSDK1084: There is no application host available for the specified RuntimeIdentifier 'osx-arm64'.
419+ // error NETSDK1084: There is no application host available for the specified RuntimeIdentifier 'osx-arm64'.
420420 [ PlatformSpecificTheory ( TestPlatforms . Any & ~ TestPlatforms . OSX ) ]
421421 [ InlineData ( "netcoreapp3.0" ) ]
422422 [ InlineData ( "netcoreapp3.1" ) ]
@@ -756,17 +756,20 @@ public void EnableSingleFile_warns_when_expected_for_not_correctly_multitargeted
756756 testProject . AdditionalProperties [ "CheckEolTargetFramework" ] = "false" ; // Silence warning about targeting EOL TFMs
757757 var testAsset = _testAssetsManager . CreateTestProject ( testProject , identifier : targetFrameworks )
758758 . WithProjectChanges ( AddTargetFrameworkAliases ) ;
759-
759+
760760 var buildCommand = new BuildCommand ( testAsset ) ;
761761 var resultAssertion = buildCommand . Execute ( "/p:CheckEolTargetFramework=false" )
762762 . Should ( ) . Pass ( ) ;
763- if ( shouldWarn ) {
763+ if ( shouldWarn )
764+ {
764765 // Note: can't check for Strings.EnableSingleFileAnalyzerUnsupported because each line of
765766 // the message gets prefixed with a file path by MSBuild.
766767 resultAssertion
767768 . And . HaveStdOutContaining ( $ "warning NETSDK1211")
768769 . And . HaveStdOutContaining ( $ "<EnableSingleFileAnalyzer Condition=\" $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\" >true</EnableSingleFileAnalyzer>") ;
769- } else {
770+ }
771+ else
772+ {
770773 resultAssertion . And . NotHaveStdOutContaining ( $ "warning") ;
771774 }
772775 }
@@ -1144,38 +1147,52 @@ static void VerifyPrepareForBundle(XDocument project)
11441147 [ InlineData ( "osx-arm64" , true ) ]
11451148 [ InlineData ( "osx-x64" , false ) ]
11461149 [ InlineData ( "osx-arm64" , false ) ]
1147- public void It_codesigns_an_app_targeting_osx ( string rid , bool enableMacOSCodeSign )
1150+ [ InlineData ( "osx-x64" , null ) ]
1151+ [ InlineData ( "osx-arm64" , null ) ]
1152+ public void It_codesigns_an_app_targeting_osx ( string rid , bool ? enableMacOSCodeSign )
11481153 {
1154+ const bool CodesignsByDefault = true ;
11491155 var targetFramework = ToolsetInfo . CurrentTargetFramework ;
11501156 var testProject = new TestProject ( )
11511157 {
11521158 Name = "SingleFileTest" ,
11531159 TargetFrameworks = targetFramework ,
11541160 IsExe = true ,
11551161 } ;
1156- testProject . AdditionalProperties . Add ( "SelfContained" , $ "true") ;
1162+ testProject . AdditionalProperties . Add ( "SelfContained" , "true" ) ;
11571163
11581164 var testAsset = _testAssetsManager . CreateTestProject (
11591165 testProject ,
11601166 identifier : $ "{ rid } _{ enableMacOSCodeSign } ") ;
11611167 var publishCommand = new PublishCommand ( testAsset ) ;
11621168
1163- publishCommand . Execute ( PublishSingleFile , $ "/p:RuntimeIdentifier={ rid } ", $ "/p:_EnableMacOSCodeSign={ enableMacOSCodeSign } ")
1169+ List < string > publishArgs = new List < string > ( 3 )
1170+ {
1171+ PublishSingleFile ,
1172+ $ "/p:RuntimeIdentifier={ rid } "
1173+ } ;
1174+ if ( enableMacOSCodeSign . HasValue )
1175+ {
1176+ publishArgs . Add ( $ "/p:_EnableMacOSCodeSign={ enableMacOSCodeSign . Value } ") ;
1177+ }
1178+
1179+ publishCommand . Execute ( publishArgs )
11641180 . Should ( )
11651181 . Pass ( ) ;
11661182
11671183 var publishDir = GetPublishDirectory ( publishCommand , targetFramework , runtimeIdentifier : rid ) . FullName ;
11681184 var singleFilePath = Path . Combine ( publishDir , $ "{ testProject . Name } { Constants . ExeSuffix } ") ;
11691185
1186+ bool shouldBeSigned = enableMacOSCodeSign ?? CodesignsByDefault ;
1187+
11701188 MachOSignature . HasMachOSignatureLoadCommand ( new FileInfo ( singleFilePath ) )
11711189 . Should ( )
1172- . Be ( enableMacOSCodeSign , $ "The app host should { ( enableMacOSCodeSign ? "" : "not " ) } have a Mach-O signature load command.") ;
1173-
1190+ . Be ( shouldBeSigned , $ "The app host should { ( shouldBeSigned ? "" : "not " ) } have a Mach-O signature load command.") ;
11741191 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
11751192 {
11761193 MachOSignature . HasValidMachOSignature ( new FileInfo ( singleFilePath ) , Log )
11771194 . Should ( )
1178- . Be ( enableMacOSCodeSign , $ "The app host should { ( enableMacOSCodeSign ? "" : "not " ) } have a valid Mach-O signature for { rid } .") ;
1195+ . Be ( shouldBeSigned , $ "The app host should { ( shouldBeSigned ? "" : "not " ) } have a valid Mach-O signature for { rid } .") ;
11791196 }
11801197 }
11811198 }
0 commit comments