Upload
jesse-houwing
View
228
Download
5
Embed Size (px)
Citation preview
Extend Build and Releaseusing TypeScript or PowerShell
Jesse HouwingLead Consultant Xpirit@jessehouwing
#TECHDAYSNL @VSTEAM
JesseHouwingLead Consultant at Xpirit@[email protected]
• Built a custom MsBuild Task?• Hand-edited a Visual Studio Project File?• Customized a targets file?• Built a XAML activity?
• Created his own Node/Bower/Grunt package?
• Created a build task that’s out on the Market Place?
Who has ever…
A very quick recapBuild agents run tasks
• Tasks run tools
• Tasks run scripts
• Tasks run tools that run scripts
Many tasks onThe Visual Studio Marketplace
What if you do something special?Write a PowerShell or Batch script, commit it to your repo and call it from a build.
You can run your scripts
in-line
When would you create a task?• When the functionality doesn’t ship out of the box• When there is no task available on the marketplace
• To make your script re-usable• To make it easy for others to consume your script• To interact with the agent
• When you want to share your creation to the world
Where to startRead the VSTS Task SDK docsLook at the VSTS Task LibraryPeek at the tasks on the build agentC:\TfsData\Build\_work\_tasks\*
Must have toolboxNodeJShttps://nodejs.org/en/
Typingsnpm install typings -g
TypeScriptnpm install typescript -g
TFS-CLI (tfx)npm install tfx-cli -g
VS
PowerShell or TypeScript or Both?PowerShell TypeScriptSupported on Windows Supported on Windows, Linux and MacCan call into existing PowerShell modules Can call PowerShell.exe for similar functionalityCan call into existing .NET APIs Can call PowerShell.exe for similar functionalityOnly supported on Windows Single implementation for all platformsDynamic typing Static typing with compiler and linterUses TFS Client Object Model to talk to TFS / VSTS REST and SOAP endpoints
Uses TypeScript SDK to task to TFS / VSTS REST endpoints
Yes you can code a task directly in JavaScript, but why would you?!
I’m starting to prefer TypeScript
TypeScript
An Extension manifestExtension ID and Publisher
A Task manifestTask ID and Task Name
Inputs & Execution
Implementation(s)Powershell or TypeScript/Javascript
DependenciesTask SDKTools & other assemblies
Create a task using Typescript
DEMO
Create a task using PowerShell
DEMO
Tips & Tricks
Dependencies
• Embed them in your task / extension
• Fetch them on demand
• Demand their existence through Capabilities and Demands
Capabilities & Demands
DEMO
Tasks run locally now!Making them much easier to test than before!
Testing your tasksArrange• Import the SDK• Set Environment variable
Act• Execute your task
Assert• Inspect the expected results
Out-of-the-box mocks are on their way!
A note on variables
!
Don’t rely on variablesUse inputs instead
Versioning• Always increase your version with every
publish• Always increase both the Extension version
and the Task version• Use a different Extension ID to limit
visibilityDevID: PingTask-DEVVisibility: PrivateShare: Your Dev Account
PreviewID: PingTask-PREVIEWVisibility: Private PreviewShare: Trusted Accounts
PublicID: PingTaskVisibility: Public
And agent versionsVersion Shipped with PowerShell PowerShell
SDKJavascript XPlat
Node SDK
1.83 TFS 2015 RTM Yes Preview1.89 TFS 2015 QU 1 Yes Preview1.95 TFS 2015 QU 2 Yes Yes Preview
1.95.1 TFS 2015 QU 2.1
Yes Yes Yes
1.95.3 TFS 2015 QU 3 Yes Yes Yes
1.105.6 VSTS Yes Yes Yes2.105 TFS 15 RC Back compat Yes Yes2.107 VSTS Back compat Yes Yes
When open-sourcing
• Override Extension ID• Override Publisher• Set your version to 0.0.0• Omit/Set visibility to
private
• This prevents people from accidentally publishing a duplicate extension
! {
"manifestVersion": 1,
"id": "vsts-extension-tasks-
DEV",
"name": "VSTS Extension
Tasks",
"version": "0.0.0",
"publisher": “set-your-own",
“public": “false“
}
Setup a build pipeline for your tasks• Use VSTS to build and publish your tasks• And Remember your PAT for you
Setting up Build & Release in VSTSDEMO
Help improve extensions by submitting your issues and pull requests to GitHub!
Next steps…Publish your own tasks to the marketplace?
THANK YOU!Jesse HouwingLead Consultant Xpirit
[email protected]@jessehouwing
#TECHDAYSNL @VSTEAM
bit.ly/XpiritMagazine
bit.ly/td-minihacks