Skip to content

C# Autobuild misidentifies incompatible SDK-style projects #19258

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

Closed
Arthri opened this issue Apr 9, 2025 · 4 comments
Closed

C# Autobuild misidentifies incompatible SDK-style projects #19258

Arthri opened this issue Apr 9, 2025 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@Arthri
Copy link

Arthri commented Apr 9, 2025

Given the following csproj,

<Project>
  <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>

Autobuild only looks at the root <Project> node and sees that it does not have an Sdk attribute, and subsequently incorrectly identifying that it is not compatible and switches to building using Mono. This way of writing SDK-style projects, specifically using <Import /> explicitly, is documented here https://learn.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2022#use-the-import-element-anywhere-in-your-project

I believe that the code which identifies whether a project is compatible is located here
https://github.com/github/codeql/blob/main/csharp/autobuilder/Semmle.Autobuild.Shared/Project.cs#L50

I have set up a repository which reproduces this issue https://github.com/Arthri/NonStdSdkAutobuild/

@Arthri Arthri added the question Further information is requested label Apr 9, 2025
@Arthri Arthri changed the title C# Autobuild improperly identifies compatible SDK-style projects C# Autobuild misidentifies incompatible SDK-style projects Apr 9, 2025
@michaelnebel
Copy link
Contributor

Thank you for reporting this! And thank you for the entry points - this is much appreciated!
I will look into this!

@michaelnebel michaelnebel self-assigned this Apr 11, 2025
@michaelnebel
Copy link
Contributor

Issue will be fixed here: #19289

@michaelnebel
Copy link
Contributor

PR merged.

@Arthri
Copy link
Author

Arthri commented Apr 14, 2025

Thank you for looking into the issue and fixing it!

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

No branches or pull requests

2 participants