@@ -17,7 +17,6 @@ import NetworkSettings from '../src/networkSettings';
17
17
import { downloadAndInstallPackages } from '../src/packageManager/downloadAndInstallPackages' ;
18
18
import { getRuntimeDependenciesPackages } from '../src/tools/runtimeDependencyPackageUtils' ;
19
19
import { getAbsolutePathPackagesToInstall } from '../src/packageManager/getAbsolutePathPackagesToInstall' ;
20
- import { commandLineOptions } from '../tasks/commandLineArguments' ;
21
20
import {
22
21
codeExtensionPath ,
23
22
packedVsixOutputRoot ,
@@ -33,8 +32,14 @@ import path = require('path');
33
32
// eslint-disable-next-line @typescript-eslint/no-var-requires
34
33
const argv = require ( 'yargs' ) . argv ;
35
34
35
+ interface VSIXPlatformInfo {
36
+ vsceTarget : string ;
37
+ rid : string ;
38
+ platformInfo : PlatformInformation ;
39
+ }
40
+
36
41
// Mapping of vsce vsix packaging target to the RID used to build the server executable
37
- export const platformSpecificPackages = [
42
+ export const platformSpecificPackages : VSIXPlatformInfo [ ] = [
38
43
{ vsceTarget : 'win32-x64' , rid : 'win-x64' , platformInfo : new PlatformInformation ( 'win32' , 'x86_64' ) } ,
39
44
{ vsceTarget : 'win32-ia32' , rid : 'win-x86' , platformInfo : new PlatformInformation ( 'win32' , 'x86' ) } ,
40
45
{ vsceTarget : 'win32-arm64' , rid : 'win-arm64' , platformInfo : new PlatformInformation ( 'win32' , 'arm64' ) } ,
@@ -46,16 +51,46 @@ export const platformSpecificPackages = [
46
51
{ vsceTarget : 'darwin-arm64' , rid : 'osx-arm64' , platformInfo : new PlatformInformation ( 'darwin' , 'arm64' ) } ,
47
52
] ;
48
53
49
- gulp . task ( 'vsix:release:package' , async ( ) => {
50
- //if user does not want to clean up the existing vsix packages
51
- await cleanAsync ( /* deleteVsix: */ ! commandLineOptions . retainVsix ) ;
54
+ const vsixTasks : string [ ] = [ ] ;
55
+ for ( const p of platformSpecificPackages ) {
56
+ let platformName : string ;
57
+ if ( p . platformInfo . isWindows ( ) ) {
58
+ platformName = 'windows' ;
59
+ } else if ( p . platformInfo . isLinux ( ) ) {
60
+ platformName = 'linux' ;
61
+ } else if ( p . platformInfo . isMacOS ( ) ) {
62
+ platformName = 'darwin' ;
63
+ } else {
64
+ throw new Error ( `Unexpected platform ${ p . platformInfo . platform } ` ) ;
65
+ }
66
+
67
+ const taskName = `vsix:release:package:${ platformName } :${ p . vsceTarget } ` ;
68
+ vsixTasks . push ( taskName ) ;
69
+ gulp . task ( taskName , async ( ) => {
70
+ await doPackageOffline ( p ) ;
71
+ } ) ;
72
+ }
52
73
53
- await doPackageOffline ( ) ;
74
+ gulp . task ( 'vsix:release:package:windows' , gulp . series ( ...vsixTasks . filter ( ( t ) => t . includes ( 'windows' ) ) ) ) ;
75
+ gulp . task ( 'vsix:release:package:linux' , gulp . series ( ...vsixTasks . filter ( ( t ) => t . includes ( 'linux' ) ) ) ) ;
76
+ gulp . task ( 'vsix:release:package:darwin' , gulp . series ( ...vsixTasks . filter ( ( t ) => t . includes ( 'darwin' ) ) ) ) ;
77
+ gulp . task ( 'vsix:release:package:neutral' , async ( ) => {
78
+ await doPackageOffline ( undefined ) ;
54
79
} ) ;
55
80
81
+ gulp . task (
82
+ 'vsix:release:package' ,
83
+ gulp . series (
84
+ 'vsix:release:package:windows' ,
85
+ 'vsix:release:package:linux' ,
86
+ 'vsix:release:package:darwin' ,
87
+ 'vsix:release:package:neutral'
88
+ )
89
+ ) ;
90
+
56
91
// Downloads dependencies for local development.
57
92
gulp . task ( 'installDependencies' , async ( ) => {
58
- await cleanAsync ( /* deleteVsix: */ false ) ;
93
+ await cleanAsync ( ) ;
59
94
60
95
const packageJSON = getPackageJSON ( ) ;
61
96
@@ -210,7 +245,8 @@ async function acquireNugetPackage(packageName: string, packageVersion: string,
210
245
return packageOutputPath ;
211
246
}
212
247
213
- async function doPackageOffline ( ) {
248
+ async function doPackageOffline ( vsixPlatform : VSIXPlatformInfo | undefined ) {
249
+ await cleanAsync ( ) ;
214
250
// Set the package.json version based on the value in version.json.
215
251
const versionInfo = await nbgv . getVersion ( ) ;
216
252
console . log ( versionInfo . npmPackageVersion ) ;
@@ -229,38 +265,37 @@ async function doPackageOffline() {
229
265
// Now that we've updated the version, get the package.json.
230
266
const packageJSON = getPackageJSON ( ) ;
231
267
232
- for ( const p of platformSpecificPackages ) {
233
- try {
234
- if ( process . platform === 'win32' && ! p . rid . startsWith ( 'win' ) ) {
235
- console . warn (
236
- `Skipping packaging for ${ p . rid } on Windows since runtime executables will not be marked executable in *nix packages.`
237
- ) ;
238
- continue ;
239
- }
240
-
241
- await buildVsix ( packageJSON , packedVsixOutputRoot , prerelease , p . vsceTarget , p . platformInfo ) ;
242
- } catch ( err ) {
243
- const message = ( err instanceof Error ? err . stack : err ) ?? '<unknown error>' ;
244
- // NOTE: Extra `\n---` at the end is because gulp will print this message following by the
245
- // stack trace of this line. So that seperates the two stack traces.
246
- throw Error ( `Failed to create package ${ p . vsceTarget } . ${ message } \n---` ) ;
247
- }
268
+ if ( process . platform === 'win32' && ! vsixPlatform ?. rid . startsWith ( 'win' ) ) {
269
+ console . warn (
270
+ `Skipping packaging for ${ vsixPlatform ?. rid } on Windows since runtime executables will not be marked executable in *nix packages.`
271
+ ) ;
272
+ return ;
248
273
}
249
274
250
- // Also output the platform neutral VSIX using the platform neutral server bits we created before.
251
- await buildVsix ( packageJSON , packedVsixOutputRoot , prerelease ) ;
275
+ if ( vsixPlatform === undefined ) {
276
+ await buildVsix ( packageJSON , packedVsixOutputRoot , prerelease ) ;
277
+ } else {
278
+ await buildVsix (
279
+ packageJSON ,
280
+ packedVsixOutputRoot ,
281
+ prerelease ,
282
+ vsixPlatform . vsceTarget ,
283
+ vsixPlatform . platformInfo
284
+ ) ;
285
+ }
286
+ } catch ( err ) {
287
+ const message = ( err instanceof Error ? err . stack : err ) ?? '<unknown error>' ;
288
+ // NOTE: Extra `\n---` at the end is because gulp will print this message following by the
289
+ // stack trace of this line. So that seperates the two stack traces.
290
+ throw Error ( `Failed to create package ${ vsixPlatform ?. vsceTarget ?? 'neutral' } . ${ message } \n---` ) ;
252
291
} finally {
253
292
// Reset package version to the placeholder value.
254
293
await nbgv . resetPackageVersionPlaceholder ( ) ;
255
294
}
256
295
}
257
296
258
- async function cleanAsync ( deleteVsix : boolean ) {
297
+ async function cleanAsync ( ) {
259
298
await del ( [ 'install.*' , '.omnisharp*' , '.debugger' , '.razor' , languageServerDirectory ] ) ;
260
-
261
- if ( deleteVsix ) {
262
- await del ( '*.vsix' ) ;
263
- }
264
299
}
265
300
266
301
async function buildVsix (
@@ -270,8 +305,6 @@ async function buildVsix(
270
305
vsceTarget ?: string ,
271
306
platformInfo ?: PlatformInformation
272
307
) {
273
- await cleanAsync ( false ) ;
274
-
275
308
await installRoslyn ( packageJSON , platformInfo ) ;
276
309
277
310
if ( platformInfo != null ) {
0 commit comments