Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Referencing resources from different folder location doesn't work #668

Closed
kanchanm opened this issue Sep 27, 2014 · 4 comments
Closed

Referencing resources from different folder location doesn't work #668

kanchanm opened this issue Sep 27, 2014 · 4 comments
Assignees
Milestone

Comments

@kanchanm
Copy link

I am working on porting a library and am hitting some issues while trying to restructure it. Since I am reusing the code that targets older MVC version and essentially doing #if-#defs for K I am referencing code/resource files from a folder that is different from where the kproj/project.json lives. Referencing code works fine for me but I am hitting issues with resources and the only way I could get it to work is placing them under the same folder as the K project files.

Here are the things I have tried so far:

  1. DOESN’T WORK: Specify the code and resource files as below. This gives build errors complaining about missing some of the resources specified in the cs file under \Resources.
    "code": "../XYZ/*/.cs",
    “resources”: "../XYZ/Resources/.",
  2. DOESN’T WORK: Specify the code and resource files as below. This builds but throws during runtime as it is unable to load the resources.
"code": "../XYZ/**/*.cs",
“resources”: "../XYZ/Resources/*.resx", 

System.Resources.MissingManifestResourceException occurred
HResult=-2146233038
Message=Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "XYZ.Resources.Messages.resources" was correctly embedded or linked into assembly "XYZ.K" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Source=mscorlib
StackTrace:
at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at FluentValidation.Resources.Messages.get_notnull_error() in C:\Users\kanchanm\Documents\Visual Studio 14\Projects\XYZ\src\FluentValidation\Resources\Messages.Designer.cs:line 192
at XYZ.Resources.LocalizedStringSource.GetString() in C:\Users\kanchanm\Documents\Visual Studio 14\Projects\fluentvalidation\src\XYZ\Resources\LocalizedStringSource.cs:line 74
InnerException:

  1. WORKS: Duplicate the contents of “../XYZ/Resources“ under the XYZ.K project and exclude the ones under the XYZ itself.
    "code": "../XYZ/*/.cs",
    "exclude": "../XYZ/Resources",
    Note, you may see some oddities here still since there is another issue in this scenario that the namespace of the resources need to be XYZ and the original one XYZ. Resources doesn’t work in the new world (works in the old world) for some reason which seems like a different issue.
@kanchanm
Copy link
Author

@davidfowl

@davidfowl
Copy link
Member

This is because we end up with different resource names. We'll need to consider changing it back.

@dougbu
Copy link
Member

dougbu commented Dec 8, 2014

Any update on this issue?

FYI my workaround was:

  1. copy *.resx files into the new ASP.NET Core 5.0 project directory because nothing in project.json extends the files ResxResourceProvider processes. (copying the files is not a viable workaround except in the very short term.)
  2. execute .\build.cmd resx to create a new *.designer.cs file since one original doesn't use the resource names ResxResourceProvider produces.
  3. remove all the extra *.resx files the previous step generated 😦
  4. update the "code" array in project.json to use the new *.designer.cs file

@davidfowl
Copy link
Member

We can look at fixing this for rc1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants