DacFx icon indicating copy to clipboard operation
DacFx copied to clipboard

Builds NEWER than 1.0.0-rc1 cause error when building on localhost

Open EikiEgilz666 opened this issue 3 months ago • 10 comments

  • SqlPackage or DacFx Version:
  • .NET Framework (Windows-only) or .NET Core: .Net standard 2.1
  • Environment (local platform and source/target platforms): localhost using Vs2022

Steps to Reproduce:

  1. Create a new database project using NEWER than 1.0.0-rc1 - this is the latest version, where dotnet restore works
  2. Then you'll see these errors ( we have 4 db projects in this particular solution ):
  3. The only way to make newer versions than 1.0.0-rc1 work, is to do dotnet restore on the commandline! It will not work building the solution inside Vs2022 because of this error. 1.0.0-rc1 is the only version that supports SDK style db projects and build inside Vs2022. Later versions need you to enter commandline/powershell and do dotnet restore there!
Image
  1. Both these versions break it: <Sdk Name="Microsoft.Build.Sql" Version="2.0.0-preview.4" /> and <Project Sdk="Microsoft.Build.Sql/2.0.0">

Did this occur in prior versions? If not - which version(s) did it work in? It works with 1.0.0-rc1 since that does dotnet restore

here's an example of the db project file:

<Project Sdk="Microsoft.Build.Sql/2.0.0"> <PropertyGroup> <TargetFramework>net9.0</TargetFramework> <Name>IsIT.Identity.XXXXXXX.Database</Name> <ProjectGuid>{346efe49-50cd-4887-bd47-03ede534d875}</ProjectGuid>

<!-- Target SQL Server 2019 -->
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider</DSP>

<ModelCollation>1039,CI</ModelCollation>
<DefaultCollation>Icelandic_CI_AS</DefaultCollation>
<DefaultFilegroup>Data1</DefaultFilegroup>
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>

<IncludeCompositeObjects>true</IncludeCompositeObjects>
<DeployToDatabase>true</DeployToDatabase>
<TargetDatabaseSet>true</TargetDatabaseSet>

<!-- 👇 Required to avoid duplicate Build items -->
<EnableDefaultSqlItems>false</EnableDefaultSqlItems>

<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<OutputType>Database</OutputType>
Always PreserveNewest

(DacFx/SqlPackage/SSMS/Azure Data Studio)

EikiEgilz666 avatar Nov 03 '25 12:11 EikiEgilz666

@EikiEgilz666 Could you please share the full contents of your .csproj with proper formatting?

ErikEJ avatar Nov 03 '25 12:11 ErikEJ

It's not pasting properly for some reason so I'll upload a screenshot of it

It's here:

Image

EikiEgilz666 avatar Nov 03 '25 12:11 EikiEgilz666

Dont think you need the explicit folder and wildcard includes - main idea of the new project format is to avoid specifying this.

ErikEJ avatar Nov 03 '25 12:11 ErikEJ

OK, please give me a clean file you think that will work - I'll try it

The main issue is that we have to run dotnet restore on the commandline if we use anything newer than 1.0.0-rc1

And I also don't want to install this, since it's in preview:

Image

If we use a later version than 1.0.0-rc1 and DO NOT run a dotnet restore on the commandline, before trying to build the DB project in Vs2022 we get these kinds of errors:

Image

We want to be able to build using only Vs2022, not having to go to the commandline first to run a dotnet restore

EikiEgilz666 avatar Nov 03 '25 12:11 EikiEgilz666

We've been able to use Vs2022 IDE to go to File -> New Project -> Sql Project

After that we manually change it to SDK Style and that just works, using 1.0.0-rc1 since that DOES the dotnet restore inside Vs2022

Packages newer than that version, you have to run the dotnet restore on the commandline, why is that?

Is there no version inside Vs2022 which can use the IDE Wizard to create the project and simply build it ? Using SDK style ( since our build servers run Linux but our local machines use Windows and Vs2022 ) - without installing any additional templates on the commandline into Vs2022 ?

I could give the latest version of what you mention a try, https://github.com/rr-wfm/MSBuild.Sdk.SqlProj - I guess it doesn't come with Vs2022 nor Vs2026, so we have to manually install the templates on the machines of our developers?

EikiEgilz666 avatar Nov 03 '25 13:11 EikiEgilz666

Packages newer than that version, you have to run the dotnet restore on the commandline, why is that?

You need the SDK Style proview support

ErikEJ avatar Nov 03 '25 13:11 ErikEJ

I did try installing the preview support last week, but then I was getting this error - right out of the box:

Image

so I had to do a dotnet restore on the commandline, and after that Vs2022 was able to do the build ( since the dotnet restore had already be run on the commandline ) - is that the current status this is in or should I be able to run directly from Vs2022 right out of the box after installing the preview ?

I think the preview uses 1.0.0-rc1 when you do file -> new project -> sql project .... right ? But using SDK style, sure. But really old version of the 1.0.0-rc

Could you maybe discuss this on Microsoft Teams directly with me ?

EikiEgilz666 avatar Nov 03 '25 13:11 EikiEgilz666

Hi again @ErikEJ

Why did you delete your comments on this thread?

We're still waiting for a PROPER support in both Vs2022 and Vs2026 with SDK Style DB projects, same as people in this thread as well: https://www.reddit.com/r/dotnet/comments/1or38qm/comment/nnqsfun/?context=3

We want to be able to use newer versions than '1.0.0-rc1' and still be able to build in Vs2022, without having to manually run dotnet restore on the commandline first. Can anybody tell us the status on that issue?

Here are the comments - why did you delete them, where you are recommending the 'SQL Database Project Power Tools' ?

Of course it would be best to get native support inside Vs2022 and Vs2026 without needing to install any extra extensions or preview features!

**** Can somebody please update us on the status for this? **** @llali, @ErikEJ

We want to move away from SSDT projects and over the SDK DB Projects, where we can actually build inside Vs2022 on Windows11 and not having to rely on extensions or preview features.


ErikEJ left a comment (microsoft/DacFx#714) @EikiEgilz666 OK, so if you do not install the SDK style preview, Visual Studio builds will most likely not work.

Also, SDK style projects do not work in VS 2026.

I can recommend https://github.com/rr-wfm/MSBuild.Sdk.SqlProj - build without any issues in both VS 2022 and VS 2026. (Full disclosure: I am a maintainer)

and also


ErikEJ left a comment (microsoft/DacFx#714) @EikiEgilz666 No need for manually anything - just install this extension to get all the benefits:

https://erikej.github.io/dotnet/dacfx/sqlserver/visualstudio/2025/09/30/sqlproj-power-tools-visualstudio.html

EikiEgilz666 avatar Nov 11 '25 12:11 EikiEgilz666

Here's a thread on this at Microsoft: https://developercommunity.visualstudio.com/t/Visual-Studio-2026-Insider-still-using-o/10965461

EikiEgilz666 avatar Nov 11 '25 13:11 EikiEgilz666

Likely Erik deleted his comments because he was worried MS would be upset with the fact that he has offered, for literally years and basically alone, a working .NET SQL SDK while Microsoft, a multi-billion-dollar cap company with tens of thousands of employees, is incapable of providing anything approaching the same functionality.

Man, I miss the days when Microsoft was actually led by engineers, not hedge fund managers.

IanKemp avatar Dec 04 '25 09:12 IanKemp