Search code examples
c#.netinstallationpackaging

create setup for an app with MSSQL server at backend


I want to create a setup file for an application that uses the following tools and technologies:

Microsoft visuals studio 2013
MSSQL server 2012

and I have used winforms and C# to write the program.

My questions are:

  1. If I want to deliver the application to customer without giving out the source code what technique or tool should I use?
  2. How do i supply the database? Should I detach it? How do I provide the database with my application?

Solution

  • I'm assuming you need to deploy the application you've created with Visual Studio rather than deploy Visual Studio itself. In which case you have a variety of options depending on its destination.

    You can just copy your executable and required dependencies to a destination without distributing your source. However, there are several tools out there that will subsequently disassemble your assemblies to reveal the source.

    The Visual Studio website has a list of options for deploying applications. If you want a tradional Next -> Next -> Finish type of installation, I would suggest using InstallShield Limited Edition.

    For SQL deployment it would depend on the Edition you have used and whether the server already exists at the destination. Additionally, it will depend on whether you only need to deploy the schema or populate the database too.

    You can distribute SQL Server Express with your application. SQL Server Management Studio will allow you to generate a "CREATE DATABASE" script (right-click database -> Script database as -> CREATE to -> File) from your existing database that can be executed as part of the installation. Alternatively, consider a backup/restore approach as detailed in this article.