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
Force logical name for generated resources #2899
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Huh, the filter is totally Deutsch on my system. Can you try again with the new commit? I weren't sure about this, so let's try what it does.. |
No change. I'll see if I can learn anything from inspecting the assembly... |
This comment has been minimized.
This comment has been minimized.
Now that's interesting. My mono packs the dlls no problem, the manifests are the same until the very last bit, both have the |
This comment has been minimized.
This comment has been minimized.
That's the exact same versions I have :/
Also you already pulled the second commit, right? |
Yes, they're there. And somehow that fixed it: Maybe the files weren't being overwritten properly? Maybe some old filenames were confusing it? Either way, it looks fine now.
I've been testing this without a local branch, in "detached HEAD" state. git fetch --all
git checkout DasSkelett/fix/idea-build Kind of handy when I know I won't be adding my own commits. |
Problem
I'm trying out JetBrain's .NET IDE, "Idea" (thanks free student license ;) )
I couldn't run CKAN built with it, it always threw
MissingManifestResourceException
exceptions.Cause
When Rider builds the GUI, it uses a different naming scheme for generated .resources file (.resources files are generated from .resx files before bundling them in the final assembly). To be exact, it appears that it uses
AssemblyName.ResourceFileNameBase
instead ofFullNamespace.ResourceFileNameBase
>CKAN.Resources*.resources
instead ofCKAN.Properties.Resources*.resources
.But not for all .resx/.resources files, only for those in the
CKAN-GUI/Properties/
directory, soCKAN-GUI/Properties/Resources*.resx
.However, this only affects runtime, not compile time.
When the first resource (ksp.png) should be loaded,
Resources.ResourceManager
is accessed, which tries to find the embedded resource.CKAN/GUI/Properties/Resources.Designer.cs
Lines 37 to 46 in cbcd3ac
It can't find it because of the wrong name, but doesn't care and returns a valid ResourceManager object.
mscorlib tries to find ksp.png with the returned ResourceManager, but can't find it either, because there's nothing "in" it.
An exception similar to this one will be thrown:
Solution
Thanks to https://blogs.msdn.microsoft.com/msbuild/2007/10/19/manifest-resource-names-changed-for-resources-files/
and especially https://stackoverflow.com/a/7090337 I found a way to force specific names for the generated resources.
They are now forced to
FullNamespace.ResourceFileNameBase
, as specified here: https://docs.microsoft.com/en-us/dotnet/api/system.resources.resourcemanager?view=netframework-4.8#exceptionThis won't change the name of the .resources files itself (see
_build/out/CKAN-GUI/Debug/obj/
), they are still named differently if generated by Rider. But the logical name does, and that's the one important tonew SingleAssemblyResourceManager()
.The normal build with the build script / cake still works on my system ;).
But it would be nice if someone using a different IDE (@HebaruSan with Visual Studio?) can test if it's still building fine too.