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

SQL projects target .NET framework even when configured for net9.0 only #562

Open
tobymiller opened this issue Feb 8, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@tobymiller
Copy link

  • SqlPackage or DacFx Version: 1.0.0-rc1
  • .NET Framework (Windows-only) or .NET Core: net9.0 (but seems to apply to any recent target framework)
  • Environment (local platform and source/target platforms): Mac (ARM)

Steps to Reproduce:

  1. dotnet new sqlproj -n TestSqlProject (1.0.0-rc1)
  2. dotnet new classlib -n TestLib (net9.0)
  3. Edit TestSqlProject.sqlproj:
    a. Add <TargetFramework>net9.0</TargetFramework>
    b. Add an item group with <ProjectReference Include="../TestLib/TestLib.csproj" />
  4. dotnet build in TestSqlProj

I would expect this to build, as a net9.0 project is referencing another net9.0 project. Instead I get this:

TestSqlProject failed with 2 error(s) (0.0s)
    /usr/local/share/dotnet/sdk/9.0.101/Microsoft.Common.CurrentVersion.targets(1889,5): error : Project '../TestLib/TestLib.csproj' targets 'net9.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6'.
    /usr/local/share/dotnet/sdk/9.0.101/Microsoft.Common.CurrentVersion.targets(1889,5): error : Project '../TestLib/TestLib.csproj' targets 'net9.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6'.

If TestLib is changed to target netstandard1.0 (and some incompatible directives removed) then they both build fine. This suggests that it is generally valid for a SQL project to reference a C# library. But no matter what I do I can't get the SQL project to stop targeting .NET framework. Am I missing something obvious?

@tobymiller tobymiller added the bug Something isn't working label Feb 8, 2025
@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 8, 2025

Why would you reference another C# project??

@tobymiller
Copy link
Author

As it happens I'm trying to load an NUnit engine extension so the SQL project (using tSQLt) will be interpreted as a unit test project. I don't know whether that's possible the way I'm trying to do it, but regardless it seems strange that there's anything to do with .NET framework here.

In #330 the .NET framework was appearing for no reason, but I believe it was fixed. Has there been a regression?

@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 8, 2025

It sounds like an unsupported scenario.
FWIW, MsBuild.Sdk.SqlProj allegedly works with tSQLt.

@tobymiller
Copy link
Author

It's definitely reasonable that it's unsupported, but as far as I can see the SQL project is insisting on targeting .NET framework despite configuration to the contrary. There are other implications of this.

For example, when putting the dependencies the other way round (importing the SQL project into a C# project, which I imagine is supported) there's a warning about having resolved the dependency using the .NET framework.

Also even with no C# projects involved at all, the project.assets.json for the SQL project is full of .NET framework stuff.

@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 8, 2025

Interestingly, MsBuld.Sdk.Sqlproj targets netstandard2.1

@tobymiller
Copy link
Author

It's odd right? I can't see where net46 is coming from at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants