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

feat: add .NET 9 Support #914

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nathan-mittelette
Copy link

Add support for .NET 9 based on this PR : #777

@nathan-mittelette nathan-mittelette requested a review from a team as a code owner November 15, 2024 10:27
@nathan-mittelette nathan-mittelette force-pushed the feat/dotnet-9-support branch 2 times, most recently from 5ff19e9 to 864914e Compare November 15, 2024 10:31
Signed-off-by: Nathan Mittelette <[email protected]>
@nil4
Copy link
Contributor

nil4 commented Nov 17, 2024

Adding a new net9.0 target to this tool would work, but I would argue that doing so would be inefficient and ultimately, unnecessary.

The tool currently targets .NET 6, 7, and 8. Adding a new .NET target would be inefficient because it would increase the package size by ~33% without providing new APIs or features.

It is not necessary because there is a relatively obscure, but straightforward, way for end-users to install and use the tool as-is with .NET 9.

Consider the scenario where only .NET 9 SDK is installed (and [...] denotes elided output to keep this brief):

> dotnet --version
9.0.100

> dotnet tool install --global CycloneDX
You can invoke the tool using the following command: dotnet-CycloneDX
Tool 'cyclonedx' (version '4.0.0') was successfully installed.

> dotnet cyclonedx --version
You must install or update .NET to run this application.

App: C:\Users\nil4\.dotnet\tools\dotnet-CycloneDX.exe
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '8.0.0' (x64)
.NET location: C:\Program Files\dotnet\

The following frameworks were found:
  9.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

[...]
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0&arch=x64&rid=win-x64&os=win10

ref. https://youtu.be/4iEqqPZKDC0?t=2081 end-users can explicitly add --allow-roll-forward when installing the tool to work around this issue:

> dotnet tool uninstall --global CycloneDX
Tool 'cyclonedx' (version '4.0.0') was successfully uninstalled.

> dotnet tool install --global --allow-roll-forward CycloneDX
You can invoke the tool using the following command: dotnet-CycloneDX
Tool 'cyclonedx' (version '4.0.0') was successfully installed.

> dotnet cyclonedx --version
4.0.0+3d71d1f1a7609ea5c8108ca11ea07d5ad2f0222b

With this, CycloneDX can be installed and used as-is on .NET 9 and future versions.

Additionally, end-users could be spared the inconvenience of having to add --allow-roll-forward when installing (and contributors/maintainers rushing to add new netX.0 targets yearly) by adding <RollForward>Major</RollForward> to the tool's project file.

This is what #909 suggests -- that change would allow the straightforward dotnet tool install --global CycloneDX to work with any future .NET SDK.

@mtsfoni
Copy link
Contributor

mtsfoni commented Nov 17, 2024

I agree with nil, additionally, for the next major version, we can remove dotnet 6 and 7 to reduce package size.

@maarten-kieft
Copy link

maarten-kieft commented Dec 3, 2024

Any news on this? We facing issues that the docker file doesn't support .net 9. We could ofcourse create our own docker image, but we rather stay in sync. Is this PR going to be closed or adjusted @nil4 ?

@nil4
Copy link
Contributor

nil4 commented Dec 6, 2024

The rollForward=major policy was merged in #909 and the subsequent release 4.1.0 includes it: https://github.com/CycloneDX/cyclonedx-dotnet/releases/tag/v4.1.0

My testing showed that installing and using version 4.1.0 worked on .NET 9 SDK. Should you face any problems, may I suggest opening a new issue to add the relevant details (e.g. stacktraces, etc.) @maarten-kieft ?

@maarten-kieft
Copy link

@nil4 Yeah we have since that version, however the dockerfile in version 4.1.0 is still using .net 8 and therefore complaining about code which is build in .net 9. If you prefer I can setup a separate issue for it, but the changes here would fix it though.

@nil4
Copy link
Contributor

nil4 commented Dec 6, 2024

I suppose you're referring to this line here:

FROM mcr.microsoft.com/dotnet/sdk:8.0.101

If so, I can see how updating that base image version to a 9.0 SDK would be helpful.

I would suggest requesting the project maintainers' feedback about this topic -- I'm not familiar with how the Docker image is created and published, nor using it myself. My feeling is that many other changes in this PR may be too broad, if this is the only update needed.

@mtsfoni
Copy link
Contributor

mtsfoni commented Dec 7, 2024

I built a new version 4.2 with sdk:9.0 as base image - everything else should work with the rollForward option.

Image needs to need to have the newest version because so it can nuget restore the projects it is supposed to scan.

@maarten-kieft please give me feedback if this resolves your issues.

@maarten-kieft
Copy link

maarten-kieft commented Dec 7, 2024

@mtsfoni , I will try it Monday and let you know. And yes @nil4 that was it indeed. Thank you both, much appreciated!

@maarten-kieft
Copy link

@mtsfoni The issue is resolved! Thank you very much!

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 this pull request may close these issues.

4 participants