-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Milestone
Description
File a bug
When trying to scaffold my database using text templates, the resulting is an FileLoadException after build succeeds.
Include your code
The following is my project files (excluding code and sensitive information):
csproj:
<Project Sdk="Microsoft.NET.Sdk" />Directory.Build.props:
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--
For non-SDK projects that import this file and then import Microsoft.Common.props,
tell Microsoft.Common.props not to import Directory.Build.props again
-->
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>MyBot.Database</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<OutputPath>..\bin\$(Configuration)\</OutputPath>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<Version>2.1.100</Version>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>preview</AnalysisLevel>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<IsPackable>false</IsPackable>
<DebugType>embedded</DebugType>
</PropertyGroup>
</Project>Directory.Build.targets:
<Project>
<ItemGroup>
<!-- We do not need these global usings. -->
<Using Remove="System.Net.Http" />
<Using Remove="System.Threading" />
<!-- We need to also add these global usings. -->
<Using Include="System.ComponentModel.DataAnnotations" />
<Using Include="System.ComponentModel.DataAnnotations.Schema" />
<Using Include="System.Globalization" />
<Using Include="CsvHelper" />
<Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Builders" />
<Using Include="Microsoft.Extensions.DependencyInjection" />
<Using Include="MyBot.Database.Extensions" />
<InternalsVisibleTo Include="MyBot.Discord" />
<None Update="CodeTemplates/EFCore/DbContextGenerator.t4">
<Link>Model/DbContextGenerator.t4</Link>
</None>
<None Update="CodeTemplates/EFCore/EntityTypeGenerator.t4">
<Link>Model/EntityTypeGenerator.t4</Link>
<DependentUpon>DbContextGenerator.t4</DependentUpon>
</None>
<Compile Update="Model/BotDbContext.cs">
<DependentUpon>DbContextGenerator.t4</DependentUpon>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="Model/BotDbContext.Methods.cs">
<DependentUpon>BotDbContext.cs</DependentUpon>
</Compile>
<Compile Update="Model/DiscordToken.cs">
<DependentUpon>EntityTypeGenerator.t4</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="Model/ExpiringVerification.cs">
<DependentUpon>EntityTypeGenerator.t4</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="Model/Patron.cs">
<DependentUpon>EntityTypeGenerator.t4</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="Model/Role.cs">
<DependentUpon>EntityTypeGenerator.t4</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="Model/Tier.cs">
<DependentUpon>EntityTypeGenerator.t4</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
</ItemGroup>
</Project>Directory.Packages.props:
<Project>
<ItemGroup>
<PackageReference Include="IDisposableAnalyzers" Version="*-*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="*-*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="*-*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="CsvHelper" Version="*-*" />
</ItemGroup>
</Project>nuget.config feeds:
- dotnet-7
- nuget.org (default implicitly used for packages not in dotnet-7)
Include stack traces
System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String dataDirectory, String rootNamespace, String language, Boolean nullable, String[] remainingArguments)
at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor(String[] remainingArguments)
at Microsoft.EntityFrameworkCore.Tools.Commands.DbContextScaffoldCommand.Execute(String[] args)
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Include verbose output
Please include --verbose output when filing bugs about the dotnet ef or Package Manager Console tools.
Use triple-tick fences for tool output. For example:
Using project 'H:\Desktop\github\MyBot\MyBot.Database\MyBot.Database.csproj'.
Using startup project 'H:\Desktop\github\MyBot\MyBot.Database\MyBot.Database.csproj'.
Writing 'H:\Desktop\github\MyBot\MyBot.Database\obj\MyBot.Database.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\User\AppData\Local\Temp\tmp8ECD.tmp /verbosity:quiet /nologo "H:\Desktop\github\MyBot\MyBot.Database\MyBot.Database.csproj"
Writing 'H:\Desktop\github\MyBot\MyBot.Database\obj\MyBot.Database.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\User\AppData\Local\Temp\tmp9BAF.tmp /verbosity:quiet /nologo "H:\Desktop\github\MyBot\MyBot.Database\MyBot.Database.csproj"
Build started...
dotnet build "H:\Desktop\github\MyBot\MyBot.Database\MyBot.Database.csproj" /verbosity:quiet /nologo
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:15.72
Build succeeded.
dotnet exec --depsfile "H:\Desktop\github\MyBot\bin\net6.0\MyBot.Database.deps.json" --additionalprobingpath C:\Users\User\.nuget\packages --additionalprobingpath "C:\Users\User\Desktop\VS2017 Preview\Shared\NuGetPackages" --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" C:\Users\User\.nuget\packages\dotnet-ef\7.0.0-preview.3.22159.9\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll dbcontext list --assembly "H:\Desktop\github\MyBot\bin\net6.0\MyBot.Database.dll" --project "H:\Desktop\github\MyBot\MyBot.Database\MyBot.Database.csproj" --startup-assembly "H:\Desktop\github\MyBot\bin\net6.0\MyBot.Database.dll" --startup-project "H:\Desktop\github\MyBot\MyBot.Database\MyBot.Database.csproj" --project-dir "H:\Desktop\github\MyBot\MyBot.Database\\" --root-namespace MyBot.Database --language C# --framework net6.0 --nullable --working-dir "H:\Desktop\github\MyBot" --verbose
Using assembly 'MyBot.Database'.
Using startup assembly 'MyBot.Database'.
Using application base 'H:\Desktop\github\MyBot\bin\net6.0'.
Using working directory 'H:\Desktop\github\MyBot\MyBot.Database'.
Using root namespace 'MyBot.Database'.
Using project directory 'H:\Desktop\github\MyBot\MyBot.Database\'.
Remaining arguments: .
System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String dataDirectory, String rootNamespace, String language, Boolean nullable, String[] remainingArguments)
at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor(String[] remainingArguments)
at Microsoft.EntityFrameworkCore.Tools.Commands.DbContextListCommand.Execute(String[] args)
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Include provider and version information
EF Core version: Latest on dotnet-7 feed.
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6
Operating system: Windows
IDE: Visual Studio 2022 17.2 Preview 2
Reactions are currently unavailable