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

Error restoring WebAPI project using .NET 9 #110201

Open
FraserElectronics opened this issue Nov 26, 2024 · 4 comments
Open

Error restoring WebAPI project using .NET 9 #110201

FraserElectronics opened this issue Nov 26, 2024 · 4 comments
Labels
area-Meta untriaged New issue has not been triaged by the area owner

Comments

@FraserElectronics
Copy link

I have created a WebAPI on a Linux machine using:

dotnet new webapi -n myapp.

I wish to host this API in a docker container so I have followed the instructions here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-9.0

When I run docker build -t myapp . I get the error:

error NETSDK1045: The current .NET SDK does not support targeting .NET 9.0.  Either target .NET 8.0 or lower, or use a version of the .NET SDK that supports .NET 9.0.

If I list the installed sdk's with dotnet --list-sdks I get:

9.0.100 [/usr/lib/dotnet/sdk]

What am I missing?

Andy

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 26, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

@julealgon
Copy link

@FraserElectronics do you have a global.json file in your solution?

@vcsjones
Copy link
Member

The Dockerfile on the linked page might need to be updated. It has a line like this:

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

If you are using .NET 9, which it looks like you are, you should change the version numbers in the Dockerfile to 9.0 instead of 8.0.

@Clockwork-Muse
Copy link
Contributor

Side note: recent version of the SDK have build-pack-like capabilities (if not using that tool itself), so you probably don't need to write/maintain the dockerfile yourself. Unless you're doing something unusual, you probably want to do that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Meta untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

4 participants