andrewlock / NetEscapades.AspNetCore.SecurityHeaders

Small package to allow adding security headers to ASP.NET Core websites
MIT License
701 stars 73 forks source link

Added net9.0 to target frameworks so package works with .NET 9 projects. #210

Closed brutaldev closed 1 week ago

brutaldev commented 1 week ago

When using this package with a .NET 9 project you get the error "Package NetEscapades.AspNetCore.SecurityHeaders 1.0.0-preview.2 is not compatible with net90 (.NETFramework,Version=v9.0). Package NetEscapades.AspNetCore.SecurityHeaders 1.0.0-preview.2 supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1)"

andrewlock commented 1 week ago

If you read the message carefully, it's because it's trying to find .NET Framework 9.0 😄 The tfm you need is net9.0. The existing package works fine 🙂

brutaldev commented 1 week ago

For some reason I cannot get the preview version to work in an ASP.NET 9 project because of this restore error though. If I revert back to 0.24.0 then for some reason it works.

The build is using .NET 9:

image

And other packages restore without issue:

image

I have no idea why the error refers to net90 but that's definitely not coming from my project.

brutaldev commented 1 week ago

Found the issue, it's because the DevOps build servers have NuGet 4.x installed by default:

Caching tool: NuGet 4.9.6 x64
Found tool in cache: NuGet 4.9.6 x64
Resolved from tool cache: 4.9.6
Using version: 4.9.6
Found tool in cache: NuGet 4.9.6 x64
Detected NuGet version 4.9.6.8 / 4.9.6+a32bce39889f724fbd11cfd12e946f802168b583

Forcing at least NuGet 5.x gets it working:

image