Archive for September, 2012

In First part of this How To I explained essential component required to manipulate MSI installation process and create funky installation process. In this part I will use that theory of 1st part and create an advance installation process which will do following steps as part of installation process …

1) Install a file at user selected location

2) Write a timestamp into that file

Under the hood this whole process actually includes more steps, this file is located into a temp folder from where this file will be copied to install directory and then I will write a timestamp to this file. And also I will remove that temp folder which was hosting this file originally.

Before anyone assumes that I am flippin’ genius or something and I have invented this whole thing, I would like to let you folks note that part of this post is based on MSDN post @ how to create custom actions in Installation projects. Rest of items are my ideas but believe me its not THAT difficult to make ‘em work …

Couple of months back I created a post about using Windows Installer Project in VS 2010 and how to create MSI from that. At that time I had very simple requirement to work on, create an installation package that just installs our product … recently that requirement got changed a bit and now I am suppose to perform some post installation processes once installation is done and to make things seamless, I have to include them as part of installation process (from my experience, only thing that doesn’t change is change in requirements … which is kind of good … because as soon as requirements stop changing … you are out of job)

Custom actions are a Windows Installer feature that allows you to run code at the end of an installation to perform actions that cannot be handled during installation. The code can be in the form of a .dll, .exe, script, or assembly. For example, you might want to create a local database on the target computer during installation. You could create an executable file that creates and configures the database, then add that executable file as a custom action in your deployment project.

Recently I had chance to look at Visual Studio 2012 RTM and this came to me as a bit of surprise that newer version of Visual Studio 2012 doesn’t have Windows Installer Project templates ! I mean you can still use Install Shield project templates but no more Windows Installer Project.

I am really upset about this exclusion and since I can’t force MSFT to do anything I will do just like any other blogger does when s/he gets pissed off … that is writing about it on blog …

First I must say that I really like MSFT’s products and they have produced some of very unique tools like Visual Studio which nobody else have matched , and since I work on technologies build around MSFT’s framework they are my bread ‘n butter … but sometimes even good people pisses you off right ?? MSFT has really nasty habit of removing perfectly fine item and introducing something total junk as its replacement.

RAISERROR is one of the most efficient method to raise user created exception based on various situations. And TRY CATCH block is perhaps the most known method for exception handling in any programing language. But it is a bit tricky to use both of them together due to manner in which they transfer control to next command.

For any DBMS system (I know that it sounds redundant) data can come into variety of forms and formats .. say CSV, XML, another DBMS, tab limited file or fixed position file or any proprietary format (as long as you have data providers for them ). And most of connected DBMS systems have different approaches to import those kind of formats into database. One of that format is fixed position files, in many cases these finds of files gets generated by applications that uses flat file databases to store data.

In SQL Server there are three main ways to import these fixed position files into database. Using Bulk Insert tsql command, using BCP utility or using SSIS. In today’s post I will be showing way to import file using BULK INSERT. May be later on if I am feeling graceful, I will write about SSIS and BCP methods as well . Ok, so for purposes of test, I have created a fixed position file using SSIS. If you don’t know how it is done is SSIS see this previous post for HOW TO create fixed width file in SSIS.