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
308 stars 19 forks source link

Code not working on Alpine distribution #72

Closed tzumbrunn closed 2 years ago

tzumbrunn commented 2 years ago

Trying to run code that deploys a dacpac on Alpine distribution of .NET 6 but it doesnt work. As Alpine is a lightweight version does it maybe require any additional package to be installed in order to work ? The code is working fine on the Debian version for example.

thanks a lot

Steps to Reproduce:

  1. Create a docker image using the FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine image
  2. The use C# to create a service to deploy the dacpac var dacServiceInstance = new DacServices(connectionString) and then using (DacPackage dacpac = DacPackage.Load(dacpacName)) { dacServiceInstance.Deploy(dacpac, new SqlConnection(connectionString).Database, upgradeExisting: true, options: dacOptions); }

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

Unhandled exception. Microsoft.SqlServer.Dac.DacServicesException: Could not read schema model header information from package. | ---> Microsoft.Data.Tools.Schema.SchemaModel.ModelSerializationException: Collation 1033 is not supported. You must specify one of the supported collations in the Collation attribute. | at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.DataSchemaModelDeserializerState.ProcessStartElement() | at Microsoft.Data.Tools.Schema.SchemaModel.XmlDeserializerEngine.ReadData(DeserializerState initialState, Boolean keepCurrentReaderPosition) | at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.ReadDataSchemaModelHeaderFromXml(TextReader input, Boolean readCustomData) | at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.ReadDataSchemaModelHeaderFromPackage(SqlPackage package, Boolean readCustomData) | at Microsoft.SqlServer.Dac.DacPackage.ReadModelHeader(IPackageSource packageSource) | --- End of inner exception stack trace --- | at Microsoft.SqlServer.Dac.DacPackage.ReadModelHeader(IPackageSource packageSource) | at Microsoft.SqlServer.Dac.DacServices.CreatePackageToDatabaseDeployment(SqlConnectionFactory connectionFactory, IPackageSource packageSource, String targetDatabaseName, DacDeployOptions options, ErrorManager errorManager) | at Microsoft.SqlServer.Dac.DeployOperation.<>cDisplayClass18_1.b1() | at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action) | at Microsoft.SqlServer.Dac.DeployOperation.<>cDisplayClass18_0.b0(Object operation, CancellationToken token) | at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) | at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) | at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) | at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) | at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) | at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken) | at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext, Action3 reportPlanOperation, Boolean executePlan) | at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable1 cancellationToken)

ErikEJ commented 2 years ago

Maybe https://github.com/dotnet/dotnet-docker/issues/2346#issuecomment-718181143 ?

tzumbrunn commented 2 years ago

Hi Erik,

that was it indeed. Thanks a lot for pointing to the right direction everything is working now using the following addition in the dockerfile

RUN apk add --no-cache icu-libs ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

There is also a nice article explaining everything here : https://andrewlock.net/dotnet-core-docker-and-cultures-solving-culture-issues-porting-a-net-core-app-from-windows-to-linux/