From a55c1fedcbdc1f873cc7f358a0f21e3db0038548 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Tue, 17 Jun 2025 21:07:29 +1000 Subject: [PATCH] fix: Resolve MSIX template field reference errors in wails3 init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the template execution errors that occurred when running 'wails3 init' with MSIX-related templates. The issue was that the templates were trying to access fields under an 'Info' sub-struct that doesn't exist in the BuildConfig context. Changes: - Fixed app_manifest.xml.tmpl to use direct field references (e.g., .ProductIdentifier instead of .Info.ProductIdentifier) - Fixed template.xml.tmpl with the same field reference corrections - Added missing MSIX-related fields to BuildAssetsOptions struct (Publisher, ProcessorArchitecture, ExecutablePath, ExecutableName, OutputPath, CertificatePath) - Set appropriate default values for the new fields in GenerateBuildAssets function Resolves the error: "can't evaluate field Info in type commands.BuildConfig" 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- v3/internal/commands/build-assets.go | 34 +++++++++++++++++-- .../windows/msix/app_manifest.xml.tmpl | 24 ++++++------- .../windows/msix/template.xml.tmpl | 28 +++++++-------- 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/v3/internal/commands/build-assets.go b/v3/internal/commands/build-assets.go index 1fa9138f5..b9a6283c9 100644 --- a/v3/internal/commands/build-assets.go +++ b/v3/internal/commands/build-assets.go @@ -31,9 +31,15 @@ type BuildAssetsOptions struct { ProductCompany string `description:"The company of the product" default:"My Company"` ProductCopyright string `description:"The copyright notice" default:"\u00a9 now, My Company"` ProductComments string `description:"Comments to add to the generated files" default:"This is a comment"` - ProductIdentifier string `description:"The product identifier, e.g com.mycompany.myproduct"` - Silent bool `description:"Suppress output to console"` - Typescript bool `description:"Use typescript" default:"false"` + ProductIdentifier string `description:"The product identifier, e.g com.mycompany.myproduct"` + Publisher string `description:"Publisher name for MSIX package (e.g., CN=CompanyName)"` + ProcessorArchitecture string `description:"Processor architecture for MSIX package" default:"x64"` + ExecutablePath string `description:"Path to executable for MSIX package"` + ExecutableName string `description:"Name of executable for MSIX package"` + OutputPath string `description:"Output path for MSIX package"` + CertificatePath string `description:"Certificate path for MSIX package"` + Silent bool `description:"Suppress output to console"` + Typescript bool `description:"Use typescript" default:"false"` } type BuildConfig struct { @@ -90,6 +96,28 @@ func GenerateBuildAssets(options *BuildAssetsOptions) error { } } + if options.Publisher == "" { + options.Publisher = fmt.Sprintf("CN=%s", options.ProductCompany) + } + + if options.ProcessorArchitecture == "" { + options.ProcessorArchitecture = "x64" + } + + if options.ExecutableName == "" { + options.ExecutableName = options.BinaryName + } + + if options.ExecutablePath == "" { + options.ExecutablePath = options.BinaryName + } + + if options.OutputPath == "" { + options.OutputPath = fmt.Sprintf("%s.msix", normaliseName(options.Name)) + } + + // CertificatePath is optional, no default needed + config.BuildAssetsOptions = *options tfs, err := fs.Sub(buildAssets, "build_assets") diff --git a/v3/internal/commands/build_assets/windows/msix/app_manifest.xml.tmpl b/v3/internal/commands/build_assets/windows/msix/app_manifest.xml.tmpl index 7697b318f..d68664afb 100644 --- a/v3/internal/commands/build_assets/windows/msix/app_manifest.xml.tmpl +++ b/v3/internal/commands/build_assets/windows/msix/app_manifest.xml.tmpl @@ -6,15 +6,15 @@ xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"> - {{.Info.ProductName}} - {{.Info.CompanyName}} - {{.Info.Description}} + {{.ProductName}} + {{.ProductCompany}} + {{.ProductDescription}} Assets\StoreLogo.png @@ -27,10 +27,10 @@ - + @@ -39,13 +39,13 @@ - + {{if .FileAssociations}} - - {{.Info.ProductName}} + + {{.ProductName}} Assets\FileIcon.png - {{.Info.ProductName}} File + {{.ProductName}} File {{range .FileAssociations}} .{{.Ext}} diff --git a/v3/internal/commands/build_assets/windows/msix/template.xml.tmpl b/v3/internal/commands/build_assets/windows/msix/template.xml.tmpl index 69b57bdf0..92f217499 100644 --- a/v3/internal/commands/build_assets/windows/msix/template.xml.tmpl +++ b/v3/internal/commands/build_assets/windows/msix/template.xml.tmpl @@ -10,15 +10,15 @@ + InstallLocation="C:\Program Files\{{.ProductCompany}}\{{.ProductName}}"> + PackageName="{{.ProductName}}" + PackageDisplayName="{{.ProductName}}" + PublisherName="CN={{.ProductCompany}}" + PublisherDisplayName="{{.ProductCompany}}" + Version="{{.ProductVersion}}.0" + PackageDescription="{{.ProductDescription}}"> {{if .FileAssociations}} @@ -27,15 +27,15 @@ {{if .FileAssociations}} - + {{range .FileAssociations}} .{{.Ext}} @@ -55,9 +55,9 @@ false - {{.Info.ProductName}} - {{.Info.CompanyName}} - {{.Info.Description}} + {{.ProductName}} + {{.ProductCompany}} + {{.ProductDescription}} Assets\AppIcon.png