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

Support .NET 8 #2792

Closed
martincostello opened this issue Apr 14, 2024 · 7 comments · Fixed by #2799
Closed

Support .NET 8 #2792

martincostello opened this issue Apr 14, 2024 · 7 comments · Fixed by #2799
Assignees

Comments

@martincostello
Copy link
Collaborator

martincostello commented Apr 14, 2024

Tracking issue to add support for net8.0.

This issue does not cover adding support for any new language features added as part of .NET 8 (or 7), such as required members (see #2555), new ASP.NET Core features etc. Those will be treated as separate feature requests.

@Frulfump
Copy link

Great to see a tracking issue for this! Congratulations on the new core team as well.
Not sure if this is somewhat covered by any of the closed issues but probably worth to include at least to get the documentation updated once support lands.

"Build-time OpenAPI document generation with Swashbuckle isn't supported in .NET 8 and later. For a supported build-time alternative, see ASP.NET Core web API documentation with Swagger / OpenAPI. Run-time document generation is still supported in .NET 8."
https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-8.0

@VAllens
Copy link

VAllens commented Apr 16, 2024

Glad to see the progress here, let's follow it up together

@JoiGud
Copy link

JoiGud commented May 8, 2024

Just to chime in, you can delete this comment if this is not relevant! 😄

Anyway, me and my college were trying to generate the swagger.json file from a dotnet8 project. Worked like a charm on my machine, but was always giving an error message when running
dotnet "tool" "run" "swagger" "tofile" "--output"

And it was always suggesting that we install dotnet7.

We tried to use homebrew to have 2 different versions at the same time but it didn't work. What did work, however, was removing all versions, folders and stuff from /usr/local/share/dotnet.

Then we installed, first, dotnet7SDK from microsoft (https://dotnet.microsoft.com/en-us/download/dotnet/7.0) and then we installed dotnet8SDK (https://dotnet.microsoft.com/en-us/download/dotnet/8.0) and everything worked like a charm!

Hope this helps!

@martincostello
Copy link
Collaborator Author

martincostello commented May 8, 2024

Another way to workaround the need for .NET 7 when using the CLI tool is to set the following environment variable:

DOTNET_ROLL_FORWARD=LatestMajor

That will cause the tool to run with the .NET 8 runtime (doesn't guarantee it'll work, but I imagine it will).

@ptzedakis
Copy link

ptzedakis commented May 11, 2024

Hi, I keep getting a different error:

Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'IServiceProvider'.

In net7.0 everything works fine and the openapi.json file gets created during VS 2022 PostBuildEvent where I have the following code:

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="dotnet tool restore"></Exec>
    <Exec Command="dotnet tool run swagger tofile --output openapi.json $(TargetPath) v1"></Exec>
    <Exec Command="dotnet tool run swagger tofile --output openapi-v2.json $(TargetPath) v2"></Exec>
  </Target>

I tried using the environment variable DOTNET_ROLL_FORWARD=LatestMajor but it didn't work. :(

Can you please shed some light on what could be the issue?
I cannot move my .NET Core APIs to .NET 8 because of this issue.

Thank you,
P.

@martincostello
Copy link
Collaborator Author

If the environment variable isn't working, all I can suggest for now to wait until #2799 is merged and then test it out with a version from our prerelease feed. If it then still doesn't work, we can look into it.

@ptzedakis
Copy link

Thank you @martincostello. I shall wait as you suggest. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants