I have a AzureFunctions project that I needed to upgrade to .NET standard 2.1 (from 2.0) All of my other projects in the solution load and compile correctly but this AzureFunctions project is throwing this error:
Error System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
I've verified all the nuget packages are updated, what else could it be?
Thanks!
Some times you receive this error because you have referenced a library/nuget package that target the incompatible .Net standard.
example: If you create project that target to .Net Core 2.2 and you try to add the library which target .net standard 2.1 then you will get the same error because .Net Core 2.2 is compatible with .net standard 2.0 or lower so you can add package/library that target to .Net Standard 2.0 or lower version.
Please see the links for more details :
.Net Core and .Net Standard
.Net Standard Compatiblity Table
I get the same error.
I don't think it's related to Microsoft.NET.Sdk.Functions package as you need that package (specifically 1.0.30-beta2 in order to try the preview of .net core 3).
I think it's got something to do with Microsoft.Extensions.Logging. If you create a new azure functions project you'll see the Azure.WebJobs.Extensions.Storage uses v2.1 of the logging package within it. However if you have a project that itself uses the latest logging, then it'll use v3.0 too.
But somewhere along the lines I don't think it really wants to and it fails in azure trying to find v2.1.
If your function takes an ILogger as a parameter it'll fail too more specifically showing it can't find that type. I think this is all because ultimately it's a preview, I can't seem to get it to work just now either.
I had the same problem. I eventually discovered that changing the Azure functions project properties to target .NET Core 3.1 still left the Azure function version on V2. The solution was to edit the CSPROJ and set the from v2 to v3.
My project file target netcoreapp3.1
with Microsoft.NET.Sdk.Functions 3.0.3
based on a template
gave a similar error.
Removing azure-functions-core-tools
and installing a different version solved it for me.
npm uninstall azure-functions-core-tools
npm install azure-functions-core-tools@3 --unsafe-perm true
I tried several approaches and ended up creating a new project and then moved items from the old project until I got the error again, I found that the error was resolved when I removed the nuget package "Microsoft.NET.Sdk.Functions".