@@ -79,40 +79,6 @@ public void It_builds_a_runnable_apphost_by_default(string targetFramework)
79
79
. HaveStdOutContaining ( "Hello World!" ) ;
80
80
}
81
81
82
- [ PlatformSpecificTheory ( TestPlatforms . OSX ) ]
83
- [ InlineData ( "netcoreapp3.1" ) ]
84
- [ InlineData ( "net5.0" ) ]
85
- [ InlineData ( ToolsetInfo . CurrentTargetFramework ) ]
86
- public void It_can_disable_codesign_if_opt_out ( string targetFramework )
87
- {
88
- var testAsset = _testAssetsManager
89
- . CopyTestAsset ( "HelloWorld" , identifier : targetFramework )
90
- . WithSource ( )
91
- . WithTargetFramework ( targetFramework ) ;
92
-
93
- var buildCommand = new BuildCommand ( testAsset ) ;
94
- buildCommand
95
- . Execute ( new string [ ] {
96
- "/p:_EnableMacOSCodeSign=false;ProduceReferenceAssembly=false" ,
97
- } )
98
- . Should ( )
99
- . Pass ( ) ;
100
-
101
- var outputDirectory = buildCommand . GetOutputDirectory ( targetFramework ) ;
102
- var appHostFullPath = Path . Combine ( outputDirectory . FullName , "HelloWorld" ) ;
103
-
104
- // Check that the apphost was not signed
105
- var codesignPath = @"/usr/bin/codesign" ;
106
- new RunExeCommand ( Log , codesignPath , new string [ ] { "-d" , appHostFullPath } )
107
- . Execute ( )
108
- . Should ( )
109
- . Fail ( )
110
- . And
111
- . HaveStdErrContaining ( $ "{ appHostFullPath } : code object is not signed at all") ;
112
-
113
- outputDirectory . Should ( ) . OnlyHaveFiles ( GetExpectedFilesFromBuild ( testAsset , targetFramework ) ) ;
114
- }
115
-
116
82
[ PlatformSpecificTheory ( TestPlatforms . OSX ) ]
117
83
[ InlineData ( "netcoreapp3.1" , "win-x64" ) ]
118
84
[ InlineData ( "net5.0" , "win-x64" ) ]
@@ -153,11 +119,15 @@ public void It_does_not_try_to_codesign_non_osx_app_hosts(string targetFramework
153
119
}
154
120
155
121
[ Theory ]
156
- [ InlineData ( "net6.0" , "osx-x64" ) ]
157
- [ InlineData ( "net6.0" , "osx-arm64" ) ]
158
- [ InlineData ( ToolsetInfo . CurrentTargetFramework , "osx-x64" ) ]
159
- [ InlineData ( ToolsetInfo . CurrentTargetFramework , "osx-arm64" ) ]
160
- public void It_codesigns_an_app_targeting_osx ( string targetFramework , string rid )
122
+ [ InlineData ( "net8.0" , "osx-x64" , true ) ]
123
+ [ InlineData ( "net8.0" , "osx-arm64" , true ) ]
124
+ [ InlineData ( ToolsetInfo . CurrentTargetFramework , "osx-x64" , true ) ]
125
+ [ InlineData ( ToolsetInfo . CurrentTargetFramework , "osx-arm64" , true ) ]
126
+ [ InlineData ( "net8.0" , "osx-x64" , false ) ]
127
+ [ InlineData ( "net8.0" , "osx-arm64" , false ) ]
128
+ [ InlineData ( ToolsetInfo . CurrentTargetFramework , "osx-x64" , false ) ]
129
+ [ InlineData ( ToolsetInfo . CurrentTargetFramework , "osx-arm64" , false ) ]
130
+ public void It_codesigns_an_app_targeting_osx ( string targetFramework , string rid , bool shouldSign )
161
131
{
162
132
const string testAssetName = "HelloWorld" ;
163
133
var testAsset = _testAssetsManager
@@ -166,7 +136,7 @@ public void It_codesigns_an_app_targeting_osx(string targetFramework, string rid
166
136
. WithTargetFramework ( targetFramework ) ;
167
137
168
138
var buildCommand = new BuildCommand ( testAsset ) ;
169
- var buildArgs = new List < string > ( ) { $ "/p:RuntimeIdentifier={ rid } " } ;
139
+ var buildArgs = new List < string > ( ) { $ "/p:RuntimeIdentifier={ rid } ", $ "/p:_EnableMacOSCodeSign= { shouldSign } " } ;
170
140
buildCommand
171
141
. Execute ( buildArgs . ToArray ( ) )
172
142
. Should ( )
@@ -176,12 +146,12 @@ public void It_codesigns_an_app_targeting_osx(string targetFramework, string rid
176
146
var appHostFullPath = Path . Combine ( outputDirectory . FullName , testAssetName ) ;
177
147
178
148
// Check that the apphost is signed
179
- MachOSignature . HasMachOSignatureLoadCommand ( new FileInfo ( appHostFullPath ) ) . Should ( ) . BeTrue ( ) ;
149
+ MachOSignature . HasMachOSignatureLoadCommand ( new FileInfo ( appHostFullPath ) ) . Should ( ) . Be ( shouldSign , $ "The app host should { ( shouldSign ? "" : "not " ) } have a Mach-O signature load command." ) ;
180
150
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
181
151
{
182
- MachOSignature . HasValidMachOSignature ( new FileInfo ( appHostFullPath ) )
152
+ MachOSignature . HasValidMachOSignature ( new FileInfo ( appHostFullPath ) , Log )
183
153
. Should ( )
184
- . BeTrue ( $ "The app host should have a valid Mach-O signature for { rid } .") ;
154
+ . Be ( shouldSign , $ "The app host should have a valid Mach-O signature for { rid } .") ;
185
155
}
186
156
}
187
157
0 commit comments