Closed
Description
openedon Aug 20, 2021
File a bug
If you constrain a directory to use .NET 6, but your root is using .NET 5 (using global.json
files), then the bundle compilation fails with NETSDK1045
because it runs under a temp directory using .NET 5.
Include your code
Any migrations code will do.
Include stack traces
This is from running:
dotnet ef migrations bundle -s ..\EfBundleWeb\ --verbose
The result with error is this:
Building bundle...
dotnet publish --output C:\Users\giovanni\AppData\Local\Temp\y1madpe2.cxd\publish
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Skipping project "C:\Users\giovanni\AppData\Local\Temp\EfBundleWeb\EfBundleWeb.csproj" because it was not found.
Skipping project "C:\Users\giovanni\AppData\Local\Temp\EfBundleWeb\EfBundleWeb.csproj" because it was not found.
C:\Program Files\dotnet\sdk\5.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0. [C:\p\rabiscos\net6\EfBundle\src\Model\Model.csproj]
C:\Program Files\dotnet\sdk\5.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0. [C:\Users\giovanni\AppData\Local\Temp\y1madpe2.cxd\bundle.csproj]
Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors.
at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args) in ef.dll:token 0x60001a9+0x23b
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args) in ef.dll:token 0x6000205+0x3b
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) in ef.dll:token 0x6000053+0x100
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) in ef.dll:token 0x60000cf+0x2e
Build failed. Use --verbose to see errors.
Include provider and version information
EF Core version:
dotnet-ef: 6.0.0-preview.7.21378.4
Same for Microsoft.EntityFrameworkCore.Design
and Microsoft.EntityFrameworkCore.SqlServer
.
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: 6.0.100-preview.7.21379.14
Operating system: Microsoft Windows [Version 10.0.19043.1165]
IDE: Visual Studio 2022 Preview 3.1
Workaround
I copied this global.json to $env:TEMP
, which is where I noticed the bundle was being compiled:
{
"sdk": {
"allowPrerelease": true,
"rollForward": "latestMajor"
}
}
After that it worked fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment