How to exclude a particular component from Publish.xml file

Priya Jha 871 Reputation points
2021-10-07T11:38:31.487+00:00

I have a requirement to exclude a particular schema definition during DACPAC publish so that this component doesn't get deployed after i have manually run this script on my database as per different env.

But i have to include this component in my DACPAC in build state as other objects are dependent on it but I do not want to deploy it

How can it be handled? Can it be managed via publish .xml file

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,286 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ronen Ariely 15,101 Reputation points
    2021-12-23T16:02:01.713+00:00

    Hi,

    The scenario is not clear to me. Please clarify

    You speak about DACPAC but you selected the tag transact-sql which make no sense. DACPAC si created using a utilities and it is not related to executing queries directly.

    If you have XML which you need to parse and remove/add/edit the content with transact-sql then please provide a sample data so we will have something to descuss and present the result of the XML which you want the query to return

    If you are speaking about removing object from DACPAC , then :

    Option 1: You can create bacpac instead of dacpac

    When you sue SSMS and execute the utility to create dacpac then you do not have option to select which object are added to the package but when you create bacpac file then you can select exactly which object to add

    160146-image.png

    In this case, you can remove the unneeded files from the bacpac package and do tiny editing and re-package it as dacpac, or simply use it directly as bacpac

    Option 2: after you create the dacpac, open the package and edit the file manually. In this case, you can use notpad++ or any XML parser. In fact, you can also load the file to SQL Server and use queries to edit the content but this is a bit like Kill a mosquito with a cannon

    Several days ago I publish an image on Facebook, which explain the differences between bacpac and dacpac. The image include two QR code to recordings (one is in Hebrew and one in English) of my lecture about the internals of the bacpac and how to edit these if you have issue (like a feature which is not supported in the target server). I HIGHLY recommend to check the recording

    https://www.facebook.com/ronen.ariely/posts/1720241498182294

    0 comments No comments