question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use NetCoreBuild in .sqlproj

See original GitHub issue
  • SqlPackage or DacFx Version:
  • .NET Framework (Windows-only) or .NET Core:
  • Environment (local platform and source/target platforms):

Steps to Reproduce:

Convert a VS .sqplproj to SDK build.

Follow this from the readme (adding it to the first “PropertyGroup”)

In Visual Studio, .NET Core targets can be used by default. Add this property to the sqlproj:

<NetCoreBuild>True</NetCoreBuild>

Excpected: project builds

Actual:

Severity Code Description Project File Line Suppression State Error Your project file doesn’t list ‘win’ as a “RuntimeIdentifier”. You should add ‘win’ to the “RuntimeIdentifiers” property in your project file and then re-run NuGet restore. Database C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\NuGet\17.0\Microsoft.NuGet.targets 198

After manually deleting the bin and obj folders, I now get this error:

Severity Code Description Project File Line Suppression State Error 04062: The “SqlModelResolutionTask” task could not be loaded from the assembly C:\Users\Erik.nuget\packages\microsoft.build.sql\0.1.3-preview\Sdk..\tools\netstandard2.1\Microsoft.Data.Tools.Schema.Tasks.Sql.dll. Could not load file or assembly ‘netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. Database C:\Users\Erik.nuget\packages\microsoft.build.sql\0.1.3-preview\tools\netstandard2.1\Microsoft.Data.Tools.Schema.SqlTasks.targets 443

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pvanhoutencommented, May 14, 2022

Unfortunately, dotnet build doesn’t work for me without specifying -p:NetCoreBuild=true as an argument. It fails with error MSB4019. Long story short, in my project, I don’t have the ability to add that argument to dotnet build and it needs to be embedded in the sqlproj file. Adding those conditions to that property allows me to use both VS and dotnet build without having to add that argument.

1reaction
pvanhoutencommented, May 13, 2022

@ErikEJ I was able to add the following properties into my sqlproj file to build both in VS as well as dotnet cli. Haven’t tried SSDT:

    <NetCoreBuild Condition="'$(MSBuildRuntimeType)' != 'Core'">False</NetCoreBuild>
    <NetCoreBuild Condition="'$(MSBuildRuntimeType)' == 'Core'">True</NetCoreBuild>

I haven’t tested extensively, so YMMV.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to build .sqlproj projects using "dotnet" tool?
It's by design that dotnet cli can't build the Database Project with old-framework ... dotnet build "sqlproj file path" /p:NetCoreBuild=true ...
Read more >
Make your SQL Server Database project (.sqlproj) build ...
In this post, I will describe how a new Microsoft build SDK (currently in preview) allows you to do the same, while preserving...
Read more >
Command-line build failing due to missing targets in ...
When the build executes - the command-line build fails with the error ... Also updated the Import of .targets to check '$(NetCoreBuild)'
Read more >
dotnet build sqlproj - Developer Community
I'm trying to do CI for solution that contains sqlproj. Command dotnet build and dotnet msbuild doesn't work.
Read more >
Build a Project from the Command Line - Azure Data Studio
The following section describes a work-around for working with non-SDK-style SQL projects from the command line on Windows, macOS, and Linux.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found