Closed lausitzer closed 1 week ago
Maybe related: https://github.com/microsoft/azuredatastudio/issues/21370
Unfortunately, SQLCLR is based only on .NET Framework, we can't support it on SQL projects with .NET 8 unless significant changes are done to the SQLCLR. To build a SQL project (including SDK-style SQL projects) with SQLCLR assemblies you would need to build it with msbuild and/or Visual Studio.
This same project fails to build with dotnet build (.NET 8 SDK). (noting that SDK 0.2.4-preview has a bug with SSDT, so I downgraded to 0.2.3-preview for testing with Visual Sutdio)
In a pipeline, you'd use an msbuild task like - https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/msbuild-v1?view=azure-pipelines - to build a SQL project.
... unfortunately, this does mean you are restricted to Windows build agents only.
I'd encourage you to share feedback on SQLCLR to the SQL engine team via https://aka.ms/sqlfeedback
ps - thank you thank you for the sample project attachment! love it when digging into an issue is made simpler with the repro setup.
@dzsquared Many thanks for investigation. To be clear, its not intended to build the CLR-assembly using dotnet build. I just want to integrate an external build assembly into my dacpac. From my perspective there is no need to parse this assembly with .NET 8. However, I don't know what's going on inside that causes this behavior. Wouldn't it be possible to accept the assembly as is?
@lausitzer it would be really nice if it were possible to include a pre-build assembly in the "dotnet build" pipeline. Currently we work around in a rather ugly way by defining normal SQL functions for those defined in the CLR assembly and then in the post deploy we drop those, create the assembly and recreate all the functions. At least it works but I agree that it would be much better if one could just integrate a pre-build CLR dll into the dotnet build process.
Steps to Reproduce:
Build fails with "Build error SQL70557: This assembly is corrupt or not valid" pointing to your CREATE ASSEMBLY script. For a cross check, executed CREATE ASSEMBLY script with SSME. Assembly gets imported flawless if appropriate conditions are met (CLR-support enabled, login for assemblies signing key created).
Also tried copying dll to $(IntermediateOutputPath) and $(OutputPath) and using assemblies name instead off binary literal. Leads to SQL70502: The assembly source is not valid. Only binary literals are allowed .
Did not test on prior versions of SDK.
Find sample-project attached. MySqlProj.zip
(DacFx/SqlPackage/SSMS/Azure Data Studio)