Razorlight: One or more errors occurred. (Cannot find compilation library location for package 'Microsoft.NETCore.App') (ca5ca414)

Created on 27 Mar 2019  路  6Comments  路  Source: toddams/RazorLight

I have my .NET Core 2.2 library that has an unexpected behavior on my IIS Server.

I got this issue
One or more errors occurred. (Cannot find compilation library location for package 'Microsoft.NETCore.App') (ca5ca414).

Note that this issue doesn't happened when I run the project locally.

Also, I don't use embedded template, I use string as template.

I tried to put in my .csproj (of my library and in my web app (.Net core API 2.2)) :

< MvcRazorExcludeRefAssembliesFromPublish>false
< CopyRefAssembliesToPublishDirectory>false< /CopyRefAssembliesToPublishDirectory>
< MvcRazorCompileOnPublish>false< /MvcRazorCompileOnPublish>
< PreserveCompilationContext>true< /PreserveCompilationContext>

Without any result.

Code :

FluentEmail.Core.Email.DefaultRenderer = new RazorRenderer();
            var sender = new MailgunSender("@@@", "@@@");
            FluentEmail.Core.Email.DefaultSender = sender;

 var fluentEmail = FluentEmail.Core.Email
                    .From(email.Sender)
                    .To(email.Recipient.Email)
                    .Subject(email.Content.Subject)
                    .UsingTemplate(template, content);

                var response = await fluentEmail.SendAsync();

  • OS: Windows Server 2016
  • Platform NET Core 2.2
  • RazorLight version 2.0-beta1
C:\Users\Administrator>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.105
 Commit:    7cecb35b92

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.105\

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.2.100 [C:\Program Files\dotnet\sdk]
  2.2.103 [C:\Program Files\dotnet\sdk]
  2.2.105 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Publish command :

dotnet.exe publish ProjectName.sln --output C:\TeamCity\buildAgent\work\706005865bacd71f/output @C:\TeamCity\buildAgent\tempagentTmp\5d3f2082f93940649580add5b1a8d1a2.rsp

There is anything that I miss ?

Most helpful comment

In case you wonder, that's the proper fix, just add these property groups to your entry point csproj.
It has to be the entry point project, so the ASP.NET core web project, or your console project, etc

  <PropertyGroup>
    <!-- This group contains project properties for RazorLight on .NET Core -->
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
    <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
  </PropertyGroup>

All 6 comments

@CyrilleFormont Have you found a solution?

@molinch Yup, I got rid of it. I'm now using AWS, storing template as .html and send them as string.

I keep the issue open in case of somebody has a solution.

On the off chance, I wonder if it could be related to an issue I experienced in the past with a few projects...

If I created a .NET Core 2.2 application in Visual Studio 2017 everything worked fine when run locally from VS, but as soon as I deployed to a remote location it would always fail.

Bizarrely enough, after much pain, I found it was based on the .NET Framework version (not .NET Core) that was currently selected in the New Project VS dialog at the bottom. If I selected the latest version then all would work fine, but older versions would cause the issues with deployment.

I note that the .NET Framework version selector gets hidden now-a-days when a .NET Core project type is selected in the dialog. so maybe this is something that Microsoft fixed at some point.

In case you wonder, that's the proper fix, just add these property groups to your entry point csproj.
It has to be the entry point project, so the ASP.NET core web project, or your console project, etc

  <PropertyGroup>
    <!-- This group contains project properties for RazorLight on .NET Core -->
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
    <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
  </PropertyGroup>

@molinch Thanks, I'll document this.

In case you wonder, that's the proper fix, just add these property groups to your entry point csproj.
It has to be the entry point project, so the ASP.NET core web project, or your console project, etc

  <PropertyGroup>
    <!-- This group contains project properties for RazorLight on .NET Core -->
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
    <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
  </PropertyGroup>

This worked for me ! thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tresoldigiorgio picture tresoldigiorgio  路  4Comments

danwalmsley picture danwalmsley  路  7Comments

shobman picture shobman  路  4Comments

WaltDaniels picture WaltDaniels  路  6Comments

IInvocation picture IInvocation  路  6Comments