3 Commits

Author SHA1 Message Date
308966da36 Upgrade to .NET 8 LTS and enhance installer functionality
- Upgraded from .NET 7 to .NET 8 LTS for better Windows 11 compatibility
- Added App.config with runtime switches to prevent DirectWrite crashes
- Moved software rendering initialization to App() constructor
- Disabled ReadyToRun compilation to avoid font rendering issues
- Enhanced installer with auto-launch after installation
- Removed license agreement screen from installer
- Added WiX heat.exe file harvesting for proper multi-file deployment
- Cleaned up old MSI files from repository

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 09:31:20 -08:00
cff9bc4876 Add single-instance enforcement and DirectWrite crash workaround
- Implement mutex-based single instance check
- Show message if app is already running
- Force software rendering to prevent DirectWrite font initialization crash
- Update version to 1.0.2

Fixes:
- Multiple instances could run simultaneously
- DirectWrite crash on certain Windows configurations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 08:25:36 -08:00
f3323420a8 Fix WPF single-file deployment crash and improve installer
- Disable single-file publishing (causes DirectWrite/font crash in WPF)
- Switch to multi-file self-contained deployment
- Update WiX installer to harvest all publish files using heat.exe
- Fix tray icon loading issue by including all necessary DLLs
- Reduce MSI size while maintaining all functionality

Fixes:
- System.TypeInitializationException crash on startup
- Missing tray icon (now shows DT logo correctly)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 08:17:41 -08:00
8 changed files with 182 additions and 26 deletions

View File

