Coded installer - c#

Is it ok to code your own c# application in order to create your installer (I mean code the installer, an not use InstallShield or Visual Studio setup project or anything else?

Yes, it's "okay" to do that, but I question the desire -
The problem with doing this is two fold:
You're doing a lot of work that an installation program can do for you, and probably do better, as they've been tested heavily. Why avoid a perfectly good tool that does a reasonable job in order to develop your own (likely poor) substitute?
If you code this in C#, you'll have a requirement that the .NET framework be installed prior to your installer being able to execute. Normally, a native bootstrapper makes sure the framework is installed before calling your installer.

If by ok you mean recommended then no, you should use ClickOnce instead, it is a lot easier/faster than coding you own solution.

In a sense, you're going to be reinventing the wheel, and the odds are good that, depending on the complexity of your install, you're going to get it wrong. Installers know how to call into the setup api correctly to register the application for uninstall. They know how to correctly install a windows service, create start menu items, set up shortcuts, etc, ....
I heartily recommend WiX, personally. It gives you all of the flexibility of an MSI-based install, with the flexibility and easy of an xml-based script.
It's very easy to write a batch script to xcopy an app into place and create some registry entries. It's not trivial to make sure that the installer rolls back the transaction if any part of the install fails. This is inherent to an MSI install, and is the preferred way to deliver an application.
If you don't want to learn WiX, and don't care about using an MSI (database-based, transactional) install, at least take a look at NSIS. It's incredibly easy to do a basic installer in only a couple lines of script, and it'll at least call the setup APIs correctly. Plus, you get a nice GUI. See http://nsis.sourceforge.net

Related

Best way to creating setup of C# application

Hi i am recently working on a c# window form application. I have done the all stuff and noe it's time to deploy the application, But i am unable to activate the visual studio installshield feature. Can any one here able to tell me any alternet way to create me a setup file of my application. Like Innosetup compiler or other.
Visual Studio Setup Project is easy to work with and is available for both VS2013 and VS2015 in the form of Visual Studio Extension (separately from the default VS installer). Download figures suggest that a whole lot of people are using this extension.
I prefer to use InnoSetup, which is free for any use including commercial.
You can have a UI to make creation simple, but if you want really complex functionality you can write code to create those functions. There is a thriving community of developers that use and contribute to the product, so finding examples is usually easy, but you do have to write your code in Delphi / Pascal.
On the other hand, all the Microsoft options are overly complicated and difficult to get working sensibly so I am pleased to avoid them. Corporate installers are good but incredibly expensive... so really there is no comparison. Ease of use, and free - what more could you ask for?
I should point out that I have absolutely no connection with the product other than that I have used it for many years for many products and have absolutely no complaints.
That depends on your needs.
Mostly you can just create an msi installer with an installer project type on VS.
The problem is that a lot of software distributors require an exe file type. For that you can use the free (limited ) edition of install shield : http://learn.flexerasoftware.com/content/IS-EVAL-InstallShield-Limited-Edition-Visual-Studio
It has everything that a standard installer needs and I use it to distribute my software.
I tried other free msi to exe programs but none of them worked well (this was a while a go and maybe things changed since then)

Build scripts for C# project - written in C#?

