@@ -70,7 +70,7 @@ var netCoreProject = new {
70
70
} ) ;
71
71
72
72
73
- Task ( "Package-Mac " )
73
+ Task ( "Create-Bundle " )
74
74
. IsDependentOn ( "Publish-NetCore" )
75
75
. Does ( ( ) =>
76
76
{
@@ -83,7 +83,7 @@ var netCoreProject = new {
83
83
Information ( "Copying Info.plist" ) ;
84
84
EnsureDirectoryExists ( tempDir . Combine ( "Contents" ) ) ;
85
85
CopyFileToDirectory ( $ "{ netCoreAppsRoot } /{ netCoreApp } /Info.plist", tempDir . Combine ( "Contents" ) ) ;
86
-
86
+
87
87
// Update versions in Info.plist
88
88
var plistFile = tempDir . Combine ( "Contents" ) . CombineWithFilePath ( "Info.plist" ) ;
89
89
dynamic plist = DeserializePlist ( plistFile ) ;
@@ -102,11 +102,100 @@ var netCoreProject = new {
102
102
EnsureDirectoryExists ( workingDir ) ;
103
103
MoveDirectory ( tempDir , workingDir . Combine ( $ "{ macAppName } .app") ) ;
104
104
105
- var architecture = runtime [ ( runtime . IndexOf ( "-" ) + 1 ) ..] ;
106
- Zip ( workingDir . FullPath , workingDir . CombineWithFilePath ( $ "../{ macAppName } -{ architecture } .zip") ) ;
105
+ // var architecture = runtime[(runtime.IndexOf("-")+1)..];
106
+ // Zip(workingDir.FullPath, workingDir.CombineWithFilePath($"../{macAppName}-{architecture}.zip"));
107
107
}
108
108
} ) ;
109
109
110
+ Task ( "Sign-Bundle" )
111
+ . IsDependentOn ( "Create-Bundle" )
112
+ . Does ( ( ) =>
113
+ {
114
+ var runtimeIdentifiers = netCoreProject . Runtimes . Where ( r => r . StartsWith ( "osx" ) ) ;
115
+ var entitlementsFilePath = $ "{ netCoreAppsRoot } /{ netCoreApp } /Entitlements.plist";
116
+
117
+ foreach ( var runtime in runtimeIdentifiers )
118
+ {
119
+ Information ( $ "Starting { runtime } macOS app signing") ;
120
+
121
+ var appBundlePath = artifactsDir . Combine ( runtime ) . Combine ( $ "{ macAppName } .app") ;
122
+ var signingIdentity = "Developer ID Application" ;
123
+
124
+ foreach ( var dylib in GetFiles ( $ "{ appBundlePath } /**/*.dylib") )
125
+ {
126
+ Information ( $ "Signing { dylib } library") ;
127
+
128
+ // Sign the library:
129
+ var args = new ProcessArgumentBuilder ( ) ;
130
+ args . Append ( "--force" ) ;
131
+ args . Append ( "--sign" ) ;
132
+ args . AppendQuoted ( signingIdentity ) ;
133
+ args . AppendQuoted ( dylib . ToString ( ) ) ;
134
+
135
+ StartProcess ( "codesign" , new ProcessSettings
136
+ {
137
+ Arguments = args . RenderSafe ( ) ,
138
+ RedirectStandardOutput = true ,
139
+ RedirectStandardError = true
140
+ } ) ;
141
+ }
142
+
143
+ // Sign the bundle:
144
+ {
145
+ Information ( $ "Signing { appBundlePath } bundle") ;
146
+
147
+ var args = new ProcessArgumentBuilder ( ) ;
148
+ args . Append ( "--force" ) ;
149
+ args . Append ( "--timestamp" ) ;
150
+ args . Append ( "--options=runtime" ) ;
151
+ args . Append ( "--entitlements " + entitlementsFilePath ) ;
152
+ args . Append ( "--sign" ) ;
153
+ args . AppendQuoted ( signingIdentity ) ;
154
+ args . AppendQuoted ( appBundlePath . ToString ( ) ) ;
155
+
156
+ StartProcess ( "codesign" , new ProcessSettings
157
+ {
158
+ Arguments = args . RenderSafe ( ) ,
159
+ RedirectStandardOutput = true ,
160
+ RedirectStandardError = true
161
+ } ) ;
162
+ }
163
+ }
164
+ } ) ;
165
+
166
+ Task ( "Compress-Bundle" )
167
+ . IsDependentOn ( "Sign-Bundle" )
168
+ . Does ( ( ) =>
169
+ {
170
+ var runtimeIdentifiers = netCoreProject . Runtimes . Where ( r => r . StartsWith ( "osx" ) ) ;
171
+ foreach ( var runtime in runtimeIdentifiers )
172
+ {
173
+ Information ( $ "Compressing { runtime } macOS bundle") ;
174
+ var appBundlePath = artifactsDir . Combine ( runtime ) . Combine ( $ "{ macAppName } .app") ;
175
+ var zippedPath = artifactsDir . Combine ( runtime ) . CombineWithFilePath ( $ "../{ macAppName } .zip") ;
176
+
177
+ var args = new ProcessArgumentBuilder ( ) ;
178
+ args . Append ( "-c" ) ;
179
+ args . Append ( "-k" ) ;
180
+ args . Append ( "--keepParent" ) ;
181
+ args . AppendQuoted ( appBundlePath . ToString ( ) ) ;
182
+ args . AppendQuoted ( zippedPath . ToString ( ) ) ;
183
+
184
+ // "Ditto" is absolutely necessary instead of "zip" command.
185
+ StartProcess ( "ditto" , new ProcessSettings
186
+ {
187
+ Arguments = args . RenderSafe ( ) ,
188
+ RedirectStandardOutput = true ,
189
+ RedirectStandardError = true
190
+ } ) ;
191
+ }
192
+ } ) ;
193
+
194
+ Task ( "Package-Mac" )
195
+ . IsDependentOn ( "Create-Bundle" )
196
+ . IsDependentOn ( "Sign-Bundle" )
197
+ . IsDependentOn ( "Compress-Bundle" ) ;
198
+
110
199
Task ( "Default" )
111
200
. IsDependentOn ( "Restore-NetCore" )
112
201
. IsDependentOn ( "Publish-NetCore" )
0 commit comments