RazorLight: Cannot find compilation library location for package 'Microsoft.NETCore.App'
Describe the bug My code run ok on developer machine. But not in Azure WebApp production.
Im using .Net Core 2.1. I get this error
Cannot find compilation library location for package 'Microsoft.NETCore.App'
To Reproduce Steps to reproduce the behavior:
string html = await _engine.CompileRenderAsync(templateKey, razor, data);
Expected behavior A clear and concise description of what you expected to happen.
Information (please complete the following information):
- OS: Windows Server 2016 (Azure WebApp) Plataform: .NET Core 2.1
- RazorLight version : e.g 2.0-beta1
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 14
- Comments: 17
I solve the problem, putting this on csproj
The key is the “MvcRazorExcludeRefAssembliesFromPublish” tag
The main problem in using Library for storing the Embedded Views. Here is an explanation: https://github.com/aspnet/Mvc/issues/6021
So I had to clean up the library
csprojfile from any additional configuration and add<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>to the WebApp itself.Here’s a very useful solution to this problem.
When publishing, view the Settings. Select ‘File Publish Options’ -> Remove additional files at destination.
There’s an outdated assembly that’s causing problems, and this should clear it for you.
Hey everybody,
I ran into the same issue. Unfortunately I was not able to find the solution helped me. I have tried this one: https://github.com/toddams/RazorLight/issues/203#issuecomment-403503671 I have also tried this one: https://stackoverflow.com/questions/51269559/razor-templates-cannot-find-compilation-library-location-for-package
@OblivionSY your sample (https://github.com/toddams/RazorLight/issues/203#issuecomment-422851064) has the latest line commented which is original one from the @penihel response (https://github.com/toddams/RazorLight/issues/203#issuecomment-403503671). So I’m a bit confusing.
I’m using dotnetcore2.1. I have the Email service library with the templates inside as an Embedded resources + main WebApp with the regular .cshtml pages. So I have added the referenced sections to the library project. I have tried Azure DevOps Build\Release process as well as publishing from VS2017 manually. No luck. I have also tried to remove the
wwwrootfolder from the Azure WebApp using the Kudo tool to force the truly clear publish.I ended up with all 3 parameters:
Here is the stack trace from Azure:
Package versions:
Do you have any ideas guys\girls? Is it related to the Class Library type of project?