Azure-functions-host: Could not load file or assembly 'Microsoft.AspNetCore.Razor.Language, Version=3.1.2.0...

Created on 19 Mar 2020  路  8Comments  路  Source: Azure/azure-functions-host

I'm attempting to make an Azure Functions based emailer using a Razor Class Library (RCL) with .Net Core 3.1:

image

However, while using the latest release, my functions app fails to find the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation library, even though it's been referenced in my nuget packages. It attempts to load this from the Azure Function Tools cli directory:

image

Is there a work-around to force my project find this package?

Sample project attached:
RazorFunctionsApp.zip

Most helpful comment

Just to chime in on what worked for me. I was getting the same issue after upgrading my functions project to .NET Core 3.1 / the latest functions runtime and was able to solve it for now by adding this line to my functions csproj file right below my AzureFunctionsVersion tag :

<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>

Found this solution in the issue linked by @FluentChange. It sounds like it may get fixed in one of the future versions of the Azure Functions SDK.

All 8 comments

Is there a workaround for this?

@fabiocav I tried adding <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to the csproj and it didn't fix the problem. Can you take a look?

i had same problem, and could solve it by downgrading Azure Functions SDK to 3.0.3
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
i think it is related to this issue: Azure/Azure-Functions#1518

Downgrading to Microsoft.NET.Sdk.Functions 3.0.3 in the sample project in the OP exhibits the same issue for me unfortunately. 馃槩

Edit: Spoke too soon. After doing a Clean, it worked!

I had a similar issue and it turned out that I was trying to run v3 project with Azure Functions Core Tools v2. Updating _tools_ to v3 solved the problem.

Just to chime in on what worked for me. I was getting the same issue after upgrading my functions project to .NET Core 3.1 / the latest functions runtime and was able to solve it for now by adding this line to my functions csproj file right below my AzureFunctionsVersion tag :

<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>

Found this solution in the issue linked by @FluentChange. It sounds like it may get fixed in one of the future versions of the Azure Functions SDK.

Had same error (except with Microsoft.AspNetCore.Razor.Language, Version=3.1.4 instead of 3.1.2) after updating to latest functions sdk.

Using:
<_FunctionsSkipCleanOutput>true

as @everix1992 said above instantly fixed the issue.

@anthonychu can you confirm what you saw, as expected, and based on what is described above, looks like disabling the output trimming seems to work.

This is a restriction we can safely relax, so I'll be assigning this to the next sprint so we can get this resolved.

Was this page helpful?
0 / 5 - 0 ratings