|
1 | | -# gl-vsts-tasks-build |
| 1 | +# gl-vsts-tasks-build |
| 2 | + |
| 3 | +This package provides npm utility commands to ease **VSTS Build And Release Tasks** extensions developement. |
| 4 | +This currently powers the development process behind [Geek Learning's VSTS extensions](https://marketplace.visualstudio.com/search?term=publisher%3A%22Geek%20Learning%22&target=VSTS&sortBy=Relevance). |
| 5 | + |
| 6 | +## Features |
| 7 | + |
| 8 | +* **Multiple packages generation** : This allows you to generate testing versions of the extension using unique ids, so you can easily |
| 9 | +test your extension and setup staged deployment to the store. At Geek Learning our CI builds 3 versions of the extension |
| 10 | +(Dev, Preview, Production) and stores them as build artifacts. We then use Release Management to publish them to the marketplace. |
| 11 | +Dev package is always published automatically upon successfull build. Preview and Production are manually pushed if it passes our |
| 12 | +final review. Ids and packages settings, are defined in the `Configuration.json` file |
| 13 | +* **Manifest automation** : We automatically populate the contributions in the vss-extension in order to reduced manual maintainance |
| 14 | +of this file. |
| 15 | +* **Common shared code** : We provide an easy way to share powershell or node scripts accros your tasks without the need to make a |
| 16 | +package of them. Place them in the right subfolder of `Common` and they will be automatically copied where appropriate on build. |
| 17 | +* **Node : Automic dependency installation** : Vsts Agent node execution engine requires npm dependencies to be bundled with your task |
| 18 | +We automatically install two dependencies as a postbuild step after a successfull `npm install` at root. |
| 19 | +* **Automatic versionning** : Visual Studio Marketplace does not support semver, but we always rely on it when it comes to versionnning. |
| 20 | +As a result we needed a way to encode our semver to a Major.Minor.Patch format. This feature can be switched of if you rely on another |
| 21 | +source of versionning. |
| 22 | + |
| 23 | +## Project structure |
| 24 | + |
| 25 | +At the moment, if you wish to use this tooling, your project will need to comply with the architecture we designed. |
| 26 | + |
| 27 | +Directory Structure |
| 28 | +``` |
| 29 | +Root |
| 30 | +|-- package.json |
| 31 | +|-- Configuration.json |
| 32 | +|-- tsconfig.json // Optional if not using typescript |
| 33 | +|-- Common // Optional |
| 34 | +| |-- Node // Node common scripts |
| 35 | +| | |-- *.ts |
| 36 | +| | |
| 37 | +| |-- Powershell3 // Powershell3 common scripts |
| 38 | +| | |-- *.ps1 |
| 39 | +| |
| 40 | +|-- Extension |
| 41 | +| |-- vss-extension.json // Extension Manifest |
| 42 | +| |-- ... |
| 43 | +| |
| 44 | +|-- Tasks // Task Directory |
| 45 | +| |-- NodeTask1 |
| 46 | +| | |-- task.json // Task manifest |
| 47 | +| | |-- icon.png // Task icon |
| 48 | +| | |-- package.json // Package.json, this is where this task dependencies must be listed |
| 49 | +| | |-- *.ts // Task source files |
| 50 | +| | |-- ... |
| 51 | +| | |
| 52 | +| |-- PowershellTask1 |
| 53 | +| | |-- task.json |
| 54 | +| | |-- icon.png |
| 55 | +| | |-- *.ps1 // Task powershell scripts |
| 56 | +| | |-- ... |
| 57 | +| | |
| 58 | +| | -- ... |
| 59 | +``` |
| 60 | + |
| 61 | +## Root `Package.json` |
| 62 | + |
| 63 | +First you should install this package |
| 64 | + |
| 65 | +```bash |
| 66 | +npm install gl-vsts-tasks-build-scripts --save-dev |
| 67 | +``` |
| 68 | + |
| 69 | +Then to get the best of this tooling we recommand that you tweak your `package.json` file a little by adding a few `scripts` : |
| 70 | +```json |
| 71 | +{ |
| 72 | + "scripts": { |
| 73 | + "clean": "vsts-build-tools-clean", |
| 74 | + "postinstall": "vsts-build-tools-install", |
| 75 | + "prebuild": "vsts-build-tools-prebuild", |
| 76 | + "build": "tsc", |
| 77 | + "package": "vsts-build-tools-package" |
| 78 | + } |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +You can now restore or update dependencies and task bundled dependencies by running a single `npm install` at the root. |
| 83 | +You can clean common files using `npm run clean` |
| 84 | +You can build node tasks using `npm run build` |
| 85 | +You can package your extension by running `npm run package`. Output will be placed in the `.BuildOutput` subdirectory at root. |
| 86 | + |
| 87 | + |
0 commit comments