codeql-action icon indicating copy to clipboard operation
codeql-action copied to clipboard

CodeQL does not seem to support .NET 6.x (pre-release)

Open manastalukdar opened this issue 4 years ago • 18 comments

Code is not detected when built with .NET 6.x (pre-release).

manastalukdar avatar Oct 03 '21 00:10 manastalukdar

Correct, we do not officially support pre-releases for C#.

hvitved avatar Oct 04 '21 08:10 hvitved

.NET 6 is now officially released.

dongle-the-gadget avatar Nov 09 '21 00:11 dongle-the-gadget

Similar to https://github.com/github/codeql-action/issues/244#issuecomment-725121467

Add a global.json file to your project with

{
  "sdk": {
    "version": "6.0.100",
    "rollForward": "latestMajor"
  }
}

Tested and working on my .NET 6 project over at https://github.com/Reelix/Reecon

Reelix avatar Nov 10 '21 22:11 Reelix

Similar to #244 (comment)

Add a global.json file to your project with

{
  "sdk": {
    "version": "6.0.100",
    "rollForward": "latestMajor"
  }
}

Tested and working on my .NET 6 project over at https://github.com/Reelix/Reecon

Thanks for the workaround. Works for my project, as well.

khaneliman avatar Nov 11 '21 14:11 khaneliman

I added a "Set up .NET" step with .NET version 6 before Autobuild and it also works.

dongle-the-gadget avatar Nov 12 '21 02:11 dongle-the-gadget

I added a "Set up .NET" step with .NET version 6 before Autobuild and it also works.

For people who may stumble upon this and not really know what this means, you can add the following to your .yml file as one of the steps in the job. I added this just before the "Initialize CodeQL" step.

    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0'
        include-prerelease: True

Doug-Murphy avatar Nov 24 '21 03:11 Doug-Murphy

I added a "Set up .NET" step with .NET version 6 before Autobuild and it also works.

For people who may stumble upon this and not really know what this means, you can add the following to your .yml file as one of the steps in the job. I added this just before the "Initialize CodeQL" step.

    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0'
        include-prerelease: True

You don't need to include prerelease if you don't need .NET 6 Preview builds.

dongle-the-gadget avatar Nov 24 '21 05:11 dongle-the-gadget

To add some information to people coming to this thread, I suppose the official support matrix is at https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks/ and it does not include .NET 6 yet.

I checked at https://github.com/lumoin/Verifiable/runs/4308854222?check_suite_focus=true#step:12:92 and got

Error: No code found during the build.

which started after updating to .NET 6 and C# 10. I have not tried add global.json but I take from this thread it would work.

There is setup actions/setup-dotnet@v1 for .NET 6 at https://github.com/lumoin/Verifiable/blob/main/.github/workflows/main.yml#L105.

veikkoeeva avatar Nov 24 '21 07:11 veikkoeeva

To add some information to people coming to this thread, I suppose the official support matrix is at https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks/ and it does not include .NET 6 yet.

I checked at https://github.com/lumoin/Verifiable/runs/4308854222?check_suite_focus=true#step:12:92 and got

Error: No code found during the build.

which started after updating to .NET 6 and C# 10. I have not tried add global.json but I take from this thread it would work.

There is setup actions/setup-dotnet@v1 for .NET 6 at https://github.com/lumoin/Verifiable/blob/main/.github/workflows/main.yml#L105.

This might not work if you don't use autobuild.

dongle-the-gadget avatar Nov 24 '21 08:11 dongle-the-gadget

This might not work if you don't use autobuild.

Ah, thanks! This could be a useful piece of information. I have not thought about using autobuild, not even adding global.json but just waiting for the .NET 6 support to appear.

veikkoeeva avatar Nov 24 '21 09:11 veikkoeeva

This might not work if you don't use autobuild.

Ah, thanks! This could be a useful piece of information. I have not thought about using autobuild, not even adding global.json but just waiting for the .NET 6 support to appear.

You could see an example here: https://raw.githubusercontent.com/RanTodd-Team/RanTodd/master/.github/workflows/codeql-analysis.yml

dongle-the-gadget avatar Nov 25 '21 01:11 dongle-the-gadget

Is there any update on this @hvitved? .NET 6 has been out for 2 months now, and since it's an LTS release, support is especially important.

samuel-lucas6 avatar Jan 08 '22 21:01 samuel-lucas6

Is there any update on this @hvitved? .NET 6 has been out for 2 months now, and since it's an LTS release, support is especially important.

@samuel-lucas6 Updating global.json and the yml file as described in the comments above has fixed the issue for me for all of my .NET 6.0 projects. Check out https://github.com/pmachapman/GoTo.Bible/commit/94907205e86184a92f350e1d596908b8dc65de7e to see this in action.

pmachapman avatar Jan 09 '22 19:01 pmachapman

@samuel-lucas6 Updating global.json and the yml file as described in the comments above has fixed the issue for me for all of my .NET 6.0 projects. Check out pmachapman/GoTo.Bible@9490720 to see this in action.

Thank you for the tip, but I've already had to implement the fix for one of my projects; I'm just trying to bring attention to this issue again since the last message was back in November and .NET 6 should be supported without any tweaks by now.

samuel-lucas6 avatar Jan 10 '22 08:01 samuel-lucas6

We updated the C# extractor back in December to use the latest version of Microsoft.CodeAnalysis.CSharp (Roslyn), which means that we will be able to partially support C# 10 code bases (full support is scheduled for implementation this quarter). This means that projects built with C# 10 / .NET 6 should work at least partially.

The workarounds in this thread seem to be about the Actions workers not having .NET 6 installed by default, which appears to still be needed, at least when using ubuntu-latest.

hvitved avatar Jan 10 '22 13:01 hvitved

I have added a request for ubuntu-latest to include .NET 6 here: https://github.com/actions/virtual-environments/issues/4851.

hvitved avatar Jan 10 '22 13:01 hvitved

I have added a request for ubuntu-latest to include .NET 6 here: actions/virtual-environments#4851.

Many thanks @hvitved!

samuel-lucas6 avatar Jan 10 '22 13:01 samuel-lucas6

I was trying to update my .NET Core project to 6.0. Seems still need workarounds now It's worked for me but still wonder if need workarounds now? or already have an official solution?

I added a "Set up .NET" step with .NET version 6 before Autobuild and it also works.

For people who may stumble upon this and not really know what this means, you can add the following to your .yml file as one of the steps in the job. I added this just before the "Initialize CodeQL" step.

    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0'
        include-prerelease: True

marsen avatar Feb 02 '22 14:02 marsen