Making a setup for C#/SQL app - c#

this is my first post in stackoverflow, I've always checked this site by searching in google, so I decided to join it myself! I hope to be useful to others
I'm a 3d developer (DirectX), but recently I've started making an SMS gateway using C# and SQL Express, now I'm going to create a setup file for my project (which uses .NET 3.5), what are my options? I've heard that VS 2008 can make setup, is there any sample? how can I include SQL express in my setup app?
also I've downloaded Install Shield 2010 which has a built-in support for VS 2008, I want to make my setup in a way that it detects SQL on target system and if it finds SQL already installed, doesn't try to install it again (the same rule can be applied for .NET), what are my options? how can I make such a setup file?
thanks

With Microsoft's Visual Studio, there is an inbuilt Setup Template which you can use.
Click Once
For your scenario you should take a look at Adding Click once Custom Prerequisites.
Setup And Deployment Application
For your scenario you should take a look at the Walk-through.
Or as you mentioned you have InstallSheild 2010 then:
Install Shield Wizard
Take a look at this Walk-through with Limited Edition
As for SQL Server i think you can usually go as far as SQL Server Compact Edition. (For anything greater you may need to Inform User to install it himself)

I have no personal experience with it, but SQL Server 2008 Compact might be good for this. It is an embedded solution so so you don't actually need to install a server. Alternatively you could look at SQLite, which has native .NET implementations (google for "sqlite .net").

Related

C#: Create a DB using sql file in setup project

I am building a desktop application where it uses a local database file (.mdf). Since I was developing it on my machine I used SQL Management 2008 R2 SP2. Then I sent it out to others for feedback. But unfortunately they were not able to use it as they didn't have SP2 installed.
So, as a resolution, I want to include a sql file that would run while installing the application. I was wondering if someone could direct me how to do so.
What I have and what I think should be done is:
- Main Project (includes forms and classes - I have this working already)
- Setup Project (includes msi file that checks database existence and runs sql file accordingly - I need help on this)
I suggest you using wix to create the msi.
You know, you can no longer create setup project using visual studio (Version 2012 above). It has been removed completely.
So you should consider going in WIX (Windows Intaller XML) direction.
If you like the idea here is the quick and easy solution:
http://www.codeproject.com/Articles/331368/WIXDataBase
http://wix.tramontana.co.hu/tutorial/sql/creating-a-database
But its completely up to you to think about the alternatives.

How To make setup file that contains C# application and sql server

I want to build a setup file that contain windows form application that is connected to sql server how can I do that? I want to put the .net framework and sql server in the setup package how can I do that? do I need sql server or sql express in this case? I want to create the database in the installation process how can I do this? I want to check If the requirements are already installed how can I do this? hw can I improve the security of the program from stealing?? please help thanks
note my English language not good enough Smile | :)
That is a lot more than one question, and not easy to answer all at once. Anyway, assuming you're using Visual Studio 2012, you can try creating a new Install Shield project (below).
(It might be easier to help you once you've tried something, and have got a more specific question/problem)
For my projects I use Inno Setup. It lets you customize all aspects of the installer - add/remove different screens, set conditions for installing different files, for example you can check out whether SQL server is installed and install it only if it is not through scripting. Take a look at the FAQ page for more information about the features this tool offers.
There's also a sample Inno Setup file at CodePlex, that should get the job done. I haven't tried it though, so I cannot guarantee whether it works fine or not.
If you want to have installer for tomorrow, than good choice will be WIX (http://wix.sourceforge.net/). It is easy to understand and have a possibility of checking installed frameworks and OS version.
If you wish to have Framework msi installer inside yours, than you can check Wix Bootsrapper. But as far as I know it has poor flexibility to setup install steps. For this propose you can combine Wix with other for example NSIS. You can create application installer by using Wix and Bootsrapper application, which will contains your application MSI and Framework MSI, by using NSIS.
To create database during installation you also can use WIX. You need to create database generation plan, which will contain queries for creating database. This generation plan can be executed as part of the installation process (http://wix.tramontana.co.hu/tutorial/sql/creating-a-database). It is good choice wile you don't need additional information from user. In other case you will need to create custom UI.
From my experience with built in Visual Studio install tools, they're all horrible.
I highly recommend Advanced Installer. It's a very powerful tool to create installers and patches for your software. It should have all the features you need in the free version, including checking for prerequisites such as .NET Framework on the user's machine, and installing things when needed.

Redistributing the .NET framework and SQL Server Express

I have an app written in C#. It's a commercial app, written using nothing but free software (Visual C# express and SQL express). So, so far it's all clean.
For the app to work, both the .NET framework and SQL Server Express need to be installed on the clients computer. I already know some of the clients don't have internet connection (for security reasons), so I need to make an installer that would locally (off line) install all the dependencies (.NET framework and SQL Server Express).
So, can I (legally) burn both the .NET framework and SQL Server Express installers on the instalation CD so that the client can just click install and not have to worry about anyting?
I tried contacting Microsoft directly to ask them, but I had no luck.
Well, this Microsoft page will tell you what you needd to redistribute SQL Server Express. And here's a link about redistributing the .NET framework.
Basically, you don't really have any major restrictions when it comes to redistributing either of them. Just dig around the Microsoft website and you'll find everything you'd ever need.

How to make my project runnable on any system?

I have developed a solution in Visual Studio 2008 C# WPF!
I'm using a service-base SQL database (I've created and managed using Microsoft Visual Studio Sever Explorer), now I'm going to publish it but the problem is that when I install .NET Framework 4.0 and SQLEXPRESS 2005 on other systems, my application doesn't launch! :-(
What componenets should I install on the systems to make it runnable?
If you develop with Visual Studio 2008 you will probably need to install .NET Framework 3.5 with Service Pack 1.
If that is not enough you need to post the error you get. Probably in the eventviewer you will see more info.
You can try to create a setup using Clickonce. To do this you need to go to the property pages of the WPF project an go to the tab Publish.
There you can choose to publish it to the network or to a local directory which can be put on a CD or USB device. The most important thing for you to check is the button "Prerequisites".
I hope this helps!
EDIT to help with the comments:
It is perfectly possible to put the prerequisites in the same folder as the install or even better in a fixed network location as you can see in this screenshot below

How to version SQL Server schema using VS 2005?

I am new to C# programming and am coming to it most recently from working with Ruby on Rails. In RoR, I am used to being able to write schema migrations for the database. I would like to be able to do something similar for my C#/SQLServer projects.
Does such a tool exist for the VS 2005 toolset?
Would it be wise to use RoR migrations with SQL Server directly outside of VS 2005? In other words, I would handle all schema versioning using ActiveRecord:Migration from Rails but nothing else.
If I do handle migrations outside of C# and VS 2005 with another tool, is RoR ActiveRecord:Migration the best thing to use or is there something which is a better fit?
There's no built in way of doing this without the Database Edition of VS Team Edition. We use a NANT script similar to this and date the migration files with a date similar to how Ruby does it.
http://www.bottleit.com.au/blog/post/Continuous-database-integration.aspx
I have been happy with DBDeploy.NET for handling our database versioning. My current project uses C# + SQL 2008. DBDeploy is not integrated into Visual Studio but I suppose you could make it happen with some custom external tool entries in the IDE.
There are other tools out there that certainly work. I am not familiar with Ruby ActiveRecord:Migration but if you are already experienced in using this particular tool why not stick with it? As far as database versioning / migrations inside of Visual Studio I believe you will need to upgrade to the Database Professional Edition (extra cost for this version last I checked).
In summary, I would go with what you know. Most of the free tools for DB versioning are still somewhat half-baked at present IMHO. If you would like more information on DBDeploy.NET you can read up on it from the original project it was ported from here - http://dbdeploy.com/ Also, keep in mind that the DBDeploy tool is cross-platform (supports many DB systems, not just SQL Server & Oracle) and open-source.
For distributing application my favorite approach is actually one built in-house: Version Control and your Database.
I use the database extended properties to store the current on-disk deployed schema version, and then run an internal upgrade array that maintains a map between on-disk version => upgrade script to next version. At start-up, the app runs the steps in the upgrade array until the on-disk version matches the current app version. So an upgrade goes through all intermediate versions. Deploying a new site ( a new location) goes through every schema version, sometimes creating and dropping object no longer used. This may seem weird, but in the end the application can be deployed over any previously released version. If a client has a schema from 3 years ago everyone forgot what it contains, the app knows how to bring it up to date, always, which is great.
I favor this approach over diff compare tools (eg. VS DB project integration) because is testable and offer much better control over the exact steps taken on any upgrade. Diff tools do all sort of questionable actions, like copying tables and renaming, which doe snot work for deployments measuring +1TB (which my app has to deal with).
If the data size you expect is reasonable small (<100 Gb) I'd consider diff based tools. VS DB project deployment based on vsdbcmd works fine in such conditions. Also, if your deployment target is only one location (ie a web app where there is only one target, the web site db), then ability to upgrade any previous version looses it's appeal.
Try DBSourceTools. http://dbsourcetools.codeplex.com
Its open source, and specifically designed to help developers version control databases.

Categories