RazorLight icon indicating copy to clipboard operation
RazorLight copied to clipboard

Cannot find compilation library location for package 'Microsoft.AspNet.WebApi.Client'

Open loukikbhandari opened this issue 6 years ago • 9 comments

Hello , I am getting this error while running docker container with Net core 2.2 project which has following code

string result = await engine.CompileRenderAsync("Header.cshtml", Resource.Header, headerModel);

Expected behavior Should compile and render html

Information (please complete the following information):

  • OS: linux (docker container)
  • Platform .NET Core 2.2
  • RazorLight version 2.0-beta1
  • Visual Studio version 15.9.1

Error occurred: System.InvalidOperationException: Cannot find compilation library location for package 'Microsoft.AspNet.WebApi.Client'\\n at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List1 assemblies)\\\\n at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()\\\\n at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext()\\n at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(DependencyContext dependencyContext)\\n at RazorLight.Compilation.RoslynCompilationService.EnsureOptions()\\n at RazorLight.Compilation.RoslynCompilationService.get_ParseOptions()\\n at RazorLight.Compilation.RoslynCompilationService.CreateSyntaxTree(SourceText sourceText)\\n at RazorLight.Compilation.RoslynCompilationService.CreateCompilation(String compilationContent, String assemblyName)\\n at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate)\\n at RazorLight.Compilation.RoslynCompilationService.CompileAsync(IGeneratedRazorTemplate razorTemplate)\\n--- End of stack trace from previous location where exception was thrown ---\\n at RazorLight.Compilation.TemplateFactoryProvider.CompileAsync(IGeneratedRazorTemplate razorTemplate)\\n at RazorLight.Compilation.TemplateFactoryProvider.CreateFactoryAsync(String templateKey)\\n at RazorLight.RazorLightEngine.CompileTemplateAsync(String key)\\n at RazorLight.RazorLightEngine.CompileRenderAsync(String key, Object model, Type modelType, ExpandoObject viewBag)\\n at

loukikbhandari avatar Apr 26 '19 23:04 loukikbhandari

@toddams Have you came across this issue with docker containers having net core apps

loukikbhandari avatar Apr 26 '19 23:04 loukikbhandari

@loukikbhandari I've found that workaround https://github.com/toddams/RazorLight/issues/217#issuecomment-428539715

pereirazc avatar May 14 '19 03:05 pereirazc

@loukikbhandari is your publish profile set to self contained or framework dependent. I am deploying to a windows machine, with SelfContained as true in publish profile and have this issue as well. So I have a feeling its related to that.

SirMrDexter avatar Sep 03 '19 02:09 SirMrDexter

@SirMrDexter I wanted to add another data point, as I'm having this issue with SelfContained = false in my publish profile. So not sure that is the issue.

SyntaxErrorOnLine1 avatar Nov 01 '19 16:11 SyntaxErrorOnLine1

@SyntaxErrorOnLine1 Are you using a docker container? I just updated the FAQ with a bunch of information.

jzabroski avatar Dec 17 '19 14:12 jzabroski

As a request, I wish people who ARE running in a container please upload to GitHub a sample project with the Dockerfile. It should lead to 100% reproducible problem.

jzabroski avatar Dec 17 '19 14:12 jzabroski

@jzabroski No, I'm not. I've just resolved my issue (I think - it's still to be fully tested) by setting MvcRazorCompileOnPublish = true in my project file, so it's likely that it's a different issue to the OP, but was giving the same error message. Sorry for the false positive.

SyntaxErrorOnLine1 avatar Dec 21 '19 11:12 SyntaxErrorOnLine1

I can confirm exactly the same problem with .net core 2.2. It was resolved by applying the instructions from the FAQ. Thanks.

mcrio avatar Dec 23 '19 21:12 mcrio

#336 might be related. @mcrio thanks for your feedback.

jzabroski avatar Apr 18 '20 17:04 jzabroski