Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build .sqlproj projects using "dotnet" tool?

Unable to build .Net .sqlproj using "dotnet" command line tool. Here's the error:

dotnet\sdk\3.1.300\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found

I have installed SSDT tool but it's not available at the above location.

Note: It's buildings without any error using Visual Studio and MSBuild

like image 691
Raza Avatar asked May 30 '20 18:05

Raza


People also ask

Is a dot net build tool?

question. Yes, dot Net is a build tool. The command builds the project and also dependencies into a set of binaries. Nant is one of the examples of dot Net built tool which are open source software tool for automating software build processes.

What is Sqlproj in Visual Studio?

Database development project created by Visual Studio, a Windows software development IDE; stores the schema of the database and can include SQL source code; used for creating databases for SQL Server, Microsoft's relational database management system (RDBMS) software. Older .

What is build in dotnet?

Description. The dotnet build command builds the project and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a . dll extension.


3 Answers

Some progress has been made, 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" />
like image 200
holytshirt Avatar answered Oct 22 '22 15:10

holytshirt


As of March 2020 this is now a possibility using the MSBuild.Sdk.SqlProj package. Technically it's not building the sqlproj file itself, but an equivalent version based on a csproj to produce a DACPAC. It currently has some advantages, such as cross-platform builds, and being able to build a whole folder instead of leaving out that one file that you always forget to manually add to the sqlproj. Current disadvantages are a slower build due to no dbmdl caching, and less IDE/tooling support at least for importing changes from an external database or DACPAC into the project source.

like image 30
CrazyPyro Avatar answered Oct 22 '22 15:10

CrazyPyro


How to build .sqlproj projects using “dotnet” tool?

Sorry but as I know this is not supported scenario for now. It's by design that dotnet cli can't build the Database Project with old-framework style project file.

As for the reason why it's buildings without any error using Visual Studio and MSBuild but failing using dotnet. Please check your SSDT installation path, it should be under pathC:\Program Files (x86)\Microsoft Visual Studio\2019\VSEditon\MSBuild\Microsoft\VisualStudio\v16.0\SSDT.

The SSDT is installed as a sub-module of MSBuild(VS build tools) or MSBuild from VS, so it works well when building it via VS/MSbuild. But dotnet cli won't know where to find this module which is under MSBuild folder's sub-folder, so it throws error.

There's once a discussion about this in github, in my opinion the feature to support build SQLProj via Dotnet hasn't come true. If you're interested in that feature, I suggest you can open a new ticket there to post your idea.

like image 8
LoLance Avatar answered Oct 22 '22 15:10

LoLance