@@ -17,7 +17,6 @@ import NetworkSettings from '../src/networkSettings';
1717import { downloadAndInstallPackages } from '../src/packageManager/downloadAndInstallPackages' ;
1818import { getRuntimeDependenciesPackages } from '../src/tools/runtimeDependencyPackageUtils' ;
1919import { getAbsolutePathPackagesToInstall } from '../src/packageManager/getAbsolutePathPackagesToInstall' ;
20- import { commandLineOptions } from '../tasks/commandLineArguments' ;
2120import {
2221 codeExtensionPath ,
2322 packedVsixOutputRoot ,
@@ -33,8 +32,14 @@ import path = require('path');
3332// eslint-disable-next-line @typescript-eslint/no-var-requires
3433const argv = require ( 'yargs' ) . argv ;
3534
35+ interface VSIXPlatformInfo {
36+ vsceTarget : string ;
37+ rid : string ;
38+ platformInfo : PlatformInformation ;
39+ }
40+
3641// Mapping of vsce vsix packaging target to the RID used to build the server executable
37- export const platformSpecificPackages = [
42+ export const platformSpecificPackages : VSIXPlatformInfo [ ] = [
3843 { vsceTarget : 'win32-x64' , rid : 'win-x64' , platformInfo : new PlatformInformation ( 'win32' , 'x86_64' ) } ,
3944 { vsceTarget : 'win32-ia32' , rid : 'win-x86' , platformInfo : new PlatformInformation ( 'win32' , 'x86' ) } ,
4045 { vsceTarget : 'win32-arm64' , rid : 'win-arm64' , platformInfo : new PlatformInformation ( 'win32' , 'arm64' ) } ,
@@ -46,16 +51,46 @@ export const platformSpecificPackages = [
4651 { vsceTarget : 'darwin-arm64' , rid : 'osx-arm64' , platformInfo : new PlatformInformation ( 'darwin' , 'arm64' ) } ,
4752] ;
4853
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+ }
5273
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 ) ;
5479} ) ;
5580
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+
5691// Downloads dependencies for local development.
5792gulp . task ( 'installDependencies' , async ( ) => {
58- await cleanAsync ( /* deleteVsix: */ false ) ;
93+ await cleanAsync ( ) ;
5994
6095 const packageJSON = getPackageJSON ( ) ;
6196
@@ -210,7 +245,8 @@ async function acquireNugetPackage(packageName: string, packageVersion: string,
210245 return packageOutputPath ;
211246}
212247
213- async function doPackageOffline ( ) {
248+ async function doPackageOffline ( vsixPlatform : VSIXPlatformInfo | undefined ) {
249+ await cleanAsync ( ) ;
214250 // Set the package.json version based on the value in version.json.
215251 const versionInfo = await nbgv . getVersion ( ) ;
216252 console . log ( versionInfo . npmPackageVersion ) ;
@@ -229,38 +265,37 @@ async function doPackageOffline() {
229265 // Now that we've updated the version, get the package.json.
230266 const packageJSON = getPackageJSON ( ) ;
231267
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 ;
248273 }
249274
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---` ) ;
252291 } finally {
253292 // Reset package version to the placeholder value.
254293 await nbgv . resetPackageVersionPlaceholder ( ) ;
255294 }
256295}
257296
258- async function cleanAsync ( deleteVsix : boolean ) {
297+ async function cleanAsync ( ) {
259298 await del ( [ 'install.*' , '.omnisharp*' , '.debugger' , '.razor' , languageServerDirectory ] ) ;
260-
261- if ( deleteVsix ) {
262- await del ( '*.vsix' ) ;
263- }
264299}
265300
266301async function buildVsix (
@@ -270,8 +305,6 @@ async function buildVsix(
270305 vsceTarget ?: string ,
271306 platformInfo ?: PlatformInformation
272307) {
273- await cleanAsync ( false ) ;
274-
275308 await installRoslyn ( packageJSON , platformInfo ) ;
276309
277310 if ( platformInfo != null ) {
0 commit comments