Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dotnet build issue with system database reference. #83

Closed
DavidWiseman opened this issue Mar 8, 2022 · 13 comments
Closed

Dotnet build issue with system database reference. #83

DavidWiseman opened this issue Mar 8, 2022 · 13 comments
Assignees
Labels
area: build sdk Related to Microsoft.Build.Sql SDK bug Something isn't working

Comments

@DavidWiseman
Copy link

  • SqlPackage or DacFx Version:0.1.3-preview
  • .NET Framework (Windows-only) or .NET Core:.NET Core
  • Environment (local platform and source/target platforms): Windows

Steps to Reproduce:

  1. Create a new database project in Visual Studio
  2. Follow instructions in this blog to get build working with dotnet build. https://erikej.github.io/ssdt/dotnet/2022/03/07/ssdt-dacpac-netcore.html
  3. Build should work at this point. dotnet build /p:NetCoreBuild=true
  4. Add a reference to the "master" system database in Visual Studio. This creates the following XML:
<ItemGroup>
    <ArtifactReference Include="$(DacPacRootPath)\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas\master.dacpac">
      <HintPath>$(DacPacRootPath)\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas\master.dacpac</HintPath>
      <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors>
      <DatabaseVariableLiteralValue>master</DatabaseVariableLiteralValue>
    </ArtifactReference>
  </ItemGroup>
  1. Build will now fail. dotnet build /p:NetCoreBuild=true

C:\Users\user1\.nuget\packages\microsoft.build.sql\0.1.3-preview\tools\netstandard2.1\Microsoft.Data.Tools.Schema.SqlTasks.targets(525,5): Build error SQL72027: File "C:\Users\user1\.nuget\packages\microsoft.build.sql\0.1.3-preview\tools\netstandard2.1\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas\master.dacpac" does not exist. [c:\Git\TrimbleOSS\dba-dash\Database1\Database1.sqlproj]

Did this occur in prior versions? If not - which version(s) did it work in?

Not applicable to prior version

@DavidWiseman DavidWiseman added the bug Something isn't working label Mar 8, 2022
@kisantia
Copy link
Contributor

kisantia commented Mar 9, 2022

@DavidWiseman Thanks for trying out the MIcrosoft.Build.Sql SDK and reporting this! I added this error to the ReadMe. $(DacPacRootPath) is a variable with the location of the system dacpacs that SSDT passes in when building a project, so when building from the command line, that will need to be passed in like /p:DacPacRootPath="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE".

There's currently support for SDK-style sql projects in the Azure Data Studio insiders build with the sql database projects extension installed. Creating new SDK-style projects(empty and from a database), adding system database references, and building SDK-style projects are already supported in ADS if you're interested in trying it out.

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 9, 2022

@kisantia
Do you get the good table designer experience in ADS?
Do you get model validation with Intellisense in ADS?

@kisantia
Copy link
Contributor

kisantia commented Mar 9, 2022

Table designer is in preview in the latest ADS release and integration with sql projects is coming in the future. Model validation is not currently available in ADS.

@DavidWiseman
Copy link
Author

Hi. Thank you for the quick reply to my issue - sorry it's taken a while to respond back. Passing the correct path from the commandline fixes the issue. 😊
I'm mostly interested in getting the project to build with dotnet build over msbuild so I can create a dacpac with a linux runner github action. I can then run SQL Server on docker and have some automated tests run. I guess my new problem might be where to point to for the system dacpacs on the github runner.

Thanks,

David

@dzsquared
Copy link
Contributor

@kisantia Kim Santiago FTE Do you get the good table designer experience in ADS? Do you get model validation with Intellisense in ADS?

@ErikEJ to be clear, this wasn't to suggest that Visual won't get support for the SDK-style project file, but currently an optional workaround is to use Azure Data Studio insiders (or the command line option shared above).

@davidcorbin-atmosera
Copy link

Been spinning my wheels trying to create a dacpac i the context of a GitHub (Linux) runner ... I have Azure Data Studio with the latest Extension for using packages.... Is there a clean sample? [for example, anything that brings up ("C:\Program Files..." is clearly not intended for Ubuntu...

note: A Microsoft supported Extension on the GitHub Market Place for this would be IDEAL <>

@dzsquared
Copy link
Contributor

@dcorbin-wintellect we're working on https://github.com/azure/sql-action, which has limited support for SDK-style project build (+deploy). At the moment the build support is in combination with deployment, but there are certainly scenarios where someone would want to hold off on deployment.

@DavidWiseman
Copy link
Author

Thank you. It's not quite what I'm looking for but could be useful for some other stuff👍
What I'm interested in -
I want to build the database project on github linux runner. It would need to handle the system dacpac reference.
In terms of deployment - I'm interested in deploying to a SQL instance running on docker on the github runner for testing. My app will take care of the deployment - I just need to build the dacpac.

@dzsquared
Copy link
Contributor

dzsquared commented Mar 23, 2022

I see you opened an issue there - thank you! Will continue to discuss there 😄

edit: oh boy, I have not had enough coffee yet.
The GH action I linked does support Linux, but needs a docs update to specify this.
I'll open issues to call out only building a dacpac + handling system dacpac references.

@dzsquared dzsquared added the area: build sdk Related to Microsoft.Build.Sql SDK label Aug 26, 2022
@zijchen
Copy link
Member

zijchen commented Feb 15, 2023

We just released 3 system dacpac Nuget packages that can be referenced via PackageReference from projects built with Microsoft.Build.Sql 0.1.9-preview and up. Example:

<PackageReference Include="Microsoft.SqlServer.Dacpacs" Version="160.0.0" />

Available packages are:

You can read more about it here: https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/sql-database-project-extension-sdk-style-projects?view=sql-server-ver16#package-references

@uladz-zubrycki
Copy link

@zijchen I see that it's possible to specify a name of the dacpac to import via <DacpacName> child node. I'm wondering whether it's going to import both master and msdb, if there is no <DacpacName> specified.

Asking, since I'm not able to fix the warning SqlProcedure: has an unresolved reference to object [msdb].[dbo].[sp_send_dbmail].[@body]. in my builds.

@zijchen
Copy link
Member

zijchen commented Mar 30, 2023

@uladz-zubrycki When no DacpacName is specified the master is used by default. There is no easy way to import both master and msdb currently. One way is to add PackageReference to master and then manually add an ArtifactReference to msdb:

<ItemGroup>
  <PackageReference Include="Microsoft.SqlServer.Dacpacs">
    <GeneratePathProperty>true</GeneratePathProperty>
    <DacpacName>master</DacpacName>
  </PackageReference>
  <ArtifactReference Include="$(PkgMicrosoft_SqlServer_Dacpacs)/tools/msdb.dacpac">
    <DatabaseVariableLiteralValue>msdb</DatabaseVariableLiteralValue>
  </ArtifactReference>
</ItemGroup>

@uladz-zubrycki
Copy link

@zijchen Thank you! Incredibly helpful. Will give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build sdk Related to Microsoft.Build.Sql SDK bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants