diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5fa488a..48c8104 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -78,3 +78,7 @@ jobs:
Or download the Source Code and Build it on your own.
files: ./MouseTrap-${{ steps.version.outputs.version }}.zip
+ - name: Push to Chocolatey
+ env:
+ CHOCO_TOKEN: ${{ secrets.CHOCO_TOKEN }}
+ run: pwsh .\MouseTrap\choco\Push.ps1 -nuspec .\MouseTrap\choco\MouseTrap.nuspec -zip ./MouseTrap-${{ steps.version.outputs.version }}.zip -version ${{ steps.version.outputs.version_tag }}
\ No newline at end of file
diff --git a/MouseTrap.sln b/MouseTrap.sln
index 7912c87..92db6a6 100644
--- a/MouseTrap.sln
+++ b/MouseTrap.sln
@@ -9,7 +9,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\build.yml = .github\workflows\build.yml
+ LICENSE.txt = LICENSE.txt
README.md = README.md
+ VERIFICATION.txt = VERIFICATION.txt
EndProjectSection
EndProject
Global
diff --git a/MouseTrap/choco/MouseTrap.nuspec b/MouseTrap/choco/MouseTrap.nuspec
new file mode 100644
index 0000000..85bcffb
--- /dev/null
+++ b/MouseTrap/choco/MouseTrap.nuspec
@@ -0,0 +1,43 @@
+
+
+
+ MouseTrap
+ 0.0.0
+ MouseTrap DPI aware mouse move across screens
+ multiscreen mouse-pointer screen-scale dpi-awareness dpi-scaling cursor-moves cursor-position
+ A small tool to map the cursor between monitors with different DPIs
+
+ # MouseTrap
+
+ MouseTrap is a small tool to map the cursor between multiple monitors with
+ different resolutions and scaling settings.
+
+ ## Min requirements
+
+ For this tool to function correctly you should have:
+
+ - At least **Windows 10 Creators update** (Build 1703)
+ - [**.NET 8 Runtime**](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) (in most cases it will notify you if the runtime is missing)
+
+ ## Usage and Configuration
+
+ Here you can find the [documentation](https://github.com/r-Larch/MouseTrap/blob/master/README.md).
+
+ René Larch
+ René Larch
+ Copyright 2023 René Larch
+ https://github.com/r-Larch/MouseTrap/blob/master/LICENSE.txt
+ https://github.com/r-Larch/MouseTrap
+ https://github.com/r-Larch/MouseTrap
+ https://github.com/r-Larch/MouseTrap/issues
+ https://github.com/r-Larch/MouseTrap/blob/master/README.md
+ https://raw.githubusercontent.com/r-Larch/MouseTrap/master/MouseTrap/AppIcon.png
+ false
+ ...
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MouseTrap/choco/Push.ps1 b/MouseTrap/choco/Push.ps1
new file mode 100644
index 0000000..801dc3c
--- /dev/null
+++ b/MouseTrap/choco/Push.ps1
@@ -0,0 +1,126 @@
+
+param (
+ [string] $nuspec,
+ [string] $zip,
+ [string] $version,
+ [switch] $debug = $false
+)
+
+
+function Main() {
+ $dir = Split-Path -parent $nuspec;
+
+ $choco = @{
+ version = $version
+ nuspec = $nuspec
+ dir = $dir
+ installScript = [System.IO.Path]::Combine($dir, "chocolateyinstall.ps1")
+ uninstallScript = [System.IO.Path]::Combine($dir, "chocolateyuninstall.ps1")
+ }
+
+ $hash = (Get-FileHash -Algorithm SHA256 -Path $zip).Hash.ToUpper()
+ ChocoUpdateScript $choco $version $hash
+
+ Push-Location $dir
+ $previousTag = [Git]::GetVersionTags() | where { $_ -ne "v$version" } | sort -Descending | select -first 2 | select -last 1;
+ $history = [Git]::GetHistorySince($previousTag);
+ Pop-Location
+
+ ChocoUpdateNuspec $choco $history "https://api.github.com/repos/r-Larch/MouseTrap"
+
+ ChocoPublish $choco $debug
+
+}
+
+
+function ChocoUpdateScript([object] $choco, [string] $version, [string] $hash) {
+ $script = Get-Content $choco.installScript -Encoding UTF8 -Raw
+ $script = $script.replace('', $version)
+ $script = $script.replace('', $hash)
+ $script | Set-Content $choco.installScript -Force -Encoding UTF8
+}
+
+
+function ChocoUpdateNuspec([object] $choco, [string] $history, [string] $githubRepoApi) {
+ $repo = $(Invoke-Webrequest $githubRepoApi).Content | ConvertFrom-Json;
+ $topics = $(Invoke-Webrequest $githubRepoApi/topics -Headers @{'Accept'='application/vnd.github.mercy-preview+json'}).Content | ConvertFrom-Json
+ $xml = [xml] $(gc -Path $choco.nuspec -Encoding UTF8);
+ $xml.package.metadata.version = [Regex]::Replace($version, '^v', '');
+ $xml.package.metadata.summary = $repo.description;
+ $xml.package.metadata.tags = [string]::Join(" ", $topics.names);
+ $xml.package.metadata.copyright = "Copyright $([DateTime]::Now.Year) René Larch";
+ $xml.package.metadata.releaseNotes = [string]::Join("`r`n", $history);
+ $xml.Save($choco.nuspec);
+}
+
+
+function ChocoPublish([object] $choco, [bool] $debug = $false) {
+
+ $chocoCommand = "choco";
+ if (!$(Get-Command $chocoCommand -errorAction SilentlyContinue)) {
+ Write-Host "Install chocolatey";
+ iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
+ $env:Path += ";%ALLUSERSPROFILE%\chocolatey\bin";
+ }
+
+ # create the nuspec package
+ & $chocoCommand pack $choco.nuspec --out $choco.dir
+
+ $ver = [Regex]::Replace($choco.version, "^v(.*)", '$1');
+ $nupkgName = $choco.nuspec.replace('.nuspec', ".$($ver).nupkg");
+
+ if (!$debug) {
+ # if token is given, we will publish the package to Chocolatey here
+ if ($env:CHOCO_TOKEN) {
+ & $chocoCommand apiKey -k $env:CHOCO_TOKEN -source https://push.chocolatey.org/
+ & $chocoCommand push $nupkgName -source https://push.chocolatey.org/
+ } else {
+ Write-Warning "Chocolatey token was not set. Publication skipped."
+ }
+ } else {
+ # For development/debugging purposes
+ $script = Get-Content $choco.installScript -Encoding UTF8 -Raw
+ Write-Host "=============== Choco Install Script ==============="
+ Write-Host $script
+ Write-Host "===================================================="
+
+ $script = Get-Content $choco.uninstallScript -Encoding UTF8 -Raw
+ Write-Host "============== Choco Uninstall Script =============="
+ Write-Host $script
+ Write-Host "===================================================="
+
+ $nuspec = Get-Content $choco.nuspec -Encoding UTF8 -Raw
+ Write-Host "================== Nuspec ==========================="
+ Write-Host $nuspec
+ Write-Host "===================================================="
+
+ Write-Host "$chocoCommand pack " $choco.nuspec
+ Write-Host "$chocoCommand apiKey -k $env:CHOCO_TOKEN -source https://push.chocolatey.org/"
+ Write-Host "$chocoCommand push $nupkgName"
+ }
+}
+
+
+class Git {
+ static [string[]] GetTags() {
+ return $(git tag --list).Split("`n");
+ }
+ static [string[]] GetVersionTags() {
+ return [Git]::GetTags() | Select-String -pattern "v[\d+\.]+(-(alpha|beta))?";
+ }
+ static [string[]] GetHistorySince([string] $tagOrHash) {
+ if ([string]::IsNullOrEmpty($tagOrHash)){
+ return $(git log --oneline);
+ }
+ return $(git log "$tagOrHash..HEAD" --oneline);
+ }
+}
+
+
+#########################
+# run main #
+#########################
+
+Main;
+
+#########################
\ No newline at end of file
diff --git a/MouseTrap/choco/chocolateyinstall.ps1 b/MouseTrap/choco/chocolateyinstall.ps1
new file mode 100644
index 0000000..3b53ea4
--- /dev/null
+++ b/MouseTrap/choco/chocolateyinstall.ps1
@@ -0,0 +1,32 @@
+$ErrorActionPreference = 'Stop';
+
+$version = ''
+$hash = ''
+$versionNumber = [Regex]::Replace($version, 'v(\d+\.\d+\.\d+).*', '$1')
+
+$packageName = 'mousetrap'
+$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
+$url = "https://github.com/r-Larch/MouseTrap/releases/download/$version/MouseTrap-$versionNumber.zip"
+
+
+$packageArgs = @{
+ packageName = $packageName
+ unzipLocation = $toolsDir
+ url = $url
+ checksum = $hash
+ checksumType = 'SHA256'
+}
+
+Install-ChocolateyZipPackage @packageArgs
+
+
+$mousetrap = "$toolsDir\$packageName";
+
+# install
+& $mousetrap "-i";
+if (-not $?) {
+ throw "error while install";
+}
+
+# start the app minimized as tray icon in taskbar.
+& $mousetrap
diff --git a/MouseTrap/choco/chocolateyuninstall.ps1 b/MouseTrap/choco/chocolateyuninstall.ps1
new file mode 100644
index 0000000..7c9e70d
--- /dev/null
+++ b/MouseTrap/choco/chocolateyuninstall.ps1
@@ -0,0 +1,13 @@
+
+$ErrorActionPreference = 'Stop';
+
+$packageName= 'mousetrap.exe'
+$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
+
+$mousetrap = "$toolsDir\$packageName";
+
+# uninstall
+& $mousetrap "-u";
+if (-not $?) {
+ throw "error while uninstall";
+}
diff --git a/README.md b/README.md
index a4fcdc2..302887a 100644
--- a/README.md
+++ b/README.md
@@ -18,9 +18,20 @@ For this tool to function correctly you should have:
You can find the latest release here:
> [Download](https://github.com/r-Larch/MouseTrap/releases)
+You can install MouseTrap with **chocolatey**:
+```Powershell
+# install the package
+choco install mousetrap
+
+# running it
+mousetrap
+```
## Changelog
+### Version 1.0.20
+ - Add `chocolatey` support
+
### Version 1.0.19
- **Migrate to .NET 8**
diff --git a/VERIFICATION.txt b/VERIFICATION.txt
index 9dc5b2d..9138edf 100644
--- a/VERIFICATION.txt
+++ b/VERIFICATION.txt
@@ -2,9 +2,22 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.
-
-This package contains MouseTrap.exe; This is an open source Windows Application written by me (René Larch).
+
+This package contains the tool MouseTrap.
+This is an open source Windows Application written by me (René Larch).
You can find the source code on github:
* https://github.com/r-Larch/MouseTrap/
+
+Files:
+
+|-------------------------------|--------------------------------------------------------|
+| Files | Description |
+|-------------------------------|--------------------------------------------------------|
+| MouseTrap.exe | Executable .NET wrapper to start the .NET Core Runtime |
+| MouseTrap.dll | The actual application to run in the .NET Core Runtime |
+| MouseTrap.pdb | Debugging symbols to have better error reports |
+| MouseTrap.deps.json | Dependencies file required for the .NET Core Runtime |
+| MouseTrap.runtimeconfig.json | Runtimeconfig file required for the .NET Core Runtime |
+|-------------------------------|--------------------------------------------------------|