Deploy SSDT SQL Project using Post-build event command line

I recently started working on a project with an SQL 2012 server database project. To target SQL 2012 I had to install SQL Server Data Tools or SSDT. If you haven’t already had a chance to look into SSDT then you may not know that with SSDT .dbproj files (Visual Studio Database Projects) have been replaced by .sqlproj files (SQL Database Projects). The new project file type allows you to target all SQL server versions including 2012. Sqlzapper did a nice post on the key differences between the two and helped me understand better how builds and deployments work with in SSDT.

With Visual Studio Database Projects you could use VSDBCMD.EXE to deploy your database project using the Post-build event command line in your project properties.

Database Project Post-build command line

Database Project Post-build command line

So, I needed to figure out how to do this with SQL Projects as my build was failing miserably doing the way you would with Database Projects. The docs on MSDN tell you how to publish a database project using the ‘Publish Database’ dialog (like one-click publish). Although this method works its not ideal in situations were you want to automate your publish on build to satisfy some dependencies, or if your lazy and don’t want to right-click and deploy each time ;) Unfortunately, I couldn’t find how to automate the publishing of the database. After reading sqlzapper’s post I realized that I needed to use SQLPACKAGE.EXE to publish my database in the Post-build event command line instead of VSDBCMD.EXE.

SQL Project Post-build command line

SQL Project Post-build command line

You can find more information on SQLPACKAGE.EXE commands at http://msdn.microsoft.com/en-us/library/hh550080(v=vs.103).aspx.

I just showed you how to deploy your database using the Post-build command line. Looking at the images there is a lot to be explained, such as the new tabs in the project properties and .dbschema file extension from the database project vs. the .dacpac file extension from the SQL database project (in the Post-build event scripts). Check out sqlzapper’s post and the other links I provided above to learn more about them.

Visual Studio 2012 must have extensions for cleaner code

I’m a huge supporter of clean coding (writing good code using principals, patterns and practices). Below is a list of some must have extensions for visual studio to help you code better and write cleaner code.

Resharper http://www.jetbrains.com/resharper/

Resharper is a developer productivity tool that enhances VS with a bunch of features to make you more productive. Not only that, Resharper helps you adhere to basic coding standards thru powerful code editing helpers and code generators, and helps eliminate errors and code smells, which ultimately lead to cleaner code. Some of my favorite features include:

  • Coding Assistance/Analysis
  • Refactorings
  • Code Generation
  • Enhanced Navigation

Agent Mulder http://hmemcpy.github.io/AgentMulder/

If your practicing clean coding and are programming to interfaces (like you should be) instead of concrete implementations, then I highly recommend Agent Mulder. Although Agent Mulder is not actually a VS extension (its actually a plug-in for Resharper), it integrates nicely with VS and Resharper to see your dependency injection container’s registrations and help you navigate them.

Agent Mulder Visual Icon

Agent Mulder Visual Icon

Agent Mulder Navigation

Agent Mulder Navigation

Agent Ralph http://code.google.com/p/agentralphplugin/

Agent Ralph is another Resharper plug-in. This plug-in will help you keep your code DRY (Don’t Repeat Yourself) by scanning your code and detecting functional duplicates, and offering the appropriate method to replace the offending code.

Agent Ralph

Agent Ralph detecting duplicate functional code

GhostDoc http://submain.com/products/ghostdoc.aspx

GhostDoc is an awesome extension that automatically generates XML documentation comments for methods and properties. If your practicing clean coding techniques then you know your documentation is your code (prose). This is not always acceptable, especially in the enterprise, so if your going to be documenting in code, then automate it so its consistent. The added benefit of this extension is that it will make you name your methods and parameters better since it uses those names in the documentation.

GhostDoc XML Documentation

GhostDoc XML Documentation

Indent Guides http://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30

Indent Guides adds vertical lines to your code at each indent level. Its a great tool that can be styled and helps you see where you are in your code.

Indent Guide

Indent guide lines

Productivity Power Tools 2012 http://visualstudiogallery.msdn.microsoft.com/3a96a4dc-ba9c-4589-92c5-640e07332afd

Like Resharper, this one is packed with features. Some features overlap with Resharper so you may want to take a look at the settings after installing to turn them off. Some of my favorite features:

  • Custom Document Well that allows you to change the behavior of document tabs, including the ability to sort tabs alphabetically or by project
  • Format Document on Save
  • Email Code Snippet and HTML Code Copy
  • Align Assignment statements
Productivity Power Tools 2012 options

Productivity Power Tools 2012 options

Team Foundation Server Power Tools http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

The Team Foundation Server Power Tools extension is a very powerful and handy tool if you use TFS. Basically, its a set of tools and utilities that enhances TFS by exposing some of its features to VS and windows. For example, the tool provides an Alert explorer that provides a GUI to subscribe to alerts based on different scenarios and exposes a TFS context menu that can be used in Windows Explorer. In addition, the tool improves your teams use of TFS thru Custom Check-in Policies and a Best Practices Analyzer.

TFS Power Tools

TFS Power Tools context menu

TFS Power Tools Best Practices Analyzer

TFS Power Tools Best Practices Analyzer

Well thats it. I didn’t mention it earlier, but Resharper will set you back about a $100 bucks; professionally, its a great investment. All the other extensions are free!

Any recommendations? Something I might have missed? Let me know.

Visual Studio Tools for Git – You can’t have your cake and eat it too!

Sometime last month, Microsoft released its Visual Studio Tools for Git. The tool is an extension for Visual Studio that allows source control integration with Git. It enables you to integrate Visual Studio with local Git repositories and provides tools to work with remote repositories as well.