@@ -3,7 +3,7 @@
<Product Id="*"
Name="NFC Actions"
Language="1033"
Version="1.0.0.0"
Version="1.0.2.0"
Manufacturer="Dangerous Things"
UpgradeCode="A1B2C3D4-E5F6-4A5B-8C9D-0E1F2A3B4C5D">
@@ -20,6 +20,15 @@
<Property Id="DISABLEADVTSHORTCUTS" Value="1" />
<Property Id="MSIINSTALLPERUSER" Value="1" />
<!-- Launch application after installation -->
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch NFC Actions" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<Property Id="WixShellExecTarget" Value="[#NfcActionsExe]" />
<CustomAction Id="LaunchApplication"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
<Icon Id="ProductIcon" SourceFile="..\NfcActions\Resources\icon.ico" />
<Property Id="ARPPRODUCTICON" Value="ProductIcon" />
<Property Id="ARPHELPLINK" Value="https://dangerousthings.com" />
@@ -27,10 +36,26 @@
<Feature Id="ProductFeature" Title="NFC Actions" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="HarvestedFiles" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="AutoStartRegistry" />
</Feature>
<UI>
<!-- Use WixUI_Minimal without license page -->
<UIRef Id="WixUI_InstallDir" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<!-- Skip the license page -->
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">1</Publish>
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="LocalAppDataFolder">
<Directory Id="CompanyFolder" Name="DangerousThings">
@@ -72,30 +97,21 @@
</Component>
</DirectoryRef>
<!-- Registry and cleanup component -->
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="MainExecutable" Guid="D4E5F6A7-B8C9-4D8E-1F2A-3B4C5D6E7F8A">
<File Id="NfcActionsExe"
Source="..\NfcActions\bin\Release\net7.0-windows\win-x64\publish\NfcActions.exe" />
<Component Id="RegistryEntries" Guid="D4E5F6A7-B8C9-4D8E-1F2A-3B4C5D6E7F8A">
<RegistryValue Root="HKCU"
Key="Software\DangerousThings\NfcActions"
Name="MainExe"
Name="Installed"
Type="integer"
Value="1"
KeyPath="yes"/>
<RemoveFolder Id="RemoveINSTALLFOLDER" Directory="INSTALLFOLDER" On="uninstall" />
<RemoveFolder Id="RemoveCompanyFolder" Directory="CompanyFolder" On="uninstall" />
</Component>
<Component Id="ResourcesFolder" Guid="E5F6A7B8-C9D0-4E9F-2A3B-4C5D6E7F8A9B">
<File Id="IconIco" Source="..\NfcActions\bin\Release\net7.0-windows\win-x64\publish\Resources\icon.ico" />
<RegistryValue Root="HKCU"
Key="Software\DangerousThings\NfcActions"
Name="Resources"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</ComponentGroup>
<!-- Harvested files will be included from HarvestedFiles.wxs -->
</Product>
</Wix>

Binary file not shown.

BIN
NfcActions-Setup-v1.0.2.msi Normal file

Binary file not shown.

7
NfcActions/App.config Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<!-- Force software rendering to prevent DirectWrite crashes -->
<AppContextSwitchOverrides value="Switch.System.Windows.DoNotUsePresentationDpiCapabilityTier2OrGreater=true;Switch.System.Windows.DoNotScaleForDpiChanges=false" />
</runtime>
</configuration>

View File

@@ -1,7 +1,9 @@
using System;
using System.Drawing;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media;
using NfcActions.Services;
using NfcActions.ViewModels;
using Application = System.Windows.Application;
@@ -13,6 +15,7 @@ namespace NfcActions;
/// </summary>
public partial class App : Application
{
private static Mutex? _instanceMutex;
private NotifyIcon? _notifyIcon;
private Icon? _customIcon;
private MainWindow? _mainWindow;
@@ -22,8 +25,40 @@ public partial class App : Application
private LogService? _logService;
private MainViewModel? _viewModel;
public App()
{
// CRITICAL: Set software rendering mode BEFORE any WPF initialization
// This must be done in the constructor before InitializeComponent()
try
{
// Set environment variable as additional safeguard
Environment.SetEnvironmentVariable("DOTNET_SYSTEM_WINDOWS_DONOTUSEPRESENTATIONDPICAPABILITYTIER2ORGREATER", "1");
// Force software rendering
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
}
catch
{
// If this fails, try to continue anyway
}
}
private void Application_Startup(object sender, StartupEventArgs e)
{
// Ensure only one instance runs at a time
bool createdNew;
_instanceMutex = new Mutex(true, "NfcActions_SingleInstance_Mutex", out createdNew);
if (!createdNew)
{
System.Windows.MessageBox.Show("NFC Actions is already running. Check the system tray.",
"NFC Actions",
MessageBoxButton.OK,
MessageBoxImage.Information);
Shutdown();
return;
}
// Initialize services
_logService = new LogService();
_cardReaderService = new CardReaderService(_logService);
@@ -107,5 +142,7 @@ public partial class App : Application
_notifyIcon?.Dispose();
_customIcon?.Dispose();
_cardReaderService?.Dispose();
_instanceMutex?.ReleaseMutex();
_instanceMutex?.Dispose();
}
}

View File

@@ -2,14 +2,14 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.0.2</Version>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<FileVersion>1.0.2.0</FileVersion>
<Company>Dangerous Things</Company>
<Product>NFC Actions</Product>
<Description>NFC card reader monitoring and action automation</Description>
@@ -17,11 +17,12 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<PublishSingleFile>true</PublishSingleFile>
<PublishSingleFile>false</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishTrimmed>false</PublishTrimmed>
<EnableCompressionInSingleFile>false</EnableCompressionInSingleFile>
</PropertyGroup>
<ItemGroup>

74
RELEASE_NOTES.md Normal file
View File

@@ -0,0 +1,74 @@
# NFC Actions v1.0.0 - Initial Release
## Features
### Core Functionality
- **System Tray Application** - Runs quietly in the background, accessible from the system tray
- **Real-time NFC Monitoring** - Automatically detects and monitors all PC/SC compatible NFC readers
- **Dynamic Reader Management** - Handles USB reader plug/unplug events automatically
- **NDEF Payload Extraction** - Supports Type 2 and Type 4 NFC tags with automatic block size detection
### Actions
- **Copy to Clipboard** - Copies NDEF payload data to clipboard for easy pasting
- **Launch URLs** - Opens URI records in your default browser (URL records only)
- **Keyboard Input** - Types NDEF content as keyboard input into active application
### User Interface
- **Configuration Window** - Clean, simple interface for managing readers and actions
- **Real-time Activity Log** - Color-coded logging (Debug, Info, Warning, Error) for visibility
- **Dangerous Things Branding** - Custom icons and clickable logo
### Technical Features
- **Settings Persistence** - Remembers your preferences between sessions
- **Auto-start on Login** - Automatically starts when you log in to Windows
- **File Logging** - Debug logs saved to application directory for troubleshooting
- **Single-file Deployment** - No .NET runtime installation required
## Installation
1. Download **NfcActions-Setup.msi** from the release assets
2. Run the installer
3. The application will:
- Install to `%LOCALAPPDATA%\DangerousThings\NFC Actions`
- Create a Start Menu shortcut
- Configure automatic startup on login
- Start running immediately in the system tray
## System Requirements
- **Operating System**: Windows 10 or Windows 11
- **Hardware**: PC/SC compatible NFC reader (USB or built-in)
- **Runtime**: None required (self-contained)
## Tested Readers
- Identiv uTrust 3700 F
- HID OMNIKEY 5022 CL
## Usage
1. **First Launch**: Click the tray icon to open the configuration window
2. **Enable/Disable Readers**: Check or uncheck readers in the "Active Readers" list
3. **Configure Actions**: Select which actions to perform when a card is detected
4. **Tap NFC Card**: Simply tap your NFC card to any enabled reader
5. **Monitor Activity**: Watch the activity log for real-time feedback
## Known Limitations
- Only the first NDEF record is processed (multiple records not supported yet)
- Only NDEF payload is used (not the full NDEF message structure)
- URI detection is limited to standard URI record types and identifier codes
## Support
- **Website**: https://dangerousthings.com
- **Repository**: https://git.dngr.us/DangerousThings/nfc-actions
- **Issues**: Report bugs via the repository issue tracker
## License
Copyright © 2025 Dangerous Things
---
**Built with Claude Code** - https://claude.com/claude-code

View File

@@ -9,7 +9,7 @@ param(
$ErrorActionPreference = "Stop"
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectPath = Join-Path $scriptPath "NfcActions\NfcActions.csproj"
$publishPath = Join-Path $scriptPath "NfcActions\bin\Release\net7.0-windows\win-x64\publish"
$publishPath = Join-Path $scriptPath "NfcActions\bin\Release\net8.0-windows\win-x64\publish"
$installerPath = Join-Path $scriptPath "Installer"
Write-Host "=== NFC Actions Release Build ===" -ForegroundColor Cyan
@@ -70,8 +70,28 @@ if ($BuildInstaller) {
Push-Location $installerPath
# Run candle (compile)
& candle.exe Product.wxs -out obj\Product.wixobj
# Create obj and bin directories if they don't exist
New-Item -ItemType Directory -Force -Path obj | Out-Null
New-Item -ItemType Directory -Force -Path bin | Out-Null
# Run heat to harvest all files from publish folder
Write-Host " Harvesting files from publish folder..." -ForegroundColor Gray
& heat.exe dir $publishPath -cg HarvestedFiles -gg -sfrag -srd -dr INSTALLFOLDER -var var.PublishDir -out obj\HarvestedFiles.wxs
if ($LASTEXITCODE -ne 0) {
Pop-Location
Write-Host "Heat (file harvesting) failed!" -ForegroundColor Red
exit 1
}
# Update the harvested file to set ID to NfcActions.exe
Write-Host " Setting file ID for NfcActions.exe..." -ForegroundColor Gray
$harvestedContent = Get-Content obj\HarvestedFiles.wxs -Raw
$harvestedContent = $harvestedContent -replace '(<File Id=")([^"]+)(" KeyPath="yes" Source="\$\(var\.PublishDir\)\\NfcActions\.exe")', '$1NfcActionsExe$3'
Set-Content obj\HarvestedFiles.wxs -Value $harvestedContent
# Run candle (compile) on both wxs files
Write-Host " Compiling installer..." -ForegroundColor Gray
& candle.exe Product.wxs obj\HarvestedFiles.wxs "-dPublishDir=$publishPath" -out obj\ -arch x64
if ($LASTEXITCODE -ne 0) {
Pop-Location
Write-Host "Candle (WiX compile) failed!" -ForegroundColor Red
@@ -79,7 +99,8 @@ if ($BuildInstaller) {
}
# Run light (link)
& light.exe obj\Product.wixobj -out bin\NfcActions-Setup.msi -ext WixUIExtension
Write-Host " Linking MSI package..." -ForegroundColor Gray
& light.exe obj\Product.wixobj obj\HarvestedFiles.wixobj -out bin\NfcActions-Setup.msi -ext WixUIExtension -ext WixUtilExtension -sval
if ($LASTEXITCODE -ne 0) {
Pop-Location
Write-Host "Light (WiX link) failed!" -ForegroundColor Red