How do NOT deploy a SQL Server Database project when debugging?
Asked Answered
H

3

26

I'm using Visual Studio 11 Beta with a SQL Server Database project and a console app project. Every time I hit F5 to debug my console app, it wants to deploy the database project. Is there any way to keep it from doing that? I can't find any settings to prevent it.

Hemicellulose answered 26/3, 2012 at 3:52 Comment(0)
M
40

The problem here is that when you say I want to build and deploy (hitting F5 does this in order to debug) you don't actually want the DB to be part of that deployment.

I'm afraid I don't have VS 11 Beta, but this is achieved by disabling the Deploy of the project in the Build Configuration.

Below is a screenshot from VS 2010, hopefully you can find an equivalent (sorry, I couldn't find the MS documentation for 2012).

Find the project you don't want to deploy, and uncheck the relevant check box under the Deploy column.

Where to find the Build Configuration drop down

Select Configuration Manager from the drop down

Uncheck Deploy for the relevant project

Mol answered 8/8, 2012 at 6:6 Comment(1)
It depends on what the OP meant, but if he did not want any deployment actions to occur (including generating a SQL script, in the case of the accepted answer above), this is the correct answer. Thank you!Burly
H
4

Double-click on the Properties node of the Database project in Solution Explorer to open the Database project properties. Select the Deploy tab. In the Deploy action section, select "Create a deployment script (.sql)" instead of "Create a deployment script (.sql) and deploy to the database".

Heaviside answered 26/3, 2012 at 7:41 Comment(2)
The Deploy tab is not present in VS 11 Beta. There is a "Create Script" checkbox on the Project Settings tab, but checking this still results in the database being deployed. Any more clues?Hemicellulose
If no deployment actions should be taken, it should be disabled in the Configuration Manager. See other answer.Burly
S
1

I had a similar problem in Visual Studio 2022, where my console app had a configured dependency on my .sqlproj. Each time I ran the console app, the .sqlproj tried to deploy.

None of the other answers above seem to be available in VS2022 (the "Deploy" checkbox is greyed out, and there's no UI for the "deployment action").

My "fix" (hack) is to override the imported "Deploy" target with a log message (I never want to deploy anyway, I just want the dacpac).

In the .sqlproj file, find the place where Microsoft.Data.Tools.Schema.SqlTasks.targets is imported, then below this, override the "Deploy" target with a "message only" target:

<Target Name="Deploy">
  <Message 
    Importance="High" 
    Text="Deployment disabled. This project is never deployed manually. Deployment is performed by applying the dacpac."></Message>
</Target> 
Slaughterhouse answered 20/6 at 22:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.