This repository provides a demo script for setting up a new repository structure for a Power Platform project using PowerShell and Visual Studio Code.
Warning
The snippets are work in progress and they are not finished!
You can watch the related walkthrough videos on our YouTube channel:
📺 Power Platform Demo Playlist
-
Install Visual Studio Code
Download VS Code -
Install PowerShell (macOS only)
This demo uses PowerShell scripts. On macOS, install PowerShell using the following command:dotnet tool install --global PowerShell
Tip
macOS: you can start PowerShell from Terminal by running pwsh
-
Create a working directory and required folders
mkdir dev-loop-demo; ` mkdir dev-loop-demo/.vscode; ` mkdir dev-loop-demo/.demo; ` code -r dev-loop-demo
-
Open PowerShell in VS Code
- Press
Ctrl + ` - Or use the menu:
Terminal → New Terminal
- Press
Tip
macOS: Cmd + J shortcut + Run pwsh to enter PowerShell
-
Download the code snippet files by running the following command
(Invoke-RestMethod 'https://api.github.com/repos/TALXIS/docs-patterns-practices/contents/dev-loops?ref=master') | Where-Object { $_.type -eq 'file' -and $_.name -like '*.code-snippets' -and $_.download_url } | ForEach-Object { Invoke-WebRequest $_.download_url -OutFile ".vscode\$($_.name)" }; (Invoke-RestMethod 'https://api.github.com/repos/TALXIS/docs-patterns-practices/contents/dev-loops/scripts?ref=master') | Where-Object { $_.type -eq 'file' -and $_.name -eq 'DemoVariables.ps1' -and $_.download_url } | ForEach-Object { Invoke-WebRequest $_.download_url -OutFile ".demo\DemoVariables.ps1" }
Warning
GitHub API might return an error 'No server is currently available to service your request' In such case, wait few moments and execute the command again.
-
Create a PowerShell script file to use during the demo and open it
New-Item -ItemType File -Name '.demo/DemoScriptPad.ps1'; ` code .demo/DemoScriptPad.ps1
-
Start typing in the script file
Start typing
CFAto insert the first snippet. Select the right snippet with arrows and confirm with the enter key. -
Optional: Bind F5 to clear the terminal and run the whole script
Paste the following into the terminal to create a custom keybinding:
$keybinding = @' [ { "key": "f5", "command": "runCommands", "args": { "commands": [ "workbench.action.terminal.clear", "PowerShell.Debug.Start" ] }, "when": "editorTextFocus && editorLangId == 'powershell'" } ]
'@
$path = ".vscode/keybindings.json" if (-not (Test-Path ".vscode")) { mkdir .vscode } Set-Content -Path $path -Value $keybinding
10. **Running the script**
- Press `F8` to run selected lines of code
- Press `F5` to run the whole script (after setting up the keybinding in the previous step)