I’ve recently become a big fan of Git and have begun using it to see how I can enhance my personal development workflow and see what else I can get out of it. So after hearing about the Git extension I was eager to try it out.

I had an existing project of some code samples with a git repo on my local machine. This project was also on my clients on-premises TFS 2010 server. After installing the extension, the project was immediately recognized as a Git team project and it appeared that all was well. I quickly switched to another task with the intent of orienting my self to the extension later. When I went to show the code samples from the project, I noticed that all the files were marked as read-only and VS kept prompting me to save the files with another name after making changes. Thinking the source code was still being managed by TFS, I checked the Source Control -> Environment -> Checked-in items -> Editing settings, to ensure it was set to ‘Check out automatically’. To my surprise, the Environment and Visual Studio TFS settings were missing!? I realized then, there was more to it and continued with my demo by  un-checking the read-only property for each file, to save the changes before running the examples.

When I had some time to look into what had happened, I noticed that the project had been un-bound from TFS source control. After looking thru the Q&A on the extension download site I found out that you can’t create a project on an on-premises TFS server that is a git repository. Apparently, a project can only be a traditional Team Foundation Version Control (TFSVC) team project, or a Git team project — you can’t have both. Which makes sense, since distributed version control is so different then centralized version control. Right now, Git team projects can only be created on Visual Studio’s cloud service, tfs.visualstudio.com. The next major release of on-premises TFS will include support for Git team projects, but they are not available in TFS 2005-2012.

This is somewhat of a disappointment as I was hoping to maintain a local git repo that I could manage locally and/or remotely, while having it managed as a traditional team project simultaneously; didn’t necessarily want a Git team project.

To fix it, I disabled the extension and then changed the source control using the Change Source Control command ‘Bind’ function. This allows a user to reestablish a source control link between a solution/project and the version store. Previous attempts with the extension enabled resulted in an error.

20 - disable extension

Start by disabling the extension and then restarting Visual Studio.

30 - remove bindings

Open the project that has the git repo. You will be asked if you want to permanently remove the source control bindings from the project. Selecting either ‘Yes’ or ‘No’ does not seem to matter.

40 - solution explorer no source control 41 - TFS not current source control plug-in 10 - no source control option

After the solution opens, you should notice that the solution is no longer under source control in Solution Explorer and Team Explorer should indicate that TFS is not the current source control provider. Also note that the Source Control menu under the File is missing. To enable the Change Source Control command you will first need to set TFS as the source control provider by either clicking on ‘Change Plug-in’ in Team Explorer or going to Tools -> Options -> Source Control settings.

50 - source control plug-in selection

Select Visual Studio TFS as the source control provider.

60 - change source control command

You should now see the Source Control option under the File menu. Click ‘Change Source Control’

70 - change source control dialog unbound 71 - change source control dialog bound

The project should be unbound. Select each Solution/Project and click Bind. Your project should now be connected.

80 - check out from TFS

You may be prompted by Visual Studio to check out your project from TFS.

90 - solution explorer with TFS

Your files should now show that they are under source control in Solution Explorer.

For now, I’ll continue using Git for Windows to manage my local repos and push/pull from GitHub. And if the project is a traditional team project on TFS, then I’ll commit my changes (on TFS) and be done with it.

Professional Development of Software Developers

Posted in Career on .

01 (341)

Creative Commons License Victor1558 via Compfight

As software developers, how do we get professional development? Who’s responsibility is it to ensure we receive professional development?

There are many ways to get professional development. For example, you can subscribe to a video training provider like Pluralsight or get free content from Microsoft thru Channel9 or many of the training videos they offer thru their technology focused sites, like ASP.NET. There’s a lot of free stuff out on the web you can search for as well. Product documentation, such as information on MSDN, books and blogs are all great sources for professional development. User group meetings, meetups, lunch-n-learns, round-tables, group discussions and mentorships are also valuable ways of getting professional development. So there’s tons of ways to get professional development you just got to go out there and get it.

Whoa! Whoa! Whoa! Hold up…”just got to go out there and get it”. Seriously?!

That’s wrong! Well not completely. As an individual, you should express some degree of personal responsibility and ensure you are getting some sort of professional development. But the buck does not stop there. If you work for someone else or are part of a team where you have leaders above you, such as senior devs, lead developers, team managers, etc, then they have a responsibility as well, to ensure you are getting some professional development. If they’re not, then they are wrong too! Bottom line here is you and your leaders share responsibility in making sure you are getting professional development.

Individual responsibilities:

  • Set your professional development goals for the year. Don’t just focus on technology oriented development either. Career, productivity, work-life balance are good ones too.
  • Build a repository of training content; either on your computer, an external drive or thru a training provider and schedule some time throughout the month to watch them
  • Join a user group or find a meetup
  • Find several blogs (personal and product specific) and read them daily, if not weekly
  • Attend at least one conference throughout the year
  • Maintain some kind of frequency. The more you do these activities the more likely you are continue doing them

Leader responsibilities:

  • Make time for your subordinates to get professional development on company time. Put it on a schedule
  • Allow them to experiment and explore on thier own during work hours
  • Have your subordinates show case their work on a regular basis
  • Get them access to books and training material
  • Host lunch-n-learns
  • Have your juniors lead discussions or give talks
  • Bring someone in from the outside if you don’t have the knowledge and skills in house
  • Start a mentorship program

I’m sure there are other things that can be done for professional development. These are the most obvious ones to me. How do you all do it? Is there a process you can share? Let me know, I’d love to here about it.