Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle build error NETSDK1045 with incorrect SDK when the .NET SDK is fixed with global.json #25622

Closed
giggio opened this issue Aug 20, 2021 · 0 comments · Fixed by #26005
Closed
Assignees
Labels
area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@giggio
Copy link

giggio commented 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.

@bricelam bricelam self-assigned this Aug 27, 2021
@ajcvickers ajcvickers added this to the 6.0.0 milestone Sep 3, 2021
bricelam added a commit to bricelam/efcore that referenced this issue Sep 13, 2021
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 13, 2021
@bricelam bricelam modified the milestones: 6.0.0, 6.0.0-rc2 Sep 14, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0-rc2, 6.0.0 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants