-
Notifications
You must be signed in to change notification settings - Fork 260
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
Unable to read cshtml from compiled project. #378
Comments
What version are you using and what's your project structure look like? Is For example: Here's a working (for me at least) example: Structure:
Code:
This also works for me:
|
@maxbanas I wonder if we should add a debug mode that dumps all known keys as part of the error message. So the Exception should be TemplateNotFoundException and has a List KnownTemplateKeys, which is passed by the Razor Project System. |
One thing I do in similar projects (like FluentMigrator) is I create an EmbeddedResourceUtility that computes the longest subsequence match and/or Levenshtein distance for all known embedded resource paths vs. the one being searched for. |
@jzabroski I think something like that would be super helpful. Even though it's pretty straightforward, I've messed up the template keys multiple times and have had to come back and check the readme (especially when the templates are outside of my main project). So I could definitely see how this could be a roadblock for some people just starting out. |
@jzabroski I've been thinking about this a bit. If we're on the same page, I can work on a pull request. To build the exception, we would need I see that
In |
@maxbanas Yes, I think this also links back to the other discussion we had yesterday about TextSourceRazorProjectItem. https://github.com/toddams/RazorLight/blob/badbd178564ba59934368161c7c140fa5906eee1/src/RazorLight/Razor/TextSourceRazorProjectItem.cs My point being, children don't know who their parents are. Project Items don't know who their Project is. As a result, information about the parent is unavailable from a child only context. |
It looks like you're preparing an rc. I haven't had time to fully implement the "debug mode" and exception message changes, but if the exception type thrown in |
@maxbanas The rc suffix is mainly due to the fact we screwed up the semver 2.0.0 naming convention. It was the only way to get the nuget gallery to display the latest package at the top. Most people didnt download the beta10 release because of this mistake. I changing it to use correct dotted identifiers convention of semver 2.0.0 and had to pick an alphabetical identifier higher than the word "beta" in order to fix the sorting on nuget.org |
@maxbanas I've tried your solution, but the problem persists. I still got "TemplateNotFoundException" when I try to read a cshtml file from a Razor Class Library. This is my sample project: https://github.com/knuxbbs/RazorLightSample |
@knuxbbs fixing the following issues in your sample project worked for me:
As a side note, I ran into the same issue as you when trying to run your example, and didn't really look into that issue. So instead I just built the razor engine in your controller's
|
@jzabroski I've started working on the feature we discussed and created a new issue, #398, so we can stay on topic (and close this issue if you want). |
@georgeemr Can you try RazorLight-2.0.0-rc.3? I plan one last fix before official release. |
Sure, sorry for the late response. |
I think the error you ran into was what I ran into in creating a cross-platform build. Try For example, this can happen if your assembly was built on Windows but used on MAC OS X. |
I'm unable to read the cshtml from a compiled dll that net core 3.1 creates when deploy the app.
To Reproduce
Expected behavior
HTML of view
but get message:
Project can not find template with key
....What do I missing?
The text was updated successfully, but these errors were encountered: