Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

ASP.NET CORE MVC Compiler Exception - View Models and HtmlHelpers in separate project #1984

Closed
joetherod opened this issue Jan 28, 2018 · 8 comments
Assignees

Comments

@joetherod
Copy link

Running latest version of VS 2017, have Docker for Windows installed on Windows 10 with host set to linux
Running application via VS in debug all works fine, when running in Release mode I get compiler exceptions of the views, cant find namespace or reference. My razors views are retrieved from database and are compiled at runtime. Why is this issue happening in Release mode and not in Debug. Tried adding references in RazorViewOptions and still not working. Looked at this post and tried what was mention with Compiler callback and adding PreserveCompilationContext to true project file.

I read this post, but the changes indicated didnt work for me.
#755

@mkArtakMSFT
Copy link
Contributor

Thank you for filing this issue. In order for us to investigate this issue, could you please provide a minimalistic repro project that illustrates the problem?

@joetherod
Copy link
Author

https://www.dropbox.com/sh/jo2idcof91hmmjv/AABTVMQmys4WT8CNcBAwyW_ba?dl=0

Local setup is Visual Studio 2017 15.4
Windows with Docker, host set to Linux

Open sln, build and Debug. Site returns html.
Now set to Release and Debug, Compilation error when parsing view.

Let me know of any issues with project.

Thanks!

@mkArtakMSFT
Copy link
Contributor

@pranavkm, can you please look into this? Thanks!

@joetherod
Copy link
Author

Any update? @pranavkm

Thank you.

@pranavkm
Copy link
Contributor

pranavkm commented Feb 3, 2018

I had a cursory look at running the solution in release. It worked, but I don't have Docker tools installed on my dev box and ended up removing the project from the solution and just running the web application. Does this also not work for you?

@joetherod
Copy link
Author

It works when running in debug mode via visual studio. I have docker installed on windows 10. When I run in release mode it creates the image and runs in docker with host set to linux. When running that way, it errors out due to compilation of razor view. Cant find namespace or reference. I saw a similar post you commented on when having view models in seperate project. Those changes didnt work for me. The publish of the project shows it has all references. Not sure if my setup is correct for the razor view options. It seems that it doesnt take into account the ViewImports file. Not sure why it works in debug and not release. I tried a few things and no luck. Can you create a docker image and try running it that way in a linux host?

@pranavkm
Copy link
Contributor

pranavkm commented Feb 3, 2018

Can you create a docker image and try running it that way in a linux host?

Will do.

@joetherod
Copy link
Author

@pranavkm I figured it out. Since my views are retrieved from the database as well, the compilation needed the ViewImports file. On release mode those files are compiled and not available on the root. So, I just simulated the ViewImports file as well. I didnt have to do this for the ViewStart which manages how I resolve my layouts.

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

3 participants