feat: better taskfile service tasks for windows dev

This commit is contained in:
2025-06-22 18:37:18 -05:00
parent 0a51119e4c
commit cb29ad2c22
3 changed files with 29 additions and 6 deletions

2
.gitignore vendored
View File

@@ -2,5 +2,5 @@
*.log *.log
.env .env
.vscode .vscode
dist bin
.wix .wix

View File

@@ -1,5 +1,9 @@
version: '3' version: '3'
vars:
APP_NAME: 'HATray'
VERSION: '0.0.1'
includes: includes:
build: build:
taskfile: tasks/Taskfile_{{OS}}.yml taskfile: tasks/Taskfile_{{OS}}.yml

View File

@@ -1,18 +1,37 @@
version: '3' version: '3'
vars: vars:
APP_NAME: 'HATray' BINARY_NAME: '{{.APP_NAME}}.exe'
EXE_NAME: '{{.APP_NAME}}.exe'
VERSION: '0.0.1'
tasks: tasks:
build: build:
cmds: cmds:
- go build -o ./dist/{{.EXE_NAME}} ./cmd/main.go - go build -o ./bin/{{.BINARY_NAME}} ./cmd/main.go
service:
desc: "Install the service"
deps: [build]
cmds:
# Create the service, if not already present
- cmd: pwsh -c 'sc create HATray binPath= "$env:USERPROFILE\AppData\Local\HATray\{{.BINARY_NAME}}" start=auto'
ignore_error: true
# Stop the service, if running
- cmd: pwsh -c 'sc stop HATray'
ignore_error: true
# Replace the binary
- cmd: pwsh -c 'Copy-Item -Force -Path .\bin\{{.BINARY_NAME}} -Destination $env:USERPROFILE\AppData\Local\HATray\{{.BINARY_NAME}}'
# Start the service
- cmd: pwsh -c 'sc start HATray'
tail:
desc: "Tail the log file"
cmds:
- cmd: pwsh -c 'Get-Content -Path $env:USERPROFILE\AppData\Local\HATray\current.log -Tail 100 -Wait'
package: package:
desc: "Package the application as a MSI"
deps: [build] deps: [build]
cmds: cmds:
- wix extension add WixToolset.Util.wixext - wix extension add WixToolset.Util.wixext
- wix extension add WixToolset.UI.wixext - wix extension add WixToolset.UI.wixext
- wix build -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -o ./dist/{{.APP_NAME}}-{{.VERSION}}.msi build/msi/HATray.wxs -arch x64 -d VERSION={{.VERSION}} -d SOURCE=./dist/{{.EXE_NAME}} - wix build -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -o ./bin/{{.APP_NAME}}-{{.VERSION}}.msi build/msi/HATray.wxs -arch x64 -d VERSION={{.VERSION}} -d SOURCE=./bin/{{.BINARY_NAME}}