Skip to content

Commit 7d2f842

Browse files
jasonhornerrwestMSFT
authored andcommitted
Update pre-post-deployment scripts documentation
Added notes on managing SQL scripts in SDK-style projects.
1 parent f572350 commit 7d2f842

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/tools/sql-database-projects/concepts/pre-post-deployment-scripts.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ Those files should be excluded from the database model build by setting the `Bui
6262
</Project>
6363
```
6464

65+
In SDK-style SQL projects, adding a `Build Remove="path\file.sql"` entry removes the file from the project entirely, which causes it to no longer appear in the Visual Studio Code project view. To keep the file visible while still excluding it from model compilation, re-add it as a `None` item:
66+
67+
```xml
68+
<Build Remove="scripts\script1.sql" />
69+
<None Include="scripts\script1.sql" />
70+
<Build Remove="scripts\script2.sql" />
71+
<None Include="scripts\script2.sql" />
72+
```
73+
74+
This prevents the file from being compiled as part of the database model while keeping it visible in the project.
75+
6576
> [!TIP]
6677
> You can validate the pre-deployment and post-deployment scripts after project build, by changing the `.dacpac` file extension to `.zip` and unarchiving the `.zip` to a folder. A single `.sql` file is present for pre-deployment and post-deployment scripts, and should contain the entire Transact-SQL contents of all referenced files in the originating SQL project.
6778
@@ -85,7 +96,7 @@ The script file is added to the project and opened in the query editor, where yo
8596

8697
::: zone pivot="sq1-visual-studio-code"
8798

88-
In the **Database Projects** view of VS Code or Azure Data Studio, right-click the project and select **Add Pre-Deployment Script** or **Add Post-Deployment Script**. Provide a script name without the file extension.
99+
In the **Database Projects** view of Visual Studio Code or Azure Data Studio, right-click the project and select **Add Pre-Deployment Script** or **Add Post-Deployment Script**. Provide a script name without the file extension.
89100

90101
The script file is added to the project and opened in the query editor, where you can complete the script. This script will be executed before or after the deployment plan is executed every time the project is deployed.
91102

0 commit comments

Comments
 (0)