@@ -85,7 +85,7 @@ private string GetNativeDll(string baseName)
85
85
private DirectoryInfo GetPublishDirectory ( PublishCommand publishCommand , string targetFramework = ToolsetInfo . CurrentTargetFramework , string runtimeIdentifier = null )
86
86
{
87
87
return publishCommand . GetOutputDirectory ( targetFramework : targetFramework ,
88
- runtimeIdentifier : runtimeIdentifier ?? RuntimeInformation . RuntimeIdentifier ) ;
88
+ runtimeIdentifier : runtimeIdentifier ?? RuntimeInformation . RuntimeIdentifier ) ;
89
89
}
90
90
91
91
[ Fact ]
@@ -416,7 +416,7 @@ public void It_generates_a_single_file_with_all_content_for_self_contained_apps(
416
416
}
417
417
418
418
// 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'.
420
420
[ PlatformSpecificTheory ( TestPlatforms . Any & ~ TestPlatforms . OSX ) ]
421
421
[ InlineData ( "netcoreapp3.0" ) ]
422
422
[ InlineData ( "netcoreapp3.1" ) ]
@@ -756,17 +756,20 @@ public void EnableSingleFile_warns_when_expected_for_not_correctly_multitargeted
756
756
testProject . AdditionalProperties [ "CheckEolTargetFramework" ] = "false" ; // Silence warning about targeting EOL TFMs
757
757
var testAsset = _testAssetsManager . CreateTestProject ( testProject , identifier : targetFrameworks )
758
758
. WithProjectChanges ( AddTargetFrameworkAliases ) ;
759
-
759
+
760
760
var buildCommand = new BuildCommand ( testAsset ) ;
761
761
var resultAssertion = buildCommand . Execute ( "/p:CheckEolTargetFramework=false" )
762
762
. Should ( ) . Pass ( ) ;
763
- if ( shouldWarn ) {
763
+ if ( shouldWarn )
764
+ {
764
765
// Note: can't check for Strings.EnableSingleFileAnalyzerUnsupported because each line of
765
766
// the message gets prefixed with a file path by MSBuild.
766
767
resultAssertion
767
768
. And . HaveStdOutContaining ( $ "warning NETSDK1211")
768
769
. And . HaveStdOutContaining ( $ "<EnableSingleFileAnalyzer Condition=\" $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\" >true</EnableSingleFileAnalyzer>") ;
769
- } else {
770
+ }
771
+ else
772
+ {
770
773
resultAssertion . And . NotHaveStdOutContaining ( $ "warning") ;
771
774
}
772
775
}
@@ -1144,38 +1147,52 @@ static void VerifyPrepareForBundle(XDocument project)
1144
1147
[ InlineData ( "osx-arm64" , true ) ]
1145
1148
[ InlineData ( "osx-x64" , false ) ]
1146
1149
[ 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 )
1148
1153
{
1154
+ const bool CodesignsByDefault = true ;
1149
1155
var targetFramework = ToolsetInfo . CurrentTargetFramework ;
1150
1156
var testProject = new TestProject ( )
1151
1157
{
1152
1158
Name = "SingleFileTest" ,
1153
1159
TargetFrameworks = targetFramework ,
1154
1160
IsExe = true ,
1155
1161
} ;
1156
- testProject . AdditionalProperties . Add ( "SelfContained" , $ "true") ;
1162
+ testProject . AdditionalProperties . Add ( "SelfContained" , "true" ) ;
1157
1163
1158
1164
var testAsset = _testAssetsManager . CreateTestProject (
1159
1165
testProject ,
1160
1166
identifier : $ "{ rid } _{ enableMacOSCodeSign } ") ;
1161
1167
var publishCommand = new PublishCommand ( testAsset ) ;
1162
1168
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 )
1164
1180
. Should ( )
1165
1181
. Pass ( ) ;
1166
1182
1167
1183
var publishDir = GetPublishDirectory ( publishCommand , targetFramework , runtimeIdentifier : rid ) . FullName ;
1168
1184
var singleFilePath = Path . Combine ( publishDir , $ "{ testProject . Name } { Constants . ExeSuffix } ") ;
1169
1185
1186
+ bool shouldBeSigned = enableMacOSCodeSign ?? CodesignsByDefault ;
1187
+
1170
1188
MachOSignature . HasMachOSignatureLoadCommand ( new FileInfo ( singleFilePath ) )
1171
1189
. 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.") ;
1174
1191
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
1175
1192
{
1176
1193
MachOSignature . HasValidMachOSignature ( new FileInfo ( singleFilePath ) , Log )
1177
1194
. 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 } .") ;
1179
1196
}
1180
1197
}
1181
1198
}
0 commit comments