/// <summary>
        /// Publishes the DacPac to the shard provided in the constructor.
        /// </summary>
        /// <param name="dacPacPath">The dac pac path.</param>
        /// <param name="dacProfilePath">The dac profile path.</param>
        /// <returns><c>true</c> if a new database was created, <c>false</c> otherwise.</returns>
        public bool PublishDacPac(string dacPacPath, string dacProfilePath)
        {
            // read the DacPac package and profile from files
            var dacPackage = DacPackage.Load(dacPacPath);
            var dacProfile = DacProfile.Load(dacProfilePath);

            return(PublishDacPac(dacPackage, dacProfile));
        }
        /// <summary>
        /// Publishes the DacPac to the shard provided in the constructor.
        /// </summary>
        /// <param name="dacPacStream">The dac pac stream.</param>
        /// <param name="dacProfileStream">The dac profile stream.</param>
        /// <returns><c>true</c> if a new database was created, <c>false</c> otherwise.</returns>
        public bool PublishDacPac(Stream dacPacStream, Stream dacProfileStream)
        {
            // read the DacPac package and profile from files
            var dacPackage = DacPackage.Load(dacPacStream);
            var dacProfile = DacProfile.Load(dacProfileStream);

            return(PublishDacPac(dacPackage, dacProfile));
        }
