views:

651

answers:

2

I have a .NET Set and Deployment project which has to execute a set of really long SQL Scripts as a part of the installation process. I have used SMO dlls to make calls to the .sql script files.These SMO dlls are however not a part of the .NET framework but they come bundled with SQL Server 2005 or 2008. Now, if the setup is run on a machine which does not have SQL Server 2005/2008 installed the SQL script execution fails. This is a perfectly valid use case for my setup as the user might not have SQL server on his local machine but on a network server. How do i embedd the SMO dll's along with the setup .msi so that it doesnt have to depend on any SMO dlls on the machine it is being run?

A: 

A simple way to do it would be to add those files to the deployment project.

If you right click on the project in solution explorer then select View > File System you could add those files under the target machine's application folder.

If you need to register the dll's I think you can add a custom action to do that, but I'm not sure.

Hope that helps!

Zachary Yates
Thanks for your reply Zachary. But the thing is that I want to use the SMO dlls from the CustomInstaller class of the msi itself.Copying the dlls to the application root still doesn't give the Custominstaller class the reference it needs.
A: 

I'm sorry, I didn't understand the question at first glance. I would do the following:

  1. Create a custom installer project (Class Library)
  2. Add a reference to the SMO DLLs (I think you have to set Copy Local = True)
  3. Add an installer class to it with your sql deployment logic
  4. Add this project's output to your setup project
  5. Setup the necessary custom actions

This article explains a similar process (minus the SMO calls), it's based on this msdn article.

Hope that helps!

Zachary Yates