We've got a quite complex deployment scenario and want to make use of continuous deployment. Currently we've got a huge MSBuild script for everything, however, MSBuild is ok for building but not really suitable for deploying.
We'd love it if there would be some kind of C# project where we could write the deploy code directly with C#. Is there some C# scripting language which is suitable especially for deploying applications?
While it's not a C# project, you can use my company's product BuildMaster to handle deployments. It's designed to solve some of the problems you're already having, and some you probably don't realize you have (configuration file deployments, database schema updates, process automation, approvals, etc.)
However, if all you want is to write C# scripts for deployment, there's a tool called con-dep which looks like what you're describing.
Well, with Roslyn now I suppose that you can technically now use C# as a scripting language. I don't know if it would be terrible appropriate to do so...
Depending on your deployment solutions you might want to look into the NAntBuilder IDE. We used this for continuous ddeployment together with SVN server. If you have TFS why don't you just look into the details and many possibilities of Build Process templates?
You can use the .NET integrated C# compiler.
The advantage is that you can use the same DLLs/APIs in a C# 'script' as you do in your own software.
I use it in our production software. Our production engineers are able to write some small programs for special stuff.
See this answer for details.
You may want to look into using a tool that's specifically designed for handling deployments. If you're using Team Foundation Server, Team Build + InRelease provides a well-supported, well-documented way to handle your builds and deployments. Now that Microsoft owns InRelease, it'll be part of Team Foundation Server pretty soon.
If not, you can always write PowerShell scripts to handle your deployments. PowerShell isn't C#, but it's built on top of the .NET framework (so all the framework methods you're familiar with are still available), and the learning curve isn't very steep.

Make changes to c# program without loosing older code

I'm a hobbyist programmer and I've created an application for my office. Every so often I need to improve the code, add features or fix issues that come up under certain circumstances - I've found bugs or ineffective coding even after 3-4 months of heavy usage of the application. The thing is that whenever I modify the code, visual studio saves the changes. This means that if I want to use the program I'll have to be really fast in coding and debugging or it won't build - and I won't be able to use it...
Is there any way to keep the old version of the program without having to save the complete project folder elsewhere? Like creating a new version but keeping the option to go back to the old - working - one...
What you are looking for is called source control.
There are many systems out there, two popular ones are subversion and Git.
Used properly, you will have a full history of each file you have in your project.
There are two other answers here regarding source control at the time I write this, but there is another angle on this as well.
You're executing your production copy from the development directory. Don't do this.
When you have developed the program to a stable version, make a copy of it somewhere else and use that copy. In this way you're free to keep developing on the software without destroying your ability to keep using the existing stable version.
As for source control, you should definitely use that as well if you're not already doing it. It would, among other things, allow you to go back and hotfix the stable version with minor bugfixes while still doing major rewrites of the software, as well as the features others here have mentioned, full history of your project, "unlimited" undo, etc.
I'm not sure what you mean that Visual Studio saves the code when you modify it. It does by default save when you build, but I don't think it saves while you're typing.
Anyway, what you're looking for is called a source control system.
You can try Team Foundation Service from Microsoft.
It works fine and you can share youre project whit colleagues.
http://tfs.visualstudio.com/
EDIT:
This is a free of charge option you can use, until you want to share youre project with more than 4 persons!! than you have to pay for TFS
You need source control.
If your project is open source you can use codeplex, it's an open-source Website where engineers and computer scientists share projects and ideas. Its features include wiki pages, source control based on Mercurial, Team Foundation Server or Subversion (also powered by TFS), Git,discussion forums, issue tracking, project tagging, RSS support, statistics, and releases
If you don't want to share your code you can use Team Foundation Server

Selecting a Build Server

I'm planning to setup my own build server. I'm primary building C#, C/C++ and Java projects. I would also like my build server to run some external programs/scripts such as my unit tests, code static analysis and doxygen.
Suggestions?
Use Hudson Continuous-Integration software.
We're using JetBrains TeamCity. It's easy to configure, user friendly, has convenient plug-ins for notifications on build events, you can install multiple build workers, define any build engine (.net, java...), it can output artifacts, it can trigger automatically on check-in, it can execute any custom build script etc, etc... and most of all - it's free (for up to 20 configurations).
We've looked far and wide, and we found this to be the best...
Hardware: Discs. Quite some, or a decent SSD. A lot of the stuff you do will be disc based from the compiler side. Not talking about the get latest version (alone), but for example a c++ compiler generates QUITE a number of interim files in the build process. A decent fast subsystem can make a recognizable difference. Especially fi this is not for you but for some colleagues as well, sotit may run a lot concurrently.
Well, enough RAM and a modern multi core CPU go without saying.
I've used Trac and Bitten, which worked quite well. I used it for C# and Python projects.
I have it building, creating docs and running unit tests. Currently I'm investigating running dotCover for test coverage, which shouldn't be too difficult, because bitten basically allows you to call any shell command you need.
Actually, I usually run the build system on an old (not-so-fast) system - it doesn't need to be very quick for me. I like to have developers behind the fast machines ;-)

manage different verions of a Visual Studio project?

I'm working on the upgrade of my c# visual express 2008 project to a newer version.
How do I manage this without having to copy the whole project directory and work into the copied directory project?
Create a new branch in the source control system that you are using. You can read more about it at Branching and Merging Primer.
If you are not using a source control I suggest you start with subversion. VisualSVN SERVER is an easy way to get started. You can use TortoiseSVN to work with it or visual studio plugins such as ankhsvn or VisualSVN.
You do not really have to install svn server. You can create repository with Tortoise Svn too and use file protocol to connect to it. This means that you can put the repository on your flash drive and query it with you so that you can work from any computer.
Subversion is good, and easy to pick up, but you might also want to consider Mercurial or Git. These are almost as easy to pick up and give you some flexibility in that they are distributed - which I have found makes much more sense for an individual user. These also tend to take up less space in the long run as well.
In addition, for your needs, you will not necessarily need to branch. Get your chosen Source Control installed, and create your repository with your stable version in it. Once you have that, as long as you have a backup in place, you will always be able to get back to your stable version. If you ever have to do a bug fix on your stable version, that would be the time to branch from that version. For a small individual repository, it'll probably be less confusing to keep your main work in the trunk -
Lastly, since you are new to source control, get in the habit of doing one thing at a time, then checking that change in. Your source control tool (or commandline) should be open every time your IDE is, and you should use it often. Even small changes are important to track. Establishing this habit will take work, but will pay off immensely.
Good luck!

Categories

Resources