DacFx: Unable to build in VS - Visual Studio support for Microsoft.Build.Sql
- SqlPackage or DacFx Version: 161
- .NET Framework (Windows-only) or .NET Core: Windows
- Environment (local platform and source/target platforms):
Steps to Reproduce:
- Attempt to load/build a new sqlproj based on template 0.1.7
- Load fails
- adding this enables the build:
<TargetDatabaseSet>True</TargetDatabaseSet>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile />
<ProjectGuid>{f1ee546e-2489-4a7b-9d69-7e2849143721}</ProjectGuid>
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 18
- Comments: 22 (8 by maintainers)
Preview support for the Microsoft.Build.Sql SDK is landing in Visual Studio soon - will update ya’ll as soon as the first release goes out the door!
Support for Microsoft.Build.Sql sqlprojects is planned for future Visual Studio (SSDT) releases. Reopening this item until it is shipped
With Visual Studio 17.12 preview 2 - support for Microsoft.Build.Sql SDK-style projects is now available in preview for Visual Studio.
2 key limitations to note:
.sqlprojxinstead of.sqlprojblog: https://techcommunity.microsoft.com/t5/azure-sql-blog/preview-release-of-sdk-style-sql-projects-in-visual-studio-2022/ba-p/4240616
docs: https://aka.ms/ssdt-sdk-preview
Sharing what my customized .sqproj file ended up being for others who come across this thread while trying to troubleshoot new use of this project sdk:
When will have support for SDK-style projects in Visual Studio? It seems like an easy-to-do feature that would be very useful for many of us, but seems to be delayed for more than a year already.
I had a similar issue, and I was able to resolve this by deleting the obj folder for my project. And so, I set up the project to clean the project and to delete the obj folder before clean. It’s still a work in progress, but I landed on the code below to both build in Visual Studio 2022 and via the dotnet cli. The dotnet cli seems to build just fine without deleting the obj folder, but it wasn’t deleting the folder, so I just added ContinueOnError=“True”.
Edited code since Visual Studio 2022 didn’t seem to output the dacpac.
I had a typo in my previous comment and edited. We do have a future enhancement for the VS to support SDK style projects and will support that in future.
Working example for 1.19-preview with vs2022 17.10.2 (Community Edition)
When I try to build in visual studio after building in AzureDataSudio I get this error: “Error: : Your project does not reference “.NETFramework,Version=v4.8.1” framework. Add a reference to “.NETFramework,Version=v4.8” in the “TargetFrameworks” property of your project file and then re-run NuGet restore.”
If I delete the project.assets.json file from the obj folder then it will build fine.
Found there is this already:
<Target Name="BeforeBuild"> <Delete Files="$(BaseIntermediateOutputPath)\project.assets.json" /> </Target>But it doesn’t work for me had to switch to:
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> <Delete Files="$(SolutionDir)$(ProjectName)\obj\project.assets.json" /> </Target>I used just $(ProjectDir) to start with - this builds in visual studio but failed more often than not in Azure Data Studio with "C:\Program Files\dotnet\sdk\7.0.400\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(321,5): error MSB4018: The “GetProjectReferencesFromAssetsFileTask” task failed unexpectedly. "
Using the SolutionDir instead makes the path *Undefined* in AzureDataStudio
Yes, as the title of the issue states this is about building in VS. Its all fine that you can build in limited cross platform tooling but the circle is not complete until you can build in VS and get the intellisense and table editing experience.
@Real-JD-UK you are not using the latest SDK version