-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
I recently migrated my ASP.NET Core website from .NET Core 3.1 to .NET 6, and since the migration I get a runtime exception when referencing classes in the Microsoft.AspNetCore.Cryptography.KeyDerivation assembly when running under my production server on Linux Debian (no issue on Windows or in the Bitbucket pipeline which also runs a Linux container, mcr.microsoft.com/dotnet/sdk:6.0):
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Cryptography.KeyDerivation, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
More infos about the production environment:
- Debian version:
Debian GNU/Linux 10 (buster) - Kernel Version:
Linux 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29) - .NET runtime version:
6.0.1 Microsoft.AspNetCore.Cryptography.KeyDerivationnuget package version:6.0.1(explicit reference in the csproj of the class library subproject throwing the exception)- The website root does not contain any
Microsoft.AspNetCore.Cryptography.KeyDerivationassembly.
Might be related to this issue.
The issue disappeared when I updated the Microsoft.AspNetCore.Cryptography.KeyDerivation nuget package from 6.0.1 to 6.0.4 because the assembly now gets copied to the publish folder when I build on the production server. It seems the assembly is not copied when the .NET runtime and Microsoft.AspNetCore.Cryptography.KeyDerivation nuget versions match, but is copied when the nuget version is greater. This would mean I will get the error back when I update my .NET runtime to 6.0.4 and deploy again.