Open rolfbjarne opened 10 months ago
This seems to fix it:
<Target Name="FixEmbeddedResources" AfterTargets="TranslateSourceFromXlf">
<ItemGroup>
<EmbeddedResource Update="@(EmbeddedResource)" Condition="'%(EmbeddedResource.XlfSource)' != ''">
<StronglyTypedClassName />
<StronglyTypedLanguage />
<StronglyTypedNamespace />
<StronglyTypedFileName />
</EmbeddedResource>
</ItemGroup>
</Target>
@rolfbjarne please feel free to submit a PR to the repo with this fix. Thanks! :)
For me the following works in a Dotnet MAUI Project (with both dotnet build
and dotnet publish
):
<Target Name="GenerateResXClass" AfterTargets="GatherXlf">
<ItemGroup>
<EmbeddedResource Update="Resources\Localization\AppResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources/Localization/AppResources.Designer.cs</LastGenOutput>
<StronglyTypedFileName>Resources/Localization/AppResources.Designer.cs</StronglyTypedFileName>
<StronglyTypedLanguage>CSharp</StronglyTypedLanguage>
<StronglyTypedNamespace>XXX.Maui.Resources.Localization</StronglyTypedNamespace>
<StronglyTypedClassName>AppResources</StronglyTypedClassName>
</EmbeddedResource>
</ItemGroup>
</Target>
After some research I think the problems is that all properties of the EmbeddedResource (e.g. StronglyTypedClassName
) are copied to the new TaskItem using the Copy-Constructor: https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.XliffTasks/Tasks/GatherXlf.cs#L39
Enabling generated strongly typed code for resources breaks XliffTasks with:
Test project: xlifftest-e9b5f83.zip To repro: download & unzip &
dotnet build
For reference, this is the
EmbeddedResource
:Binlog: msbuild.binlog.zip