-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET 7/.NET 8 MAU projects don't build if NuGet package referencing ICU4N.Resources is added: alleged same target path for e.g. zh-HK\ICU4N.resources.dll #65
Comments
I have made some progress to identify when things started to break in terms of referencing SaxonCS, with 12.1 which references ICUN 60.1.0alpha.354 a .NET 8 MAUI project builds and works, starting with SaxonCS 12.2 the build fails with errors as given above. |
Thanks for the report. The Saxon team has reported an issue with getting build warnings when using ICU4N.Resources, but this seems to be a different issue. BackgroundSo, what is known about the issue so far is that NuGet seems perfectly happy with having resource files with names that .NET doesn't recognize. However, MSBuild does not automatically copy resource files for names it does not recognize (many of these resource files are 3-character resource names). If you notice in the I am hesitant to report this to Microsoft as a bug, because it isn't a very common use case to create resource files with names that .NET doesn't recognize. Most projects would use the built-in I think the solution will ultimately be to use officially supported .NET culture names and pack the non-matching names into the most relevant related culture (there is a 3-letter to 2-letter conversion function in ICU that will do most of the heavy lifting). I know there are some hard coded rules in .NET around Chinese cultures, and that may be contributing to the issue. I haven't had a chance to work out how to close the gap between .NET culture names and ICU culture names. I know Microsoft maintains a custom build of ICU4C for use in .NET Core here: https://www.nuget.org/packages/Microsoft.ICU.ICU4C.Runtime, but I haven't dug into the source (of dotnet/runtime, MAUI or ICU4C) to see how this culture name mapping happens. Potential WorkaroundA couple of things you can try get the build to function: Use an explicit reference to ICU4N.ResourcesFirst, remove the transitive dependency on ICU4N.Resources. There are a couple of options here. Option 1This is supposed to work with MSBuild to remove the transitive dependency. If not, that is a bug that will need to be reported to Microsoft. <ItemGroup>
<PackageReference Include="ICU4N" Version="60.1.0-alpha.402" ExcludeAssets="buildTransitive" />
</ItemGroup> Option 2In your build file, use Either of these options should remove the PackageReference to ICU4N.Resources from your project. Then, you can explicitly add a reference to it. <PackageReference Include="ICU4N.Resources" Version="60.1.0-alpha.402" PrivateAssets="all" /> Have your build copy all of the
|
Yeah, that works because it was before we split the resource files out into satellite assemblies. It unblocks you from having a build failure, but doesn't help get us closer to a working solution with satellite assemblies. |
Following your advice with option 1 and SaxonCS 12.4 I still get errors about several files with the same target path:
I will try your suggestions on "Have your build copy all of the ICU4N.Resources.dll files into your project" later this evening or tomorrow and report back whether it helped. |
Well, there are no duplicate culture names in the NuGet cache, so this definitely sounds like a bug in MSBuild for MAUI. But looking at the list, there are some grandfathered culture names in there that may be interfering with the file copy logic.
If you package the resources into your own NuGet package and exclude the Chinese cultures that have been superseded, I suspect it will work. MAUI is apparently not expecting both current and legacy file names, but one or the other. The effect will be that the legacy culture names won't work in ICU4N, but there probably aren't many users who are using them, anyway. If that works, then the fix we have already planned - to eliminate the grandfathered and unknown culture names from the set of resource files and include the resources in the most appropriate resource file - will fix this issue as well. |
I have found that .NET 7 or .NET 8 MAUI projects stop building with VS 2022 with errors like shown below as soon as I add SaxonCS as a NuGet package to the project; SaxonCS (12.4) references ICU4N.Resources 60.1.0-alpha.402.
My translation of the (German) error message VS is giving below (repeatedly) is "Resource data contains several files with the same target path"
I am not sure what is causing this, some other .NET 8/VS 2022 project types like WPF build/work fine with SaxonCS referencing ICU4N.Resources 60.1.0-alpha.402.
Any idea whether that is something you can fix with ICU4N.Resources or whether I need to try to file that as a bug on .NET 7/8 MAUI/VS 2022?
The text was updated successfully, but these errors were encountered: