question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Following the publish of the API controller project, the following error occurs.

See original GitHub issue

BiHu.AspNetCore.Demo.API.Controllers.ValuesController|ERROR| System.Private.CoreLib at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at BiHu.AspNetCore.Demo.API.Controllers.ValuesController.Get() in D:\CompanyProject\BiHu.AspNetCore.Demo\src\BiHu.AspNetCore.Demo.API\Controllers\ValuesController.cs:line 53 One or more errors occurred. (Cannot find compilation library location for package 'System.Data.SqlClient') System.InvalidOperationException: Cannot find compilation library location for package 'System.Data.SqlClient' at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List1 assemblies) at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext() at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(DependencyContext dependencyContext) at RazorLight.Compilation.RoslynCompilationService.EnsureOptions() at RazorLight.Compilation.RoslynCompilationService.get_ParseOptions() at RazorLight.Compilation.RoslynCompilationService.CreateSyntaxTree(SourceText sourceText) at RazorLight.Compilation.RoslynCompilationService.CreateCompilation(String compilationContent, String assemblyName) at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate) at RazorLight.Compilation.RoslynCompilationService.CompileAsync(IGeneratedRazorTemplate razorTemplate) — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at RazorLight.Compilation.TemplateFactoryProvider.<CompileAsync>d__10.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at RazorLight.Compilation.TemplateFactoryProvider.<CreateFactoryAsync>d__8.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at RazorLight.RazorLightEngine.<CompileTemplateAsync>d__14.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at RazorLight.RazorLightEngine.<CompileRenderAsync>d__11.MoveNext()

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ragnarek81997commented, Jun 28, 2018

I have the same problem, but only when building on a linux (.net core 2.1) in code

var _engine = new RazorLightEngineBuilder()
.UseFilesystemProject(Path.Combine(Directory.GetCurrentDirectory(), "Templates"))
.UseMemoryCachingProvider()
.Build();

var result = string.Empty;
var cacheResult = _engine.TemplateCache.RetrieveTemplate(viewPath);
if (cacheResult.Success)
{
	result = await _engine.RenderTemplateAsync(cacheResult.Template.TemplatePageFactory(), model);
}
else
{
	result = await _engine.CompileRenderAsync(viewPath, model);
}

exception

System.InvalidOperationException: Cannot find compilation library location for package 'Microsoft.NETCore.App'
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List`1 assemblies)
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(DependencyContext dependencyContext)
at RazorLight.Compilation.RoslynCompilationService.EnsureOptions()
1reaction
huanbdcommented, Sep 4, 2018

I’ve resolved this error, this is my work. In project file *.csproj, change to like this:

<PropertyGroup>
    ...
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
  </PropertyGroup>

and when deploy your project, copy all file/folder in bin folder

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web API in an MVC project not working after publishing
I have an mvc project which has a web api controller. The web api has a Get method which returns a list of...
Read more >
Handle errors in ASP.NET Core web APIs
The error response can be configured in one of the following ways: Implement ProblemDetailsFactory.
Read more >
Create web APIs with ASP.NET Core
ASP.NET Core supports creating web APIs using controllers or using minimal APIs. Controllers in a web API are classes that derive from ...
Read more >
[Solved] The resource cannot be found
Solution 1. One reason this could occur is if you don't have a start page set under your web project's properties. So do...
Read more >
Resolve errors | Google Drive
This error occurs for the following situations: The daily limit was exceeded. The user rate limit was exceeded. The project rate limit was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found