DACPAC Deployment setting - dacpac

I want to publish my dacpac file using VSTS. I will be giving only DACPAC file to Dev ops team. I want to ignore drop table that is not in source. If i Publish it from SSDT, I can change in advanced settings. How to do that for VSTS. I can see an option under debug menu, But I am unable to check that option, Screen shot is attached in below URL.
https://i.stack.imgur.com/TBQPe.png

You can give publish.xml along side your dacpac and include a similar setting in that xml as well such as mentioned below
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
<TargetDatabaseName>dbname</TargetDatabaseName>
<DeployScriptFileName>dbname.sql</DeployScriptFileName>
<TargetConnectionString>Data Source=<name>;Integrated Security=True;Persist
Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect
Timeout=60;Encrypt=False;TrustServerCertificate=True</TargetConnectionString>
<BlockOnPossibleDataLoss>False</BlockOnPossibleDataLoss>
<DropObjectsNotInSource>False</DropObjectsNotInSource>
<ProfileVersionNumber>1</ProfileVersionNumber>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
</Project>
and while deploying dacpac (using cmd or powershell) you need to pass this xml file path in /Profile: parameter to pick this xml for deployment settings

Related

SQL Server DACPAC Deployment Dropping Users/Roles/Permissions

I'm deploying an (Azure) SQL Server Database using a DACPAC. Every time I deploy it's dropping my users, roles, and permissions even though I'm explicitly telling it not to in the publishing profile I'm using.
The publishing profile is defined as
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
<TargetDatabaseName>neonbliss</TargetDatabaseName>
<DeployScriptFileName>Neon Bliss Storefront Database.sql</DeployScriptFileName>
<BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
<DropObjectsNotInSource>True</DropObjectsNotInSource>
<ProfileVersionNumber>1</ProfileVersionNumber>
<DatabaseEdition>Basic</DatabaseEdition>
<DatabaseServiceObjective>Basic</DatabaseServiceObjective>
<DatabaseMaximumSize>2</DatabaseMaximumSize>
<DoNotDropRoleMembership>True</DoNotDropRoleMembership>
<DoNotDropUsers>True</DoNotDropUsers>
<DoNotDropPermissions>True</DoNotDropPermissions>
<DoNotDropSecurityPolicies>True</DoNotDropSecurityPolicies>
<ExcludeUsers>True</ExcludeUsers>
<ExcludeSecurityPolicies>True</ExcludeSecurityPolicies>
<ExcludeDatabaseRoles>True</ExcludeDatabaseRoles>
<IgnorePermissions>True</IgnorePermissions>
<TreatVerificationErrorsAsWarnings>True</TreatVerificationErrorsAsWarnings>
</PropertyGroup>
</Project>
Has anyone seen this?
This has been an ongoing DACPAC issue, presumably with the DropObjectsNotInSource overriding all other flags indiscriminately.
If you don't want to specifically add the security objects into your SSDT package, then since the publishing profile isn't sticking like you need, you'll need to adjust the arguments of SQLPackage.exe with...
/p:ExcludeObjectTypes=Users;Logins;RoleMembership;Permissions

How can i include a master changelog file inside another master changelog file in liquibase

I have a requirement where am pulling changelog files containing changesets as a maven dependency from other project module. I need to include the master changelog file of other project (which has reference to all the changesets in it)in current project from where i will execute the maven liquibase update / rollback or spring boot liuqibase setup. Is there a way to make it work?
I tried to do that like shown below
<?xml version="1.0" encoding="UTF-8" standalone="no"?><databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangeloghttp://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
<property name="blob" value="bytea" dbms="postgresql"/>
<property name="blob" value="blob" dbms="derby"/>
<preConditions>
<or>
<dbms type="derby"/>
<dbms type="postgresql"/>
</or>
</preConditions>
<include file="db/changelog/db.changelog-master.xml"/>
<include file="db/changelog/changesets/2019-06-001-modeler.changelog.xml"/>
</databaseChangeLog>
But i get error
Error setting up or running Liquibase: liquibase.exception.SetupException:
Error Reading Migration File: Found 2 files that match db/changelog/db.changelog-master.xml
I have same folder structure in all the projects.
This was a reported bug a while back and is now fixed with the later versions of Liquibase.
Please try to use the latest Liquibase version and see if the issue goes away.
Below is a reference for Liquibase releases.
https://github.com/liquibase/liquibase/releases
Liquibase can't understand which of your files with same name it should use.
If it's possible you should change path to your changelog.
So if your changelogs are both on path db/changelog/db.changelog-master.xml try to rename the paths at least. For example use db/changelog/module1/db.changelog-master.xml or db/changelog/db.changelog-module1-master.xml.

It is possible to use new csproj format to build for .NET Framework Client Profile?

