How I fixed my problem that my VSTS Build Extension was too big to upload to the Marketplace
Whist adding a couple of new tasks to my VSTS Manifest Versioning Extension I hit the problem that VSIX package became too big to upload to the Marketplace. The error I saw in my CI/CD VSTS pipeline was``` ##vso[task.logissue type=error;]error: Failed Request: Bad Request(400) - The extension package size '23255292 bytes' exceeds the maximum package size '20971520 bytes'
1
21. They get a list of files
32. Extract a version number from the build number
43. Then apply this to one or more files in a product/task specific manner
5
6there has been some cut and paste coding. This means that I have NPM modules in the tasks **package.json** file that were not needed for a given task. I could manually address this but there is an NPM module to help, DepCheck. First install the [DepCheck](https://www.npmjs.com/package/depcheck) module```
7npm install depcheck –g
8```then run **depcheck** from the command line whist within your task’s folder. This returns a list of modules listed in the **package.json** that are not referenced in the code files. These can then be removed from the **package.json.** e.g. I saw```
9Unused dependencies
10\* @types/node
11\* @types/q
12\* Buffer
13\* fs
14\* request
15\* tsd
16Unused devDependencies
17\* @types/chai
18\* @types/mocha
19\* @types/node
20\* mocha-junit-reporter
21\* ts-loader
22\* ts-node
23\* typings
24```The important ones to focus on are the first block (non-development references), as these are the ones that are packaged with the production code in the VSIX; I was already pruning the **node\_module** folder of development dependencies prior to creating the VSIX to remove devDependancies using the command```
25npm prune –production
26```I did find some of the listed modules strange, as I knew they really were needed and a quick test of removing them did show the code failed if they were missing. These are what [depchecks documentation calls false alerts](https://www.npmjs.com/package/depcheck). I found I could remove the **@type/xxx** and **tsd** references, which were the big ones, that are only needed in development when working in TypeScript. Once these were removed for all four of my NodeJS based tasks my VSIX dropped in size from 22Mb to 7Mb. So problem solved.