microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
347 stars 20 forks source link

DacFx doesn't work on .NET 6 #33

Closed jmezach closed 2 years ago

jmezach commented 3 years ago

Hi there, I'm the maintainer of MSBuild.Sdk.SqlProj and we've been working on upgrading that project to make it compatible with .NET 6. Unfortunately we've ran into an issue in DACFX where it seems that it is depending on Strong-name signing which seems to be no longer supported on .NET 6. We are seeing the following stack trace:

System.PlatformNotSupportedException: Strong-name signing is not supported on this platform.
     at System.Reflection.AssemblyName.get_KeyPair()
     at Microsoft.Data.Tools.Schema.Extensibility.ExtensionTypeLoader.ExtensionAssemblies.CreateAssemblyName(String partialName, AssemblyName templateName)
     at Microsoft.Data.Tools.Schema.Extensibility.ExtensionTypeLoader.ExtensionAssemblies.CreateAssemblyLoadName(String partialName, Nullable`1 specificVersion, Nullable`1 isLazy)
     at Microsoft.Data.Tools.Schema.Extensibility.ExtensionTypeLoader.ExtensionAssemblies.GetNames(HashSet`1& allNames)
     at Microsoft.Data.Tools.Schema.Extensibility.ExtensionTypeLoader.LoadTypes()
     at Microsoft.Data.Tools.Schema.Extensibility.ExtensionManager..ctor(String databaseSchemaProviderType)
     at Microsoft.Data.Tools.Schema.Extensibility.ExtensionManager.<>c__DisplayClass20_0.<SetLazyExtensionManager>b__0()
     at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
     at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
     at System.Lazy`1.CreateValue()
     at System.Lazy`1.get_Value()
     at Microsoft.Data.Tools.Schema.Extensibility.ExtensionManager.GetExtensionManager(String dsp)
     at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ModelBuildingUtils.CreateEmptyModel(Type dspType, Action`1 ctorSetter)
     at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ModelBuildingUtils.CreateEmptyModel(SqlPlatforms platform, Action`1 ctorSetter)
     at Microsoft.SqlServer.Dac.Model.SqlSchemaModelCreator.CreateEmptyModel(SqlServerVersion modelTargetVersion, TSqlModelOptions modelCreationOptions)
     at Microsoft.SqlServer.Dac.Model.TSqlModel..ctor(SqlServerVersion modelTargetVersion, TSqlModelOptions modelCreationOptions)

Steps to Reproduce:

  1. Create a new Console app on .NET 6 (dotnet new console)
  2. Instantiate a new TSqlModel using the constructor that takes a SqlServerVersion and TSqlModelOptions.
  3. Run the app and see the above exception

Did this occur in prior versions? If not - which version(s) did it work in? It works fine on .NET 5.

(DacFx/SqlPackage/SSMS/Azure Data Studio)

KalleOlaviNiemitalo commented 3 years ago

The AssemblyName.KeyPair implementation was replaced with throw statements in https://github.com/dotnet/runtime/pull/50941, which was merged before v6.0.0-preview.5.21301.5.

jmezach commented 3 years ago

I have also tried using the latest preview of DacFx, but that exhibits the same issue.

dvomsaal commented 3 years ago

I started the process of opening this exact issue last week and traded emails with Leila Lali llali@microsoft.com but you beat me to the punch. This is a critical issue for our project as we rely on code-based dacpac deployments. I can provide any additional details, but it's exactly what was reported - as soon as you try to get a script against NET 6 the strong-name exception is raised.

kevin-david commented 3 years ago

@dzsquared I'm wondering if anyone has mentioned this to you yet? My understanding is the final release of .NET 6 is about a month or so away, and I'm assuming having DacFx not working with that at release would be undesirable 🙂

llali commented 3 years ago

@jmezach sorry about the delay. I have a fix for this and planning to include it in the next release of DacFx Nuget package.

jmezach commented 3 years ago

@llali No problem, looking forward to it. If you want I could take a preview release for a spin to see if that solves our issue.

llali commented 3 years ago

the preview version of dacfx with this fix is now available in nuget.org. https://www.nuget.org/packages/Microsoft.SqlServer.DacFx/160.5323.3-preview

DavidWiseman commented 3 years ago

The preview version resolved the issue for me. Thank you.

jmezach commented 3 years ago

I can confirm the same.

Do have an estimate when DACFX 160 is going to ship?

llali commented 3 years ago

Thanks for confirming the fix. We're planning to release by end of the year.

zvrba commented 2 years ago

I have just tried Microsoft.SqlServer.DacFX 160.5400.1-preview and it still fails with PNSE due to strong naming. (Exactly the same exception as in the OP).

OskarKlintrot commented 2 years ago

I tried to update from 160.5371.2-preview to 160.5400.1-preview to see if anything broke but it still works fine for me.

zvrba commented 2 years ago

Maybe an important detail: I'm deploying a net6.0 app to Azure AppService ("framework-dependent"), where it fails with PNSE. I have temporarily worked around it by disabling signing of the assembly which uses DacFX, but I'd rather not.

ErikEJ commented 2 years ago

@dzsquared could this be closed?

llali commented 2 years ago

this is fixed in stable release https://www.nuget.org/packages/Microsoft.SqlServer.DacFx/160.5400.1

joyita4subs commented 2 years ago

I am still getting this error after using 160.5400.1 or 160.6161.0. Any help on this is appreciated.