microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.57k stars 901 forks source link

Using SQL Database Projects extension version 0.5.1 - Build fails #13955

Closed wknsJimmy closed 2 years ago

wknsJimmy commented 3 years ago

SQL Database Projects extension version: 0.5.1

Steps to Reproduce:

1.Connect to an existing database 2.Use the Create Project from Database option 3.Confirm the scripts for each object exist in the Project folders 4.Right click on the Project name and choose Build

5.Partial Build output window is as follows:

_[ Build ]
> "C:\\Program Files\\dotnet\\dotnet.exe"  build "c:\\Users\\Jimmy_Blacksmith\\source\\repos\\HKTest\\ADSInsideRepo\\SIRDev\\SIRDev.sqlproj" /p:NetCoreBuild=true /p:NETCoreTargetsPath="c:\\Users\\Howard_Kealy\\.azuredatastudio-insiders\\extensions\\microsoft.sql-database-projects-0.5.1\\BuildDirectory"
stdout: Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
stdout: Copyright (C) Microsoft Corporation. All rights reserved.
stdout: 
stdout: 
stdout:   Restore completed in 22.15 ms for c:\Users\Jimmy_Blacksmith\source\repos\HKTest\ADSInsideRepo\SIRDev\SIRDev.sqlproj.
stdout: 
stdout:   Creating a model to represent the project...
stdout: 
stdout: c:\Users\Jimmy_Blacksmith\.azuredatastudio-insiders\extensions\microsoft.sql-database-projects-0.5.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: The "SqlBuildTask" task failed unexpectedly. [c:\Users\Jimmy_Blacksmith\source\repos\HKTest\ADSInsideRepo\SIRDev\SIRDev.sqlproj]
stdout: c:\Users\Jimmy_Blacksmith\.azuredatastudio-insiders\extensions\microsoft.sql-database-projects-0.5.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: System.TypeInitializationException: The type initializer for 'SqlSchemaModelStaticState' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [c:\Users\Jimmy_Blacksmith\source\repos\HKTest\ADSInsideRepo\SIRDev\SIRDev.sqlproj]_
  1. Clicking on the link to the "Not found" file says "Unable to resolve non-existing file 'c:\Users\Jimmy_Blacksmith\source\repos\HKTest\ADSInsideRepo\SIRDev\SIRDev.sqlproj]' Note the closing square bracket

  2. Confirmed that the .sqlproj file does actually exist in that location

udeeshagautam commented 3 years ago

@wknsJimmy thanks for reporting. Can you please help us with following answers,

  1. does the same project build fine in SSDT?
  2. does the project build in ADS stable december release?
  3. which dotnet SDK version is installed on the box (at C:\Program Files\dotnet\ location)
wknsJimmy commented 3 years ago
  1. Not using SSDT – we are moving from using SSMS in order to use Database Projects in order to use Source control plus Azure DevOps to Build, Test and Deploy our solutions (Azure Data Factory, Azure SQL database, Azure Analysis Services and Power BI reports) – we chose to skip SSDT and go straight to ADS. Give me some time and I will check out if I have an issue with SSDT and get back to you.
    1. No. I got the same error message in the ADS stable December release – so I then went to the Insider release

3. [cid:image003.png@01D6EA06.79E25DF0]

From: Udeesha Gautam notifications@github.com Sent: Wednesday 13 January 2021 23:22 To: microsoft/azuredatastudio azuredatastudio@noreply.github.com Cc: Kealy, Howard (Naas) Howard.Kealy@sgs.com; Mention mention@noreply.github.com Subject: [EXTERNAL] Re: [microsoft/azuredatastudio] Using SQL Database Projects extension version 0.5.1 - Build fails (#13955)

WARNING: this message is from an EXTERNAL SENDER. Please be cautious, particularly with links and attachments.


@wknsJimmyhttps://github.com/wknsJimmy thanks for reporting. Can you please help us with following answers,

  1. does the same project build fine in SSDT?
  2. does the project build in ADS stable december release?
  3. which dotnet SDK version is installed on the box (at C:\Program Files\dotnet\ location)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/microsoft/azuredatastudio/issues/13955#issuecomment-759820716, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASOT5XERPSDYC27AP2G4NTTSZYTH5ANCNFSM4WBN2WUQ.

Information in this email and any attachments is confidential and intended solely for the use of the individual(s) to whom it is addressed or otherwise directed. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the Company. Finally, the recipient should check this email and any attachments for the presence of viruses. The Company accepts no liability for any damage caused by any virus transmitted by this email. All SGS services are rendered in accordance with the applicable SGS conditions of service available on request and accessible at https://www.sgs.com/en/terms-and-conditions

wknsJimmy commented 3 years ago

Just an update to point 1: Yes the project builds in SSDT and I get my dacpac

From: Udeesha Gautam notifications@github.com Sent: Wednesday 13 January 2021 23:22 To: microsoft/azuredatastudio azuredatastudio@noreply.github.com Cc: Kealy, Howard (Naas) Howard.Kealy@sgs.com; Mention mention@noreply.github.com Subject: [EXTERNAL] Re: [microsoft/azuredatastudio] Using SQL Database Projects extension version 0.5.1 - Build fails (#13955)

WARNING: this message is from an EXTERNAL SENDER. Please be cautious, particularly with links and attachments.


@wknsJimmyhttps://github.com/wknsJimmy thanks for reporting. Can you please help us with following answers,

  1. does the same project build fine in SSDT?
  2. does the project build in ADS stable december release?
  3. which dotnet SDK version is installed on the box (at C:\Program Files\dotnet\ location)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/microsoft/azuredatastudio/issues/13955#issuecomment-759820716, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASOT5XERPSDYC27AP2G4NTTSZYTH5ANCNFSM4WBN2WUQ.

Information in this email and any attachments is confidential and intended solely for the use of the individual(s) to whom it is addressed or otherwise directed. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the Company. Finally, the recipient should check this email and any attachments for the presence of viruses. The Company accepts no liability for any damage caused by any virus transmitted by this email. All SGS services are rendered in accordance with the applicable SGS conditions of service available on request and accessible at https://www.sgs.com/en/terms-and-conditions

udeeshagautam commented 3 years ago

@wknsJimmy thanks for the details.

In the above message looks like image you shared for question-3 dotnet version did not come through. Can you please share the dotnet sdk version on your machine again.

I tried reproing this with a few databases on our side but could not get the error so far. Is it possible for you to share the project or just the sqlproj file with us?

kpapaj commented 3 years ago

Looks the same problem in v0.6.1 version of SQL Datababase Project: [ Build ]

"C:\Program Files\dotnet\dotnet.exe" build "c:\TMP\TSQLV5\TSQLV5.sqlproj" /p:NetCoreBuild=true /p:NETCoreTargetsPath="c:\Users\Karol\.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory" stdout: Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core stdout: Copyright (C) Microsoft Corporation. All rights reserved. stdout: stdout: stdout: Restore completed in 54,92 ms for c:\TMP\TSQLV5\TSQLV5.sqlproj. stdout: stdout: Creating a model to represent the project... stdout: stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: The "SqlBuildTask" task failed unexpectedly. [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: System.TypeInitializationException: The type initializer for 'SqlSchemaModelStaticState' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.RegisterImplementationForSqlModelImpl(ModelSchema storeSchema) [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.SqlSchemaModelStaticState.RegisterModelSchema() [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.SqlSchemaModelStaticState..cctor() [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: --- End of inner exception stack trace --- [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel..ctor(SqlDatabaseSchemaProvider databaseSchemaProvider, SqlPlatforms platform, ModelCollation collation, String modelFileName, ErrorManager errorManager, Boolean validationEnabled, Boolean initializeBuiltIns, Boolean validateCasingOnIdentifiers, Boolean convertCrossDbRefToWarning, Boolean isMsdb, ModelStorageType modelStorageType, Boolean storeSourceCodePositionAnnotations) [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModelConstructor.ConstructServiceImplementation() [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Sql.Build.SqlTaskHost.CreateDataSchemaModel() [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Tasks.Sql.TaskHostLoader.LoadImpl(ITaskHost providedHost, TaskLoggingHelper providedLogger) [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Tasks.Sql.TaskHostLoader.Load(ITaskHost providedHost, TaskLoggingHelper providedLogger) [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.ExecuteLoadTaskHostStep() [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.ExecuteStep(Func`1 step) [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.Execute() [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: c:\Users\Karol.azuredatastudio\extensions\microsoft.sql-database-projects-0.6.1\BuildDirectory\Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [c:\TMP\TSQLV5\TSQLV5.sqlproj] stdout: stdout: stdout: Build FAILED.

wknsJimmy commented 3 years ago

@wknsJimmy thanks for the details.

In the above message looks like image you shared for question-3 dotnet version did not come through. Can you please share the dotnet sdk version on your machine again.

I tried reproing this with a few databases on our side but could not get the error so far. Is it possible for you to share the project or just the sqlproj file with us?

@wknsJimmy thanks for the details.

In the above message looks like image you shared for question-3 dotnet version did not come through. Can you please share the dotnet sdk version on your machine again.

I tried reproing this with a few databases on our side but could not get the error so far. Is it possible for you to share the project or just the sqlproj file with us?

The version of dotnet is as follows:

2.1.202 [C:\Program Files\dotnet\sdk] 2.1.403 [C:\Program Files\dotnet\sdk] 2.1.520 [C:\Program Files\dotnet\sdk]

And here is the content of the sqlproj file

<?xml version="1.0" encoding="utf-8"?>

Debug AnyCPU SIRDev 2.0 4.1 {45D9424E-B64C-4488-9036-6D4A512F9979} Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider Database SIRDev SIRDev 1033, CI BySchemaAndSchemaType True v4.5 CS Properties False True True bin\Release\ $(MSBuildProjectName).sql False pdbonly true false true prompt 4 bin\Debug\ $(MSBuildProjectName).sql false true full false true true prompt 4 11.0 True 11.0
wknsJimmy commented 3 years ago

SIRDev.txt

Here is the sqlproj file with the extension changed to txt

supamii commented 3 years ago

@wknsJimmy - I had the same problem you did. Missing System.Runtime is seems fundamentally off.

I had Visual Studio 2017 Pro with dotnet core 2.1 (no other dotnet core runtimes/sdks)


On a hunch I went ahead and installed a more recent version of dotnet core (requires visual studio 2019)

The build feature in Azure Data Studio works now

kpapaj commented 3 years ago

@supamii - I have VS 2017, VS 2019 and .NET SDK 2.1.521 installed, still the problem persists ...

supamii commented 3 years ago

If you're looking to unblock yourself, try to install dotnet3.x

kpapaj commented 3 years ago

Installing dotnet 3.x doesn't help, the same error again.

udeeshagautam commented 3 years ago

Hi @wknsJimmy,

[updating the investigation below]

I was able to repro this using lower 2.x version of dotnet core SDK just now. So it seems the issue is that the machine has a lower version of dotnet SDK. Can you please check that you have dotnet core SDK 3.1 or higher installed and System.Runtime present on the machine

Paths to check

If the folder seems incomplete please install from https://dotnet.microsoft.com/download/dotnet/3.1

I have also opened a tracking item for a better error in these cases. Hopefully that helps.

adriennn commented 2 years ago

I'm seeing a similar error appearing out of the blue after an update to the SQL Database Project extension 0.14.1 (which fixed another bug) with either of the following:

.NET 3.1.416 .NET 6.0.101

ADS: 1.34.0 (user setup)

is there a way to rollback the extension to something before 0.14.1 in order to debug?

edit: the build works fine in VS 2017 edit: installed VS 2019 and try to open the project which threw the same exception as the ADS build but with the crucial addition of telling which file caused the build error. The file in question (sql) has been unchanged throughout previous succesful builds.

Charles-Gagnon commented 2 years ago

@adriennn You can download previous versions of the extension by replacing the ##.##.## with the version you want in this URL : https://sqlopsextensions.blob.core.windows.net/extensions/sql-database-projects/sql-database-projects-##.##.##.vsix

e.g. https://sqlopsextensions.blob.core.windows.net/extensions/sql-database-projects/sql-database-projects-0.14.0.vsix