I use FluentMigrator in NET7 and wanted to migrate my migrations. I use the:
dotnet tool install -g FluentMigrator.DotNet.Cli
And I have ran command:
dotnet fm migrate -a Conversations.API.dll -p postgres -c "omitted"
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly And I got:
'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
When I use --allowDirtyAssemblies flag, then I get exception as below:
// Wrong assembly binding redirects for System.Runtime, loading it from disk anyway. pathomitted/System.Runtime.dll
// Wrong assembly binding redirects for Google.Protobuf, loading it from disk anyway. pathomitted/Google.Protobuf.dll
Unhandled exception. System.TypeLoadException: Could not load type 'Google.Protobuf.IBufferMessage' from assembly 'Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604'.
That's my .csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.151" />
<PackageReference Include="FluentMigrator" Version="3.3.2" />
<PackageReference Include="FluentMigrator.Console" Version="3.3.2" />
<PackageReference Include="FluentMigrator.Runner.Postgres" Version="3.3.2" />
<PackageReference Include="Grpc.AspNetCore" Version="2.55.0" />
<PackageReference Include="Npgsql" Version="7.0.4" />
<PackageReference Include="PasetoBearer.Authentication" Version="2.0.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\get_conversations.proto" GrpcServices="Server" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\get_conversation_messages.proto" GrpcServices="Server" />
</ItemGroup>
</Project>
Why it happens?
At a quick glance I'd assume one of your elements needs updated or you updated without adjusting assembly binding redirects?