Problem
Opening a solution that contains a 'legacy' non-sdk style .sqlproj, Rider fails to load it. Checking the error on the problems view, it complains MSBuild cannot find TargetFramework assemblies for .NETFramework, Version=v.4.5
Cause
Rider delivered .sqlproj support in two waves:
Legacy 'non-sdk style' .sqlproj support was delivered only to Windows earlier. Such projects are by-default windows-only because it depends on Microsoft.Data.Tools.Chema.SqlTasks.targets and Microsoft.Data.Tools.Schema.SqlTasks.targets that are typically distributed with Visual Studio. The non-sdk style projects are by default not supposed to work on non-Windows.
Cross-platform support for 'sdk style' .sqlproj support was delivered as a part of Rider 2025.2 release.
Resolution
To make the 'non-sdk style' .sqlproj work on MacOs or Linux, one needs to adjust the .sqlproj file, so that MSBuild can find the missing files. Such a conversion can be done using Azure Data Studio with 'SQL Database Projects' extension: Upon opening such an .sqlproj on MacOs or Linux, the user will be prompted to update the project:
That are the changes is does:
<Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
->
<Import Condition="'$(NetCoreBuild)' != 'true' AND '$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
<Import Condition="'$(NetCoreBuild)' != 'true' AND '$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Condition="'$(NetCoreBuild)' == 'true'">
<Version>1.0.0</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(NETCoreTargetsPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" Condition="'$(NetCoreBuild)' == 'true'" />
<Target Name="BeforeBuild">
<Delete Files="$(BaseIntermediateOutputPath)\project.assets.json" />
</Target>
It is planned to deliver a similar 'Update' action to Rider soon: Right-click on the SQL project in the solution explorer and select "{Not yet released action}" (to be updated).
Comments
0 comments
Please sign in to leave a comment.