Esempio n. 3
0
        private PackageOptions _unusedOptions = new PackageOptions();   //without this the Microsoft.SqlServer.Dac.Extensions.dll is not included in the build

        public Proxy(string dacPacPath, string profilePath)
        {
            Profile  = DacProfile.Load(profilePath);
            Services = new DacServices(Profile.TargetConnectionString);

            Services.Message         += (sender, args) => Message.Invoke(sender, $"{args.Message.Prefix}, {args.Message.MessageType}, {args.Message.Number}, {args.Message.Message}");
            Services.ProgressChanged += (sender, args) => Message.Invoke(sender, $"{args.Message}, {args.Status.ToString().Replace("Completed", "Complete")}");

            DacpacPath = dacPacPath;
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var    Options          = new Options();
            string vDacDictionary   = null;
            string vDacProfile      = null;
            string vtargetDatabase  = null;
            string connectionString = null;
            bool   isValid          = false;

            try
            {
                isValid = CommandLine.Parser.Default.ParseArguments(args, Options);
            }
            catch (Exception e)
            {
                Console.WriteLine("there is an error in command line arguments , try reading it from configuration " + e.Message);
            }



            if (isValid)
            {
                vDacDictionary   = Options.DacDictionary;
                vDacProfile      = Options.DacProfile;
                vtargetDatabase  = Options.TargetDatabase;
                connectionString = ConnectionStringResolver(Options, connectionString);
            }
            else
            {
                vDacDictionary   = ConfigurationManager.AppSettings.Get("dac directory");
                vDacProfile      = ConfigurationManager.AppSettings.Get("dac profile");
                vtargetDatabase  = ConfigurationManager.AppSettings.Get("targetdatabase");
                connectionString = ConfigurationManager.ConnectionStrings["Mask"].ConnectionString;
            }
            string path = Directory.GetCurrentDirectory();

            // connectionString = ConnectionStringResolver(Options, connectionString);

            try
            {
                var dp         = DacPackage.Load(path + $@"\" + vDacDictionary);
                var dacService = new DacServices(connectionString);
                var dacProfile = DacProfile.Load(path + $@"\" + vDacProfile);
                dacService.Message += (object sender, Microsoft.SqlServer.Dac.DacMessageEventArgs eventArgs) => Console.WriteLine(eventArgs.Message.Message);

                dacService.Deploy(dp, vtargetDatabase, true, dacProfile.DeployOptions);

                Console.WriteLine("Deployment completed successfully !!!!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in the deployment. please correct the input " + ex.Message);
            }
            Console.ReadLine();
        }
Esempio n. 5
0
 private void LoadDacProfile()
 {
     if (File.Exists(_options.ProfilePath))
     {
         _log.Info("Using Dac profile: " + _options.ProfilePath);
         _dacProfile = DacProfile.Load(_options.ProfilePath);
     }
     else
     {
         _log.Info("Dac profile not used.");
     }
 }
Esempio n. 6
0
        private async Task <CreateDeployFilesResult> CreateDeployFilesInternalAsync(string previousVersionDacpacPath,
                                                                                    string newVersionDacpacPath,
                                                                                    string publishProfilePath,
                                                                                    bool createDeployScript,
                                                                                    bool createDeployReport)
        {
            return
                (await Task.Run(() =>
            {
                PublishResult result;
                PublishProfile publishProfile;
                string preDeploymentScriptContent;
                string postDeploymentScriptContent;
                try
                {
                    // Get publish profile
                    var deployOptions = DacProfile.Load(publishProfilePath).DeployOptions;
                    publishProfile = ConvertPublishProfile(deployOptions);

                    // Read the DACPACs
                    using (var previousDacpac = DacPackage.Load(previousVersionDacpacPath, DacSchemaModelStorageType.Memory))
                        using (var newDacpac = DacPackage.Load(newVersionDacpacPath, DacSchemaModelStorageType.Memory))
                        {
                            // Read pre-deployment and post-deployment from new DACPAC.
                            preDeploymentScriptContent = TryToReadDeploymentScriptContent(newDacpac.PreDeploymentScript);
                            postDeploymentScriptContent = TryToReadDeploymentScriptContent(newDacpac.PostDeploymentScript);

                            // Process the input
                            result = DacServices.Script(newDacpac,
                                                        previousDacpac,
                                                        "PRODUCTION",
                                                        new PublishOptions
                            {
                                GenerateDeploymentScript = createDeployScript,
                                GenerateDeploymentReport = createDeployReport,
                                DeployOptions = deployOptions
                            });
                        }
                }
                catch (DacServicesException e)
                {
                    return new CreateDeployFilesResult(GetErrorList(e));
                }

                return new CreateDeployFilesResult(result?.DatabaseScript,
                                                   _xmlFormatService.FormatDeployReport(result?.DeploymentReport),
                                                   preDeploymentScriptContent,
                                                   postDeploymentScriptContent,
                                                   publishProfile);
            }));
        }
Esempio n. 7
0
        private void ReadPublishProfile(string targetPublishProfileFile)
        {
            var dacProfile = DacProfile.Load(targetPublishProfileFile);

            DatabaseName = dacProfile.TargetDatabaseName;

            if (IsNullOrWhiteSpace(DatabaseName))
            {
                throw new ArgumentException($"Database Name not found in publish profile \"{targetPublishProfileFile}\". The node \"//Project/PropertyGroup/TargetDatabaseName\" is empty or missed.");
            }

            sqlCmdVariables.Add("DatabaseName", DatabaseName);


            ConnectionString = dacProfile.TargetConnectionString;

            var builder = new SqlConnectionStringBuilder(ConnectionString);

            ServerName = builder.DataSource;
            if (IsNullOrWhiteSpace(ServerName))
            {
                throw new ArgumentException($"No Server name (DataSource) provided in TargetConnectionString property of publish profile {targetPublishProfileFile}. The node \"//Project/PropertyGroup/TargetConnectionString\" is empty or missed.");
            }

            IntegratedSecurity = builder.IntegratedSecurity;

            if (!IntegratedSecurity)
            {
                UserID = builder.UserID;
                if (IsNullOrWhiteSpace(ServerName))
                {
                    throw new ArgumentException($"No UserID provided although the Integrated Security property of TargetConnectionString in publish profile \"{targetPublishProfileFile}\" set to \"false\"");
                }

                Password = builder.Password;
                if (IsNullOrWhiteSpace(ServerName))
                {
                    throw new ArgumentException($"No Password provided although the Integrated Security property of TargetConnectionString in publish profile \"{targetPublishProfileFile}\" set to \"false\"");
                }
            }

            DacDeployOptions = dacProfile.DeployOptions;
        }
Esempio n. 8
0
        public void publishChanges()
        {
            string dacpacPath      = @"C:\Program Files (x86)\Jenkins\workspace\FirstDeploymentProject\SQLTestProject\SQLTestProject\bin\Debug\SQLTestProject.dacpac";
            string dacProfilePath  = @"C:\Program Files (x86)\Jenkins\workspace\FirstDeploymentProject\SQLTestProject\SQLTestProject\Dev.publish.xml";
            var    dp              = DacPackage.Load(dacpacPath);
            var    dbDeployOptions = new DacDeployOptions();

            dbDeployOptions.BlockOnPossibleDataLoss = false;
            //dbDeployOptions.SqlCommandVariableValues.
            //Load DacProfile from sql project
            DacProfile d = new DacProfile();

            d = DacProfile.Load(dacProfilePath);
            //var p = new PublishOptions();
            //p.GenerateDeploymentScript = true;
            //p.DatabaseScriptPath = "";
            var dbServices = new DacServices(d.TargetConnectionString);

            dbServices.Deploy(dp, d.TargetDatabaseName, true, dbDeployOptions);
        }
        /// <summary>
        /// Loads the profile.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        DacProfile LoadProfile(SqlDeploymentCompileContext context)
        {
            var profile = new DacProfile();

            // load external profile source
            if (ProfileSource != null)
            {
                // ensure path is rooted
                var source = ProfileSource.Value.Expand(context);
                if (Path.IsPathRooted(source) == false)
                {
                    source = Path.Combine(context.RelativeRoot, source);
                }

                profile = DacProfile.Load(source);
            }

            if (DeployOptions.AdditionalDeploymentContributorArguments != null)
            {
                profile.DeployOptions.AdditionalDeploymentContributorArguments = DeployOptions.AdditionalDeploymentContributorArguments.Value.Expand <string>(context);
            }
            if (DeployOptions.AdditionalDeploymentContributorPaths != null)
            {
                profile.DeployOptions.AdditionalDeploymentContributorPaths = DeployOptions.AdditionalDeploymentContributorPaths.Value.Expand <string>(context);
            }
            if (DeployOptions.AdditionalDeploymentContributors != null)
            {
                profile.DeployOptions.AdditionalDeploymentContributors = DeployOptions.AdditionalDeploymentContributors.Value.Expand <string>(context);
            }
            if (DeployOptions.AllowDropBlockingAssemblies != null)
            {
                profile.DeployOptions.AllowDropBlockingAssemblies = DeployOptions.AllowDropBlockingAssemblies.Value.Expand <bool>(context);
            }
            if (DeployOptions.AllowIncompatiblePlatform != null)
            {
                profile.DeployOptions.AllowIncompatiblePlatform = DeployOptions.AllowIncompatiblePlatform.Value.Expand <bool>(context);
            }
            if (DeployOptions.AllowUnsafeRowLevelSecurityDataMovement != null)
            {
                profile.DeployOptions.AllowUnsafeRowLevelSecurityDataMovement = DeployOptions.AllowUnsafeRowLevelSecurityDataMovement.Value.Expand <bool>(context);
            }
            if (DeployOptions.BackupDatabaseBeforeChanges != null)
            {
                profile.DeployOptions.BackupDatabaseBeforeChanges = DeployOptions.BackupDatabaseBeforeChanges.Value.Expand <bool>(context);
            }
            if (DeployOptions.BlockOnPossibleDataLoss != null)
            {
                profile.DeployOptions.BlockOnPossibleDataLoss = DeployOptions.BlockOnPossibleDataLoss.Value.Expand <bool>(context);
            }
            if (DeployOptions.BlockWhenDriftDetected != null)
            {
                profile.DeployOptions.BlockWhenDriftDetected = DeployOptions.BlockWhenDriftDetected.Value.Expand <bool>(context);
            }
            if (DeployOptions.CommandTimeout != null)
            {
                profile.DeployOptions.CommandTimeout = DeployOptions.CommandTimeout.Value.Expand <int>(context);
            }
            if (DeployOptions.CommentOutSetVarDeclarations != null)
            {
                profile.DeployOptions.CommentOutSetVarDeclarations = DeployOptions.CommentOutSetVarDeclarations.Value.Expand <bool>(context);
            }
            if (DeployOptions.CompareUsingTargetCollation != null)
            {
                profile.DeployOptions.CompareUsingTargetCollation = DeployOptions.CompareUsingTargetCollation.Value.Expand <bool>(context);
            }
            if (DeployOptions.CreateNewDatabase != null)
            {
                profile.DeployOptions.CreateNewDatabase = DeployOptions.CreateNewDatabase.Value.Expand <bool>(context);
            }
            if (DeployOptions.DatabaseLockTimeout != null)
            {
                profile.DeployOptions.DatabaseLockTimeout = DeployOptions.DatabaseLockTimeout.Value.Expand <int>(context);
            }
            //if (DeployOptions.DatabaseSpecification != null)
            //    profile.DeployOptions.DatabaseSpecification = DeployOptions.DatabaseSpecification.Value.Expand<bool>(context);
            if (DeployOptions.DeployDatabaseInSingleUserMode != null)
            {
                profile.DeployOptions.DeployDatabaseInSingleUserMode = DeployOptions.DeployDatabaseInSingleUserMode.Value.Expand <bool>(context);
            }
            if (DeployOptions.DisableAndReenableDdlTriggers != null)
            {
                profile.DeployOptions.DisableAndReenableDdlTriggers = DeployOptions.DisableAndReenableDdlTriggers.Value.Expand <bool>(context);
            }
            if (DeployOptions.DoNotAlterChangeDataCaptureObjects != null)
            {
                profile.DeployOptions.DoNotAlterChangeDataCaptureObjects = DeployOptions.DoNotAlterChangeDataCaptureObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.DoNotAlterReplicatedObjects != null)
            {
                profile.DeployOptions.DoNotAlterReplicatedObjects = DeployOptions.DoNotAlterReplicatedObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.DoNotDropObjectTypes != null)
            {
                profile.DeployOptions.DoNotDropObjectTypes = DeployOptions.DoNotDropObjectTypes?.SelectMany(i => i.Expand <string>(context)?.Split(';').Select(i => ToObjectType(i))).ToArray();
            }
            if (DeployOptions.DropConstraintsNotInSource != null)
            {
                profile.DeployOptions.DropConstraintsNotInSource = DeployOptions.DropConstraintsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropDmlTriggersNotInSource != null)
            {
                profile.DeployOptions.DropDmlTriggersNotInSource = DeployOptions.DropDmlTriggersNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropExtendedPropertiesNotInSource != null)
            {
                profile.DeployOptions.DropExtendedPropertiesNotInSource = DeployOptions.DropExtendedPropertiesNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropIndexesNotInSource != null)
            {
                profile.DeployOptions.DropIndexesNotInSource = DeployOptions.DropIndexesNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropObjectsNotInSource != null)
            {
                profile.DeployOptions.DropObjectsNotInSource = DeployOptions.DropObjectsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropPermissionsNotInSource != null)
            {
                profile.DeployOptions.DropPermissionsNotInSource = DeployOptions.DropPermissionsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropRoleMembersNotInSource != null)
            {
                profile.DeployOptions.DropRoleMembersNotInSource = DeployOptions.DropRoleMembersNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropStatisticsNotInSource != null)
            {
                profile.DeployOptions.DropStatisticsNotInSource = DeployOptions.DropStatisticsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.ExcludeObjectTypes != null)
            {
                profile.DeployOptions.ExcludeObjectTypes = DeployOptions.ExcludeObjectTypes?.SelectMany(i => i.Expand <string>(context)?.Split(';').Select(i => ToObjectType(i))).ToArray();
            }
            if (DeployOptions.GenerateSmartDefaults != null)
            {
                profile.DeployOptions.GenerateSmartDefaults = DeployOptions.GenerateSmartDefaults.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreAnsiNulls != null)
            {
                profile.DeployOptions.IgnoreAnsiNulls = DeployOptions.IgnoreAnsiNulls.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreAuthorizer != null)
            {
                profile.DeployOptions.IgnoreAuthorizer = DeployOptions.IgnoreAuthorizer.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreColumnCollation != null)
            {
                profile.DeployOptions.IgnoreColumnCollation = DeployOptions.IgnoreColumnCollation.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreColumnOrder != null)
            {
                profile.DeployOptions.IgnoreColumnOrder = DeployOptions.IgnoreColumnOrder.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreComments != null)
            {
                profile.DeployOptions.IgnoreComments = DeployOptions.IgnoreComments.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreCryptographicProviderFilePath != null)
            {
                profile.DeployOptions.IgnoreCryptographicProviderFilePath = DeployOptions.IgnoreCryptographicProviderFilePath.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDdlTriggerOrder != null)
            {
                profile.DeployOptions.IgnoreDdlTriggerOrder = DeployOptions.IgnoreDdlTriggerOrder.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDdlTriggerState != null)
            {
                profile.DeployOptions.IgnoreDdlTriggerState = DeployOptions.IgnoreDdlTriggerState.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDefaultSchema != null)
            {
                profile.DeployOptions.IgnoreDefaultSchema = DeployOptions.IgnoreDefaultSchema.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDmlTriggerOrder != null)
            {
                profile.DeployOptions.IgnoreDmlTriggerOrder = DeployOptions.IgnoreDmlTriggerOrder.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDmlTriggerState != null)
            {
                profile.DeployOptions.IgnoreDmlTriggerState = DeployOptions.IgnoreDmlTriggerState.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreExtendedProperties != null)
            {
                profile.DeployOptions.IgnoreExtendedProperties = DeployOptions.IgnoreExtendedProperties.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFileAndLogFilePath != null)
            {
                profile.DeployOptions.IgnoreFileAndLogFilePath = DeployOptions.IgnoreFileAndLogFilePath.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFilegroupPlacement != null)
            {
                profile.DeployOptions.IgnoreFilegroupPlacement = DeployOptions.IgnoreFilegroupPlacement.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFileSize != null)
            {
                profile.DeployOptions.IgnoreFileSize = DeployOptions.IgnoreFileSize.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFillFactor != null)
            {
                profile.DeployOptions.IgnoreFillFactor = DeployOptions.IgnoreFillFactor.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFullTextCatalogFilePath != null)
            {
                profile.DeployOptions.IgnoreFullTextCatalogFilePath = DeployOptions.IgnoreFullTextCatalogFilePath.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIdentitySeed != null)
            {
                profile.DeployOptions.IgnoreIdentitySeed = DeployOptions.IgnoreIdentitySeed.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIncrement != null)
            {
                profile.DeployOptions.IgnoreIncrement = DeployOptions.IgnoreIncrement.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIndexOptions != null)
            {
                profile.DeployOptions.IgnoreIndexOptions = DeployOptions.IgnoreIndexOptions.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIndexPadding != null)
            {
                profile.DeployOptions.IgnoreIndexPadding = DeployOptions.IgnoreIndexPadding.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreKeywordCasing != null)
            {
                profile.DeployOptions.IgnoreKeywordCasing = DeployOptions.IgnoreKeywordCasing.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreLockHintsOnIndexes != null)
            {
                profile.DeployOptions.IgnoreLockHintsOnIndexes = DeployOptions.IgnoreLockHintsOnIndexes.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreLoginSids != null)
            {
                profile.DeployOptions.IgnoreLoginSids = DeployOptions.IgnoreLoginSids.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreNotForReplication != null)
            {
                profile.DeployOptions.IgnoreNotForReplication = DeployOptions.IgnoreNotForReplication.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreObjectPlacementOnPartitionScheme != null)
            {
                profile.DeployOptions.IgnoreObjectPlacementOnPartitionScheme = DeployOptions.IgnoreObjectPlacementOnPartitionScheme.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnorePartitionSchemes != null)
            {
                profile.DeployOptions.IgnorePartitionSchemes = DeployOptions.IgnorePartitionSchemes.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnorePermissions != null)
            {
                profile.DeployOptions.IgnorePermissions = DeployOptions.IgnorePermissions.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreQuotedIdentifiers != null)
            {
                profile.DeployOptions.IgnoreQuotedIdentifiers = DeployOptions.IgnoreQuotedIdentifiers.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreRoleMembership != null)
            {
                profile.DeployOptions.IgnoreRoleMembership = DeployOptions.IgnoreRoleMembership.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreRouteLifetime != null)
            {
                profile.DeployOptions.IgnoreRouteLifetime = DeployOptions.IgnoreRouteLifetime.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreSemicolonBetweenStatements != null)
            {
                profile.DeployOptions.IgnoreSemicolonBetweenStatements = DeployOptions.IgnoreSemicolonBetweenStatements.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreTableOptions != null)
            {
                profile.DeployOptions.IgnoreTableOptions = DeployOptions.IgnoreTableOptions.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreUserSettingsObjects != null)
            {
                profile.DeployOptions.IgnoreUserSettingsObjects = DeployOptions.IgnoreUserSettingsObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreWhitespace != null)
            {
                profile.DeployOptions.IgnoreWhitespace = DeployOptions.IgnoreWhitespace.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreWithNocheckOnCheckConstraints != null)
            {
                profile.DeployOptions.IgnoreWithNocheckOnCheckConstraints = DeployOptions.IgnoreWithNocheckOnCheckConstraints.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreWithNocheckOnForeignKeys != null)
            {
                profile.DeployOptions.IgnoreWithNocheckOnForeignKeys = DeployOptions.IgnoreWithNocheckOnForeignKeys.Value.Expand <bool>(context);
            }
            if (DeployOptions.IncludeCompositeObjects != null)
            {
                profile.DeployOptions.IncludeCompositeObjects = DeployOptions.IncludeCompositeObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.IncludeTransactionalScripts != null)
            {
                profile.DeployOptions.IncludeTransactionalScripts = DeployOptions.IncludeTransactionalScripts.Value.Expand <bool>(context);
            }
            if (DeployOptions.LongRunningCommandTimeout != null)
            {
                profile.DeployOptions.LongRunningCommandTimeout = DeployOptions.LongRunningCommandTimeout.Value.Expand <int>(context);
            }
            if (DeployOptions.NoAlterStatementsToChangeClrTypes != null)
            {
                profile.DeployOptions.NoAlterStatementsToChangeClrTypes = DeployOptions.NoAlterStatementsToChangeClrTypes.Value.Expand <bool>(context);
            }
            if (DeployOptions.PopulateFilesOnFileGroups != null)
            {
                profile.DeployOptions.PopulateFilesOnFileGroups = DeployOptions.PopulateFilesOnFileGroups.Value.Expand <bool>(context);
            }
            if (DeployOptions.RegisterDataTierApplication != null)
            {
                profile.DeployOptions.RegisterDataTierApplication = DeployOptions.RegisterDataTierApplication.Value.Expand <bool>(context);
            }
            if (DeployOptions.RunDeploymentPlanExecutors != null)
            {
                profile.DeployOptions.RunDeploymentPlanExecutors = DeployOptions.RunDeploymentPlanExecutors.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDatabaseCollation != null)
            {
                profile.DeployOptions.ScriptDatabaseCollation = DeployOptions.ScriptDatabaseCollation.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDatabaseCompatibility != null)
            {
                profile.DeployOptions.ScriptDatabaseCompatibility = DeployOptions.ScriptDatabaseCompatibility.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDatabaseOptions != null)
            {
                profile.DeployOptions.ScriptDatabaseOptions = DeployOptions.ScriptDatabaseOptions.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDeployStateChecks != null)
            {
                profile.DeployOptions.ScriptDeployStateChecks = DeployOptions.ScriptDeployStateChecks.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptFileSize != null)
            {
                profile.DeployOptions.ScriptFileSize = DeployOptions.ScriptFileSize.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptNewConstraintValidation != null)
            {
                profile.DeployOptions.ScriptNewConstraintValidation = DeployOptions.ScriptNewConstraintValidation.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptRefreshModule != null)
            {
                profile.DeployOptions.ScriptRefreshModule = DeployOptions.ScriptRefreshModule.Value.Expand <bool>(context);
            }
            foreach (var kvp in DeployOptions.SqlCommandVariableValues)
            {
                profile.DeployOptions.SqlCommandVariableValues[kvp.Key] = kvp.Value.Expand <string>(context);
            }
            if (DeployOptions.TreatVerificationErrorsAsWarnings != null)
            {
                profile.DeployOptions.TreatVerificationErrorsAsWarnings = DeployOptions.TreatVerificationErrorsAsWarnings.Value.Expand <bool>(context);
            }
            if (DeployOptions.UnmodifiableObjectWarnings != null)
            {
                profile.DeployOptions.UnmodifiableObjectWarnings = DeployOptions.UnmodifiableObjectWarnings.Value.Expand <bool>(context);
            }
            if (DeployOptions.VerifyCollationCompatibility != null)
            {
                profile.DeployOptions.VerifyCollationCompatibility = DeployOptions.VerifyCollationCompatibility.Value.Expand <bool>(context);
            }
            if (DeployOptions.VerifyDeployment != null)
            {
                profile.DeployOptions.VerifyDeployment = DeployOptions.VerifyDeployment.Value.Expand <bool>(context);
            }

            return(profile);
        }