forked from panuoksala/streamdeck-azuredevops-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegisterPluginAndStartStreamDeck.ps1
64 lines (44 loc) · 2.13 KB
/
RegisterPluginAndStartStreamDeck.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Write-Host "Gathering deployment items..."
Write-Host "Script root: $PSScriptRoot`n"
$basePath = $PSScriptRoot
if ($PSSCriptRoot.Length -eq 0) {
$basePath = $PWD.Path;
}
# Load and parse the plugin project file
$pluginProjectFile = "$basePath\StreamDeckAzureDevOps.csproj"
$projectContent = Get-Content $pluginProjectFile | Out-String;
$projectXML = [xml]$projectContent;
$buildConfiguration = "Debug"
# Get the target .net core framework
$targetFrameworkName = $projectXML.Project.PropertyGroup.TargetFramework;
# Set local path references
$streamDeckExePath = "$($ENV:ProgramFiles)\Elgato\StreamDeck\StreamDeck.exe"
# For now, this PS script will only be run on Windows.
$bindir = "$basePath\bin\Debug\$targetFrameworkName\win-x64"
# Make sure we actually have a directory/build to deploy
If (-not (Test-Path $bindir)) {
Write-Error "The output directory `"$bindir`" was not found.`n You must first build the `"StreamDeckAzureDevOps`" project before calling this script.";
exit 1;
}
# Load and parse the plugin's manifest file
$manifestFile = $bindir +"\manifest.json"
$manifestContent = Get-Content $manifestFile | Out-String
$json = ConvertFrom-JSON $manifestcontent
$uuidAction = $json.Actions[0].UUID
$pluginID = $uuidAction.substring(0, $uuidAction.Length - ".action".Length)
$destDir = "$($env:APPDATA)\Elgato\StreamDeck\Plugins\$pluginID.sdPlugin"
$pluginName = Split-Path $basePath -leaf
Get-Process -Name ("StreamDeck", $pluginName) -ErrorAction SilentlyContinue | Stop-Process –force -ErrorAction SilentlyContinue | Wait-Process -Timeout 30
# Short wait as the files below might still be locked for few seconds after StreamDeck is closed.
Start-Sleep 4
# Delete the target directory, make sure the deployment/copy is clean
If (Test-Path $destDir) {
Remove-Item -Recurse -Force -Path $destDir
}
# Then copy all deployment items to the plugin directory
New-Item -Type Directory -Path $destDir -ErrorAction SilentlyContinue # | Out-Null
$bindir = $bindir +"\*"
Copy-Item -Path $bindir -Destination $destDir -Recurse
Write-Host "Deployment complete. Restarting the Stream Deck desktop application..."
Start-Process $streamDeckExePath
exit 0