I am trying to manually update a new csproj file to configure building for .NET Framework 4.0 Client Profile.
This works correctly
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>NET40</TargetFrameworks>
</PropertyGroup>
</Project>
but this generates an error
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>NET40</TargetFrameworks>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
</Project>
'project.assets.json' doesn't have a target for
'.NETFramework,Version=v4.0,Profile=Client'.
Ensure that restore has run and that you have included
'net40-client' in the TargetFrameworks for your project.
Is it possible to use new csproj format e.g. <Project Sdk="Microsoft.NET.Sdk"> to build for .NET Framework Client Profile?
This worked for me:
<TargetFramework>net40-client</TargetFramework>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
There is a package for this, all you have to do is to replace the first line of your csproj with:
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
Then you have some new target frameworks available such as net40-client, so
<TargetFrameworks>net40-client</TargetFrameworks>
will now work.
See the project page (https://github.com/novotnyllc/MSBuildSdkExtras) if you want more information.

NuGet does not add dependencies to package

I'm trying to package my WPF application with the NuGet pack command. So far I found out that adding -IncludeReferencedProjects resolves the problem of referenced projects not getting packed.
./nuget.exe pack {path}.csproj -NonInteractive -OutputDirectory C:\test -Properties Configuration=release -version 0.1.0 -Verbosity Detailed -IncludeReferencedProjects
The problem I face is that the project's dependencies are not getting packed. They however do show up in the log as you can see below. Dependencies: EntityFramework.
But the dependencies are never added to the package. Even when I manually inspect or deploy the package only Data.dll and {name}.exe are deployed.
What I've already tried (by searching Google/SO):
Adding a NuSpec file for the csproj file
NuGet.config with a reference to the correct packages folder (in case NuGet did not find it)
EDIT: added generated .nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>{path}.UpgradeDatabase</id>
<version>0.1.4</version>
<title>{path}.UpgradeDatabase</title>
<authors>stephanbisschop</authors>
<owners>stephanbisschop</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<copyright>Copyright © 2016</copyright>
<dependencies>
<dependency id="EntityFramework" version="6.1.3" />
</dependencies>
</metadata>
</package>
Thank you in advance,
Stephan
Problem solved.
It wasn't my NuGet package that was missing the dependencies.. it was Octopus Deploy that wasn't restoring the packages. We fixed it by adding entries in the appropriate .NuSpec files. Now all the .dll, .config , etc.. files get packaged with the package.

VisualStudio SQL database project sqlcmdvars TFS deployment override custom File path?

I have an SQL database project in VisualStudio 2010 in source control with TFS 2010 with a few branches that each deploy to different servers depending on the configuration profile.
Using a sqlcmdvars file with the configuration profile appended in the filename (Debug.sqlcmdvars, etc..) for each configuration profile lets me specify the unique file path for a particular deployment environment by use of the reserved names Path1 and Path2 for the mdf file and the log file.
<?xml version="1.0" encoding="utf-8"?>
<SqlCommandVariables xmlns="urn:Microsoft.VisualStudio.Data.Schema.Package.SqlCmdVars">
<Version>1.0</Version>
<Properties>
<Property>
<PropertyName>Path1</PropertyName>
<PropertyValue>C:\SQLSERVER LOG\$(DatabaseName)\</PropertyValue>
</Property>
<Property>
<PropertyName>Path2</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\</PropertyValue>
</Property>
</Properties>
</SqlCommandVariables>
Now I'm trying to add a custom FileStream file with an associated FileStream FileGroup
I have added an additional entry in sqlcmdvars files:
<Property>
<PropertyName>PathBlobStream</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\BlobStream\</PropertyValue>
</Property>
But am not sure how to tell the database to use this over what the SchemaObjects\Database Level Objects\Storage\BlobStore.sqlfile.sql has declared:
ALTER DATABASE [$(DatabaseName)]
ADD FILE (NAME = [BlobStore], FILENAME = 'C:\SQLSERVER DATA\####\BlobStream') TO FILEGROUP [BlobStreamFileGroup];
How do you use the new entry in the sqlcmdvars to override the path for the new FileStream file?
The best way I found to do this was add additional entries in the dbproj file to use a different schema file depending on the configuration profile:
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<Build Include="Schema Objects\Database Level Objects\Storage\Files\BlobStore.sqlfile.sql">
<SubType>Code</SubType>
</Build>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Internal' ">
<Build Include="Schema Objects\Database Level Objects\Storage\Files\BlobStore.sqlfile.Internal.sql">
<SubType>Code</SubType>
</Build>
</ItemGroup>
The key was copy/pasting the original schema file and appending the configuration profile name in the file name. This keeps the debug variation with the original file name so that any future schema comparisons will be oblivious to the additional variations. You want to include the additional schema files in source control, but if following suite to the entries above, they won't show up in the project. I verified MSBuild handles this correctly. I'm crossing my fingers that TFS will do the same.

Resources