I have an ASP.NET Core 1.1 website that targets .NET Framework 4.6.1. Now after installing .NET Core SDK 2.0, I can't view any of the pages because of the error:
InvalidOperationException: Can not find compilation library location for package 'xxx'
Below is the stack trace. Not sure if it's really Razor-related. The site works after uninstalling .NET Core 2.0 SDK.
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart+<>c.b__8_0(CompilationLibrary library)
System.Linq.Enumerable+d__16.MoveNext()
Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerableparts, MetadataReferenceFeature feature)
Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature(TFeature feature)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager.GetCompilationReferences()
System.Threading.LazyInitializer.EnsureInitializedCore(ref T target, ref bool initialized, ref object syncLock, Func valueFactory)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager.get_CompilationReferences()
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.CreateCompilation(string compilationContent, string assemblyName)
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.Compile(RelativeFileInfo fileInfo, string compilationContent)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorCompilationService.Compile(RelativeFileInfo file)
Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.CreateCacheEntry(string relativePath, string normalizedPath, Funccompile)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.GetOrAdd(string relativePath, Funccompile)
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(string relativePath)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSetexpirationTokens, string relativePath, bool isMainPage)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, string pageName, bool isMainPage)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, string viewName, bool isMainPage)
Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, string viewName, bool isMainPage)
Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
Microsoft.AspNetCore.Mvc.ViewResult+d__26.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__30.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__28.MoveNext()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResultExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__22.MoveNext()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__20.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Session.SessionMiddleware+d__9.MoveNext()
Microsoft.AspNetCore.Session.SessionMiddleware+d__9.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+d__7.MoveNext()
Same here, I have an asp.net core 2.0 application (net462) trying to reference a net462 assembly.
PreserveCompilationContext
is set to true but reference is ignored.
@DamianEdwards @Eilon was this supposedly fixed for 2.0.0?
/cc @pranavkm
@EPinci your issue is likely a dup of https://github.com/dotnet/core-setup/issues/2981.
@jomargon, could you share a repro application with us assuming you're issue is not the same as https://github.com/dotnet/core-setup/issues/2981?
@pranavkm This is basically a dup of https://github.com/aspnet/Mvc/issues/6661. One of the comments contain a link to the repro app.
I thought I recognized your GitHub alias 馃槃. https://github.com/dotnet/core-setup/issues/2981 is slated to be fixed for the 2.0.2 release and for the time being https://github.com/dotnet/core-setup/issues/2981#issuecomment-322572374 is the best workaround we have.
@pranavkm indeed a dup of dotnet/core-setup#2981.
Workaround works for me but direct DLL reference has been an issue since... forever. Do you know why the fix has been postponed from 2.0.1?
@EPinci I'm not sure about pre-2.0.0, but by the time we got reports of it in Asp.Net Core Mvc 2.0.0, the CLI core-setup was already locking down for the 2.0.1 release. Since lots of teams (including AspNetCore) build and re-test on top of them, resetting would've upset lots of schedules. Given we have a workaround for now, it was deemed safer to fix it in the follow up release.
@jomargon, could this be closed since we have a workaround for now?
@pranavkm Ok I'm gonna close this now. Looking forward to 2.0.1.
Team, have we found a fix of this ? I am facing the same issue while creating mvc project using dotnet core on Mac Sierra.
鉁岋笍
@foo-baar, does https://github.com/dotnet/core-setup/issues/2981#issuecomment-322572374 work for you?
@pranavkm : Nopes then it starts yelling about oldMetadataReferenceFeatureProvider references which is another dense cave unless your are using VIsual Studio, I am on Mac with VScode & wanted to stay away from that heavy stack this time, hence struggling to make the basic boilerplate work.
Danke,
馃憤
My problem also solved Installing Nuget package for System.Configuration.ConfigurationManager
InvalidOperationException: Cannot find compilation library location for package
I ran into this issue with .NET Core 2.1.1. I was using the RazorLight lib coupled with some cshtml files for FluentEmail. Having the cshtml email templates in my project triggered error "Cannot find compilation library location for package" after deployment. I truly did not need the Razor compilation, since it was being handled by RazorLight at runtime, so adding <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
to the csproj file resolved the issue
Which file/where do you add <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
?
@jessicac311 edit your *.csproj file, and add the following:
<PropertyGroup>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>
Most helpful comment
@jessicac311 edit your *.csproj file, and add the following: