Deploy SQL project to localdb when building application - visual-studio-2013

This might be a very easy to answer question but I'm losing time here trying to research silly little things so I thought I'd just pose the question here.
I have a solution in VS2013 with two projects. The main project (Startup project) is a C# Winforms project which targets a DB and the second project a SQL project which has the schema for said DB.
So I can make changes and build the SQL project. I can take snapshots and eveything works swimmingly. What I can't do is to Run the project (which should publish it into the (localdb) debug project. If I click on run, it runs the default startup project.
Of course I can temporarily set the SQL project as the default startup project, then run, then set the main project to the default startup project again.
Surely there must be a way in which I can build the SQL project and get it to publish to the debug DB all at once, or at least in easier steps as described above?
In fact, what I would ultimately like is if there was one hotkey that will build both projects, publish the SQL project to the debug DB and run the main project.

Never mind, I've figured it out. Go to PROJECT -> Project Dependencies...
Select the WinForms project in the "Projects:" combo box and tick the Database project in the "Depends on:" checklist box.
The WinForms project is now dependent on the Database project and if you Run the application, VS will first build the DB project, then publish it to the debug DB, then build the WinForms project and then run it. Or so it seems.

There are two sides to running the db deploy on each build, the on the one hand you want the db to be up to date but on the second it is quite slow and gets really irritating really quite quickly!
What you could do is to have your c# app as the startup app so pressing F5 starts it but also map a keyboard shortcut to "Build.SSDTPublishSelection", I map CTRL+6 as it is near F5 and I hadn't used that combination of shortcuts (at least not in the last 15 years!) - This only publishes the selected project so you do need to select it first in object explorer (I have that covered with another series of shortcuts which sets the focus to solution explorer and syncing with the current document - I know keyboard heaven, who needs vim and emacs ha ha)
This was you make sure the project is selected CTRL+6, publish then F5 and you should get what you want.
One additional thing is that if you haven't already, look at the add-ins that let you publish stored procs directly without going through the publish cycle, so you can make incremental changes, then when you are ready do a full publish and run all your tests (Dave Ballantyne published one: http://dataidol.com/davebally/2014/03/01/ssdt-fast-deploy/ and I have one: https://github.com/GoEddie/SSDTExtension/tree/master/download/0.4.2)
Hope it helps!
Ed Elliott

Related

Visual Studio, setting 2 start up projects, a docker one and a client

First of all I would like to apologize in case that the question should not be here, because it is not about coding only.
The problem is the following:
I have a solution with several projects, all of those projects but one (a client), run on dapr inside of docker containers. The client is meant to be an outside project that connects to one of the dockerized project, does something and retrieves something back, very simple, for testing purposes, but it is not a test project (there is no xunit, mocking services...).
Ideally, I would like to fire the client and the rest of the projects at the same time. Question is how do I do that?
This is what I have tried:
1.- I have tried to set up the solution to start on multiple projects, marking the client and the other one that I need, and maybe other ones. It gives me the following issues:
The port is not the one that should be (5005, instead 22794), this is very minor, but when I try to test the api I get dapr errors, because it is not running.
I tried to set up the docker project as a starting project, this was done on the solution explorer window, right click and selecting option. The problem is that the client does not run.
Finally, I have tried to set up in the properties of the solution the docker project and the client to run at the same time but the problem is that I don't see the docker project, but the projects that run individually on docker (doing this will go to first problem). So there is no way on solution properties to set up the docker project and the client to run at the same time.
The workaround that I have found is to open another VStudio with the client project and fire it from there, and run in the other window the docker project. The problem with this is that it can get very messy if I need to change code in the client, so I would like to fire the docker project and the client from the same VStudio,
how do I do that? or better, can this be done?

Is it possible to change the configuration of visual studio according to the startup project?

I am having one solution with multiple projects.
I am basically creating building blocks to build more complicated projects later on. These projects are sometimes dependent on one another, thought I am trying to keep it losely coupled.
It is sometimes necessary to debug one of the projects to test whether certain functions actually behave the way they should. ( I am going to create test projects for each individual project in the future. ).
Since they are all .lib files, everytime I make a certain project the startup project to test it, I need to switch the configuration properties to create a .exe file otherwise it wont run.
Is there a way to change the configuration of your projects based on what project is the startup project? So that I can instantly run this instead of manually changing the properties everytime I take a differnt startup project.
Your plan won't work the way you want. But I suppose you could add an extra project that can load the correct lib file and launch it. Then in the debug settings of each lib project specify that debugging will launch your extra project with the path to the lib to load as an argument.
It will require a small custom project, but will make your life easier. It'll look something like this in the debug settings:

Visual Studio - how to change default build configuration to release?

Whenever I open a new (web) project in VS 2010 the default build configuration is set to "Active (Debug)". I read somewhere that if I upload my project like this to the server it would have a slight affect on performance (is this true?), so I have to manually go to properties and change it in the build tab to release. Is there any way to tell VS 2010 to open every new project in 'release' configuration?
I believe the build configurations are listed alphabetically, and the first one is always selected when starting a new project.
Since Debug and Release configurations are always added by default, you'll always get Debug selected unfortunately.
You would be better off performing a Publish operation when you want to deploy, as this will not only build in Release (or any configuration you wish), but also will only produce the files that are required by the application. You can publish to a local folder to then upload to a remote server.
Yes, it is true that dll's built in debug mode will not perform as efficiently as dll's built in release mode. A debug mode build includes symbols to allow you to attach a debugger to the dll while it is running. The result of this is slightly larger, less performant set of libraries. However, unless you are doing some really intense mathmatical processing, you probably wouldn't notice the performance loss.
Release mode on the other hand will produce smaller, more efficient dll's but you won't be able to attach an external debugger once you have deployed your application.
I would recommend you leave your applications in debug mode while in development/test, and then before deploying to production, switch to release mode.
UPDATE: I now realize I didn't answer your original question but hopefully you find the advice useful.

Visual Studio 2010: How can I build a project and not its dependencies?

I want to be able to build a web project and not its dependencies since I know that I have not modified any of the dependencies since the last build. I am looking to cut down the build time if possible. Is there a way to do this?
You could have a solution by
check the setting in Tools >> Options >> Projects and Solutions >>
Build and Run setting : Only build startup projects and dependencies on Run.
OR
If you want to go for sophistication then :
build >> Configuration Manager
from the "Active solution configuration:" dropdown select ""
give a name to your configuration and keep checked the "Create new project configurations" checkbox.
and then choose that config that you want and set the build or not check boxes.
To accomplish this in something I am working on, I created my own solution, added the projects I needed (including the projects I never wanted compiled), and then in the Configuration Manager turned off the check boxes for building the projects I didn't want to build, just as arora described above.
I've also made a copy of an existing solution (that had 16 components in it), saved it under new name (foo.sln -> foo.mine.sln), and then disabled the build of all the other sub-projects except the one(s) I am working on, that way I know for sure that I got the correct build settings.
It's not the simplest solution, but it works well for me, and takes less than 2 minutes to set up and is easy to understand. I normally add the new solution to the version control ignore list so that it never gets checked in.
Rather than project references you can just add the references to the dlls directly (the Add Reference dialog has tabs for these types, choose browse rather than project and remove the other projects from your solution). I typically create a full lib and web project solution for major development. Then just a solution for the website project for fixes where I don't need updated libs/dlls.
Although it is nice to have them autocompile if they have changed during heavy development. If they haven't changed it just refreshes them and recopies them to the bin folder.
Well one way would be to remove project references. Instead stick to dll references. You could use a post build script for dependent projects that copy the updated dll to the web project whenever they change.

Sync Services Client and Schema Xcode Project Structure

I've started work on a project that will be primarily acting as a Sync Services Client. Ideally, the project have two components: a custom schema bundle and a preference pane.
As a first step, I've created an Xcode project for the schema bundle. But now I found myself ready to start writing the code for the preference pane and the client, and I'm not sure what the best way is to integrate it with the project I already have.
What approaches have you found to work well in these kinds of situations?
The easiest way is probably to create a new Pref Pane project. That way you get all the benefits. After that, you can actually drag the project into your schema project and make it a dependent of your schema project. Whenever you build your main project (the schema project), if there are any changes in your pref pane project it will get rebuilt.

Resources