Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 48
Browse files Browse the repository at this point in the history
  • Loading branch information
panuoksala committed Jun 2, 2024
2 parents 8b303ee + c81151c commit 9121ddf
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 46 deletions.
24 changes: 14 additions & 10 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
using StreamDeckLib;
using Microsoft.Extensions.Hosting;
using StreamDeckLib;
using StreamDeckLib.DependencyInjection;
using StreamDeckLib.Hosting;
using System.Net.WebSockets;
using System.Threading.Tasks;

namespace StreamDeckAzureDevOps
{
class Program
{

static async Task Main(string[] args)
public static void Main(string[] args)
{
using (var config = StreamDeckLib.Config.ConfigurationBuilder.BuildDefaultConfiguration(args))
{
await ConnectionManager.Initialize(args, config.LoggerFactory)
.RegisterAllActions(typeof(Program).Assembly)
.StartAsync();
}

CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureStreamDeckToolkit(args)
.ConfigureServices((hostContext, services) =>
{
services.AddStreamDeck(hostContext.Configuration, typeof(Program).Assembly);
});
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ If Stream Deck shows red question icon on top right corner of the button, check
4. Visual Studio should automatically add Azure DevOps button into your Stream Deck app / device.
5. To debug the app just run it and attach debugger into StreamDeck application (you might have two so try both).
6. If you experience problems try to run the Visual Studio in Administrator mode.
7. Build/Rebuild will stop StreamDeck app, so start it manually after every build. It will reload changes automatically.

If you have problems to build plugin after debugging, quick fix is to restart Visual Studio.

Expand Down
56 changes: 26 additions & 30 deletions RegisterPluginAndStartStreamDeck.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
Write-Host "Gathering deployment items..."

Write-Host "Script root: $PSScriptRoot`n"
Write-Host "Current Working Directory: $(get-location)"

$basePath = $PSScriptRoot
$basePath = $(get-location)

if ($PSSCriptRoot.Length -eq 0) {
$basePath = $PWD.Path;
}


# Load and parse the plugin project file
$pluginProjectFile = "$basePath\StreamDeckAzureDevOps.csproj"
# Load and parse the plugin project file - Fully expects there to be only one csproj file in there
$pluginProjectFile = Get-ChildItem -Filter *.csproj | Select-Object -First 1
$projectContent = Get-Content $pluginProjectFile | Out-String;
$projectXML = [xml]$projectContent;

Expand All @@ -20,45 +15,46 @@ $buildConfiguration = "Debug"
$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"
if ($IsMacOS) {
$streamDeckExePath = "/Applications/Stream Deck.app"
$bindir = "$basePath/bin/Debug/$targetFrameworkName/osx-x64"
} else {
$streamDeckExePath = "$($ENV:ProgramFiles)\Elgato\StreamDeck\StreamDeck.exe"
$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.";
Write-Error "The output directory `"$bindir`" was not found.`n You must first build the 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
$manifestPath = Join-Path $bindir "manifest.json"
$json = Get-Content -Path $manifestPath -Raw | ConvertFrom-Json

$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
if($IsMacOS) {
$destDir = "$HOME/Library/Application Support/com.elgato.StreamDeck/Plugins/$pluginID.sdPlugin"
} else {
$destDir = "$($env:APPDATA)\Elgato\StreamDeck\Plugins\$pluginID.sdPlugin"
}

Get-Process -Name ("StreamDeck", $pluginName) -ErrorAction SilentlyContinue | Stop-Process –force -ErrorAction SilentlyContinue | Wait-Process -Timeout 30
$pluginName = Split-Path $basePath -leaf

# Short wait as the files below might still be locked for few seconds after StreamDeck is closed.
Start-Sleep 4
Get-Process -Name ("StreamDeck", $pluginName) -ErrorAction SilentlyContinue | Stop-Process –force -ErrorAction SilentlyContinue

# Delete the target directory, make sure the deployment/copy is clean
If (Test-Path $destDir) {
Remove-Item -Recurse -Force -Path $destDir
}
Remove-Item -Recurse -Force -Path $destDir -ErrorAction SilentlyContinue
$bindir = Join-Path $bindir "*"

# 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
Write-Host "Deployment complete. We will NOT restart the Stream Deck desktop application here, but will from the template..."
# Start-Process $streamDeckExePath
exit 0
10 changes: 6 additions & 4 deletions StreamDeckAzureDevOps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<RuntimeIdentifier Condition=" '$(OS)' == 'Windows_NT' and '$(Configuration)'=='Debug' ">win-x64</RuntimeIdentifier>
<!-- When building/running on Windows -->
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition=" '$(OS)' != 'Windows_NT' and '$(Configuration)'=='Debug' ">osx-x64</RuntimeIdentifier>
<!-- When on non-Windows environment, assume macOS for now -->
<!-- At this time, the only platforms we are really targetting, and supported by the Stream Deck SDK are Windows and macOS -->
<RuntimeIdentifiers Condition="'$(Configuration)'=='Release' ">win-x64;osx-x64</RuntimeIdentifiers>
<!-- At this time, the only platforms we are really targetting, and supported by the Stream Deck SDK are Windows and macOS -->
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>

Expand All @@ -25,10 +26,11 @@

<!--Dependencies-->
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="19.225.1" />
<PackageReference Include="Microsoft.TeamFoundationServer.ExtendedClient" Version="19.225.1" />
<PackageReference Include="Microsoft.VisualStudio.Services.Client" Version="19.225.1" />
<PackageReference Include="Microsoft.VisualStudio.Services.Release.Client" Version="16.191.0-preview" />
<PackageReference Include="Microsoft.VisualStudio.Services.Release.Client" Version="19.225.1" />
<PackageReference Include="StreamDeckLib" Version="0.*" />
<PackageReference Include="StreamDeckLib.Config" Version="0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
Expand All @@ -37,7 +39,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Net.WebSockets" Version="4.3.0" />
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"Name": "AzureDevOpsRunner",
"Icon": "images/Azure-DevOps72",
"URL": "https://github.com/panuoksala/streamdeck-azuredevops-plugin",
"Version": "1.4.0",
"Version": "1.5.0",
"SDKVersion": 2,
"Software": {
"MinimumVersion": "4.1"
"MinimumVersion": "5.0"
},
"OS": [
{
Expand Down

0 comments on commit 9121ddf

Please sign in to comment.