dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.74k stars 1.07k forks source link

dotnet core3.1/dotnet5.0 build sqlproj #16587

Open alexirion10 opened 3 years ago

alexirion10 commented 3 years ago

Similar to https://github.com/dotnet/sdk/issues/10441 & https://github.com/dotnet/sdk/issues/8546

All .sqlproj files are msbuild project type ie: <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

As opposed to the new style SDK ie: <Project Sdk="Microsoft.NET.Sdk">

--> A dotnet core 3.x, C# code application, is not able to build a sqlproj msbuild project. Example:

Project p = new Project("C:\\Users\<myself>\\my-cool-sql-app.sqlproj");
p.Build();

--> Results in: Microsoft.Build.Exceptions.InvalidProjectFileException: 'The imported project "C:\Program Files\dotnet\sdk\2.1.522\Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk

Can I otherwise instruct a dotnet application to use msbuild located elsewhere? Will SQL Server Database projects become an SDK type project? Or will dotnet be able to build non-SDK type projects?

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

marcpopMSFT commented 3 years ago

sqlproj targets are not supported in the .NET SDK which is used when targeting .net core. This may work if you retarget your application to net framework as that should use the net framework version of MSBuild.

marcpopMSFT commented 3 years ago

And to your other questions, there are not plans for SDK support for sqlproj files in the short term.

rajeshaz09 commented 3 years ago

.NET 5 released 6 months back and .NET 6 is going to release in 6 months, but no support of SQLPROJ?

hartmark commented 3 years ago

+1 I'd also like to know if sqlproj would be handled by dotnet, as it is now I need to have my sqlprojects separated from the rest of the code base as I cannot run "dotnet test" for example without doing some magic

Denny966 commented 3 years ago

Bump

Scorito-Dev commented 3 years ago

bump

spencer741 commented 3 years ago

bump

larstbone commented 3 years ago

Our SSDT project belongs in our solution. "dotnet build" should not fail when coming across an SSDT project, it should just ignore it.

KalleOlaviNiemitalo commented 3 years ago

If you just want the projects to be ignored by MSBuild of .NET SDK, then perhaps you can add Condition='"$(MSBuildRuntimeType)" != "Core"' to the Import elements… except then you'd also have to define the Test etc. targets yourself. I wonder if there is a way to reuse Microsoft.Build.NoTargets for that. The Sdk element does not allow a Condition attribute, but if you instead used <Import Project="Sdk.props" Sdk="Microsoft.Build.NoTargets" Condition='"$(MSBuildRuntimeType)" == "Core"' /> at the top and a similar element with "Sdk.targets" at the bottom, then that might work.

rajeshaz09 commented 3 years ago

Microsoft is doing good work but now a days mostly half baked stuff. Not only this issue, other areas as well similar pattern. Ex: publish single EXE (Dotnet team claiming that they are supporting but not WPF projects)

Microsoft is promoting .NET 5 (now .NET 6) as upgrade path from .NET framework 4.8/.NET core 3.1. When comes to SqlProj projects, you decided that not to support in .NET 5/6/7 near future. But what is the alternative? Please don't say use full framework. We can't use half projects .NET framework and half projects .NET5/6/7.

ahdung commented 2 years ago

WE NEED Microsoft.Net.Sdk.Sql

mikelneo commented 2 years ago

It's interesting to understand .sqlproj destiny. If this kind of project will not have support in .NetCore, I guess it's time to replace it with some other approach (but what?). EF migrations is not always an alternative to .sqlproj (especially when we don't use EF as ORM). Now I'm using MSBuild.Sdk.SqlProj to build .sqlproj with dotnet sdk, but I'm also not sure about future of this project.

ahdung commented 2 years ago

@marcpopMSFT while sqlclr alive, sqlproj should alive too, you ms guys shouldn't give up on it.

marcpopMSFT commented 2 years ago

Including @baronfel for visibility on this ask.

holytshirt commented 2 years ago

A preview has been released https://github.com/microsoft/DacFx/tree/main/src/Microsoft.Build.Sql

<Sdk Name="Microsoft.Build.Sql" Version="0.1.3-preview" />
hartmark commented 2 years ago

Nice to have some progress