The SQL project build output provides feedback on the database model construction and T-SQL validation. The default command line output only shows errors and some status information. In this article, we discuss how to enable more verbose logging to help troubleshoot build issues and common errors that are encountered with SQL projects.
Enable verbose loggingTo further troubleshoot build issues for SQL projects, you can use command line switches to generate more logs. More logging can help in not only identifying the cause of errors but also degradation in build speed. The two primary options are:
Binary logger: This option generates a binary log file (msbuild.binlog
) that can be viewed using the MSBuild Log Viewer. This viewer is helpful for diagnosing dependency issues and optimizing the build process. The command to generate this log is:
dotnet build -bl
File logger: This option generates a text log file that contains the most verbose logging from the build. The command to generate this log is:
dotnet build -flp:v=diag
To recap, the combined command to generate both logs is:
dotnet build -bl -flp:v=diag
The full set of switches can be found at the MSBuild Command-Line Reference.
Common issues Build errorsWhen the build error indicates invalid syntax, the output also specifies which file contains the erroneous code. If you're using syntax that was recently added, you may need to update your project SDK version.â
Build errors from a database project should have SQLxxxxx
error codeâ, where xxxxx
is a five-digit number. Some issues that cause the error for an unresolved reference (SQL71501
/SQL71502
)â are:
[schema].[table].[column]
)âFor an error that occurs during restore, first run a clean build after deleting the /bin
and /obj
folders in the project.
If the error includes SDK 'Microsoft.Build.Sql' specified could not be foundâ
, begin by verifying NuGet package feeds are valid. The base command to view current feeds is:
dotnet nuget list sourceâ
The public NuGet feed is:
dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.orgâ
If your environment requires private feeds, ensure they're valid and accessible. You may be required to authenticate with package feeds. Enabling authentication during project build can be done with:
dotnet build --interactive
For MSBuild, the equivalent command is:
msbuild /p:nugetInteractive=trueâ
For other non-SQL error codes, refer to the following resources:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4