1

I followed the steps described in this SSE question/answer to create my WDP.

Everything works like a charm when deploying this WDP into a Sitecore Azure Paas instance.

However, when I try to install it locally in my on-premises Sitecore 9.1 XP single instance, it doesn't work.

This is the command I'm using to install it locally:

msdeploy -verb:sync -source:package="D:\coveoticore.scwdp.zip" -dest:auto -enableRule:DoNotDeleteRule -setParam:"Application Path"="coveoticore" -setParam:"Core Admin Connection String"="Data Source=.\HSANTOS2016;Initial Catalog=coveoticore_Core;User ID=sa;Password=mypassword" -setParam:"Master Admin Connection String"="Data Source=.\HSANTOS2016;Initial Catalog=coveoticore_Master;User ID=sa;Password=mypassword" -verbose

Those are the error messages I get:

Error: .Net SqlClient Data Provider: Msg 5061, Level 16, State 1, Line 5 ALTER DATABASE failed because a lock could not be placed on database 'coveoticore_Core'. Try again later.
Error: Script execution error.  The executed script:
IF EXISTS (SELECT 1
           FROM   [master].[dbo].[sysdatabases]
           WHERE  [name] = N'$(DatabaseName)')
    BEGIN
        ALTER DATABASE [$(DatabaseName)]
            SET CONTAINMENT = NONE
            WITH ROLLBACK IMMEDIATE;
    END


Error: .Net SqlClient Data Provider: Msg 5069, Level 16, State 1, Line 5 ALTER DATABASE statement failed.
Error: Script execution error.  The executed script:
IF EXISTS (SELECT 1
           FROM   [master].[dbo].[sysdatabases]
           WHERE  [name] = N'$(DatabaseName)')
    BEGIN
        ALTER DATABASE [$(DatabaseName)]
            SET CONTAINMENT = NONE
            WITH ROLLBACK IMMEDIATE;
    END

And this one:

Error Code: ERROR_EXECUTING_METHOD
More Information: Could not deploy package.
Warning SQL72023: The database containment option has been changed to None.  This may result in deployment failure if the state of the database is not compliant with this containment level.
Error SQL72014: .Net SqlClient Data Provider: Msg 5061, Level 16, State 1, Line 5 ALTER DATABASE failed because a lock could not be placed on database 'coveoticore_Core'. Try again later.
Error SQL72045: Script execution error.  The executed script:
IF EXISTS (SELECT 1
           FROM   [master].[dbo].[sysdatabases]
           WHERE  [name] = N'$(DatabaseName)')
    BEGIN
        ALTER DATABASE [$(DatabaseName)]
            SET CONTAINMENT = NONE
            WITH ROLLBACK IMMEDIATE;
    END


Error SQL72014: .Net SqlClient Data Provider: Msg 5069, Level 16, State 1, Line 5 ALTER DATABASE statement failed.
Error SQL72045: Script execution error.  The executed script:
IF EXISTS (SELECT 1
           FROM   [master].[dbo].[sysdatabases]
           WHERE  [name] = N'$(DatabaseName)')
    BEGIN
        ALTER DATABASE [$(DatabaseName)]
            SET CONTAINMENT = NONE
            WITH ROLLBACK IMMEDIATE;
    END
1

The Problem

So basically if your Sitecore package contains database users that must be deployed and the target database already contains any user (which is true for SC9.1 OOTB), you can't create the WDP in the same way you did for Azure.

From the official documentation:

Use DisableDacPacOptions to create tables or users when you are deploying. You must disable SqlDatabaseOptions for the module WDP package if you want to deploy them to an on-premise instance. If you do not disable SqlDatabaseOptions, msDeploy will try to convert the contained database into an uncontained database and the attempts to apply these options while deploying the module package produces the wrong result.

The Fix

Just add the DisableDacPacOptions option when calling the function to create your WDP ConvertTo-SCModuleWebDeployPackage. The command-line should look like this:

ConvertTo-SCModuleWebDeployPackage -Path "yourPackagePath.zip" -Destination "wdpOutputDirectoryPath" -force -verbose -DisableDacPacOptions "*"

Installing this new WDP should not produce any error message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.