LocalizedData not included in compilation

Hello,

As per this document from Microsoft, it specifies how to handle multiple languages for a script. Unfortunately, compiling the script as an executable doesn’t bundle the language files. I was wondering if I was doing something wrong, and if there’s a way to fix it.

Here is a sample project.

main.xaml.ps1 (-UICulture is set but not needed IF your system’s UICulture matches - this is a test)

Import-LocalizedData -BindingVariable MsgTable -UICulture "en-CA"

function Add-ControlVariables {

New-Variable -Name 'Label' -Value $window.FindName('Label') -Scope 1 -Force
}

[System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework") | Out-Null

function Import-Xaml {
    [xml]$xaml = Get-Content -Path $PSScriptRoot\main.xaml
    $manager = New-Object System.Xml.XmlNamespaceManager -ArgumentList $xaml.NameTable
    $manager.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");
    $xamlReader = New-Object System.Xml.XmlNodeReader $xaml
    [Windows.Markup.XamlReader]::Load($xamlReader)
}

$window = Import-Xaml
Add-ControlVariables

$Label.Content = $MsgTable.Test

$window.ShowDialog()

main.xaml

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="MainWindow" Height="100" Width="200">

    <Grid>

        <Label x:Name="Label" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>

    </Grid>

</Window>

en-CA\main.xaml.psd1

ConvertFrom-StringData -StringData @'
Test = This is a test.
'@

Project compile properties (rest is empty - nothing is set)
Packaging Settings

Expected result
VSDebugExe

Actual result
CompiledExe

Build output

Build started...
------ Build started: Project: Compile-LocalizedDataTest, Configuration: Debug Any CPU ------
		Checking license
		OutputPath is C:\Users\Samuel\Documents\GitLab\Compile-LocalizedDataTest\bin\Debug\
		Bundling main.xaml.ps1
		Parsing file main.xaml.ps1.
		Checking path C:\Users\Samuel\Documents\GitLab\Compile-LocalizedDataTest\main.xaml for XAML.
		Embedding XAML file C:\Users\Samuel\Documents\GitLab\Compile-LocalizedDataTest\main.xaml
		Packaging C:\Users\Samuel\AppData\Local\Temp\main.xaml.ps1
		Creating temp directory: C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2
		Packaging modules...
		Checking dotnet version.
		Checking dotnet SDK version.
		6.0.400

		.NET SDK Version: 6.0.400

		Creating package project.
		Using .NET Framework version: net6.0
		Import-LocalizedData -BindingVariable MsgTable -UICulture "en-CA"

function Add-ControlVariables {

New-Variable -Name 'Label' -Value $window.FindName('Label') -Scope 1 -Force
}

[System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework") | Out-Null

function Import-Xaml {
    [xml]$xaml = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('PFdpbmRvdw0KICB4bWxucz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93aW5meC8yMDA2L3hhbWwvcHJlc2VudGF0aW9uIg0KICB4bWxuczp4PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dpbmZ4LzIwMDYveGFtbCINCiAgVGl0bGU9Ik1haW5XaW5kb3ciIEhlaWdodD0iMTAwIiBXaWR0aD0iMjAwIj4NCg0KICAgIDxHcmlkPg0KDQogICAgICAgIDxMYWJlbCB4Ok5hbWU9IkxhYmVsIiBIb3Jpem9udGFsQWxpZ25tZW50PSJMZWZ0IiBNYXJnaW49IjEwLDEwLDAsMCIgVmVydGljYWxBbGlnbm1lbnQ9IlRvcCIvPg0KDQogICAgPC9HcmlkPg0KDQo8L1dpbmRvdz4='))
[System.Reflection.Assembly]::LoadWithPartialName('PresentationFramework') | Out-Null
    $manager = New-Object System.Xml.XmlNamespaceManager -ArgumentList $xaml.NameTable
    $manager.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");
    $xamlReader = New-Object System.Xml.XmlNodeReader $xaml
    [Windows.Markup.XamlReader]::Load($xamlReader)
}

$window = Import-Xaml
Add-ControlVariables

$Label.Content = $MsgTable.Test

$window.ShowDialog()
		  Determining projects to restore...
C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://nuget.org/api/v2'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
  Restored C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj (in 756 ms).

		  Determining projects to restore...
C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://nuget.org/api/v2'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
  Restored C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj (in 756 ms).

		Packaging C:\Users\Samuel\AppData\Local\Temp\main.xaml.ps1 -> C:\Users\Samuel\Documents\GitLab\Compile-LocalizedDataTest\bin\Debug\main.exe
		MSBuild version 17.3.0+92e077650 for .NET
  Determining projects to restore...
C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://nuget.org/api/v2'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
  Restored C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj (in 764 ms).
C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://nuget.org/api/v2'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
  main -> C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\bin\Release\net6.0-windows\win-x64\main.dll
  main -> C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\out\

		MSBuild version 17.3.0+92e077650 for .NET
  Determining projects to restore...
C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://nuget.org/api/v2'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
  Restored C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj (in 764 ms).
C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\main.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://nuget.org/api/v2'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
  main -> C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\bin\Release\net6.0-windows\win-x64\main.dll
  main -> C:\Users\Samuel\AppData\Local\Temp\82866fb9b9c642279ad09699fd5bd4e2\out\

		Obfuscating C:\Users\Samuel\Documents\GitLab\Compile-LocalizedDataTest\bin\Debug\main.exe
		Output: C:\Users\Samuel\Documents\GitLab\Compile-LocalizedDataTest\bin\Debug\main.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Thank you for your assistance,
Sam

We currently don’t bundle localization files. I’ll open an issue for this to get it implemented.