diff --git a/client/ui-wails/README.md b/client/ui-wails/README.md index ec1e96028..82bf5e4bf 100644 --- a/client/ui-wails/README.md +++ b/client/ui-wails/README.md @@ -62,6 +62,21 @@ CGO_ENABLED=1 task windows:build Produces `bin/netbird-ui.exe`. macOS cross-compile from Linux is not supported (signing and notarization need a real Mac). +### Windows console build (logs in the terminal) + +Default `windows:build` links the binary as a Windows GUI app, which +detaches from the launching console — `logrus` output, `fmt.Println`, +and panics go nowhere visible. To debug tray/event/daemon issues: + +```bash +CGO_ENABLED=1 task windows:build:console +``` + +Produces `bin/netbird-ui-console.exe`. Run it from `cmd.exe` / +PowerShell / Windows Terminal and stdout/stderr land in that +terminal. Same flag works on a native Windows build (drop the +`CGO_ENABLED=1` if your toolchain already has it set). + ## Regenerating bindings When a Go service signature changes: diff --git a/client/ui-wails/build/windows/Taskfile.yml b/client/ui-wails/build/windows/Taskfile.yml index 5aaf2db90..9617d3e52 100644 --- a/client/ui-wails/build/windows/Taskfile.yml +++ b/client/ui-wails/build/windows/Taskfile.yml @@ -28,6 +28,50 @@ tasks: vars: CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}' + build:console: + summary: Builds a console-attached Windows binary so logs go to the terminal. + desc: | + Same as `windows:build` but links against the console PE subsystem + instead of windowsgui, so stdout/stderr (logrus, panics) print to the + terminal that launched the .exe. Useful for chasing tray, event-stream, + or daemon-RPC bugs that have no other feedback channel on Windows. + + Output is bin/netbird-ui-console.exe — kept distinct so the production + binary built by `windows:build` isn't shadowed. + + Cross-compile from Linux works the same way: + CGO_ENABLED=1 task windows:build:console + deps: + - task: common:go:mod:tidy + - task: common:build:frontend + vars: + BUILD_FLAGS: + ref: .BUILD_FLAGS + DEV: + ref: .DEV + - task: common:generate:icons + preconditions: + - sh: '[ "{{OS}}" = "windows" ] || [ "{{.CGO_ENABLED}}" != "1" ] || command -v {{.CC}}' + msg: "{{.CC}} not found. Install with: sudo apt-get install gcc-mingw-w64-x86-64 (Debian/Ubuntu) / sudo dnf install mingw64-gcc (Fedora)" + cmds: + - task: generate:syso + - go build {{.BUILD_FLAGS}} -o "{{.BIN_DIR}}/{{.APP_NAME}}-console.exe" + - cmd: powershell Remove-item *.syso + platforms: [windows] + - cmd: rm -f *.syso + platforms: [linux, darwin] + vars: + # Identical to build:native's flags except no -H windowsgui, so the + # binary attaches to the launching console. + BUILD_FLAGS: '-tags production{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s"' + CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}' + CC: '{{.CC | default "x86_64-w64-mingw32-gcc"}}' + env: + GOOS: windows + CGO_ENABLED: '{{.CGO_ENABLED}}' + GOARCH: '{{.ARCH | default ARCH}}' + CC: '{{.CC}}' + build:native: summary: Builds for Windows natively, or cross-compiles from Linux/macOS via mingw-w64. internal: true