2

Powershell deployment script:

Executing: C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\sqlpackage.exe /Action:Publish /SourceFile:********.dacpac /Profile:Release.Publish.xml /TargetConnectionString:server=********;database=********;uid==********;pwd=********;app=********;timeout=900 /p:IgnoreAuthorizer=True /p:IgnorePermissions=True /p:IgnoreRoleMembership=True /p:IgnoreUserSettingsObjects=True /p:BlockOnPossibleDataLoss=False /p:TreatVerificationErrorsAsWarnings=True /p:GenerateSmartDefaults=True 
Error *** The object [********] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box. 
Error *** The object [********_log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box. 
Info Initializing deployment (Complete) 
Info Analyzing deployment plan (Start) 
Info Analyzing deployment plan (Complete) 
Info Updating database (Start) 
Info Starting ********.sql 
Info Update complete. 
Info Updating database (Complete) 
Info Successfully published database.

Release.Publish.xml:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <CreateNewDatabase>False</CreateNewDatabase>
    <BackupDatabaseBeforeChanges>False</BackupDatabaseBeforeChanges>
    <BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
    <NoAlterStatementsToChangeCLRTypes>False</NoAlterStatementsToChangeCLRTypes>
    <DropObjectsNotInSource>True</DropObjectsNotInSource>
    <DeployDatabaseInSingleUserMode>False</DeployDatabaseInSingleUserMode>
    <DeployScriptFileName>Release.sql</DeployScriptFileName>
    <ProfileVersionNumber>1</ProfileVersionNumber>
    <UnmodifiableObjectWarnings>False</UnmodifiableObjectWarnings>
  </PropertyGroup>
</Project>

Why is this trying to drop mdf and ldfs?

From Project-Oriented Database Development using Command-Line Tools: I can tell the fix would possibly be to use DoNotDropObjectType to make DropObjectsNotInSource behave more responsibly, if so how?

Honestly I'm confused why this is even an issue in the first place.

1

If your mdf and ldf files are in a non-default location (or have a non-default prefix / name), you need to add that information to the SSDT project. This will help the schema compare operation (that occurs when you do a publish) to see that the files are in the right place and don't need to be dropped / recreated.

Right-click your project -> Add New Item -> File Group File

You'll get something like this:

/*
Do not change the database path or name variables.
Any sqlcmd variables will be properly substituted during 
build and deployment.
*/
ALTER DATABASE [$(DatabaseName)]
    ADD FILE
    (
        NAME = [SqlFile1],
        FILENAME = '$(DefaultDataPath)$(DefaultFilePrefix)_SqlFile1.ndf'
    )

Modify that script so that it points to the desired location of your primary data file (mdf) and your deploy should go much more smoothly.

Note that $(DefaultDataPath) is set by the settings of the target instance:

enter image description here

And $(DefaultFilePrefix) is set by the "TargetDatabaseName" in your publish.xml file.

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.