At the end of this lesson, you will know…
- How to move your game to another computer, and run it without Visual Studio
Right now, you have to start Visual Studio and load your solution before you can play the game. But if you want to share your program with someone else, you don’t want to make them install Visual Studio.
So, now we’ll build a version that you can copy to a CD/DVD/thumb drive/etc. and share with your friends and family.
Visual Studio has a nice installation package creation project, but it gets a little complex. So, we’re going to use the “quick and dirty” method, for now.
Building the program for another computer
The first thing you want to do is build the program in “Release” mode.
So far, we’ve used “Debug” mode, which can be useful while writing the program. Debug mode lets you take a look into the program while it’s running, in case you have a problem and aren’t sure where it’s happening.
But when you’re done writing your program, and are ready to “release it”, you want to use Release mode.
Then, you just need to copy the program’s files to a computer that has the correct .Net Framework installed, and you can run it there.
Step 1: Start Visual Studio Express 2013 for Desktop, and open the solution.
Step 2: In the menu, to the right of the “Start”, there is a dropdown that probably says “Debug” right now (that’s the default value). Change it to “Release”.
Step 3: From the menu, click on “Build”, then “Build Solution”. This will create the executable files – the ones needed to run your program.
Check the “Output” box, in the bottom middle of Visual Studio. It will tell you when it’s done building the program, along with where it was built.
Step 4: Open up Windows Explorer and get to the folder where the executable file was created.
You’ll see the file there, along with some other ones. You don’t need all of them, but it won’t hurt to have the extra files. So, we’ll copy all of them to our new location.
In this case, I just created a new folder named “Games”, with a sub-folder under it named “SuperAdventure”. You can name your folder whatever you want.
Then, paste the files into this folder.
Step 5: To make this easier to run, create a desktop shortcut for the SuperAdventure.exe file. That’s the executable, the file to run the game.
Now, you can double-click on the shortcut on the desktop and start playing your game.
Now you can copy your program to another computer (assuming they’ve been running Windows Update, and have the same version of the .Net Framework you used when you made the program.
If you learn how to create a Windows Installer project, you can end up with a single program someone can use to install your program on their computer. If their computer is missing anything, or doesn’t have the correct version of the .Net Framework, the installer program will fix that for them.
There are also some more complex installations for different types of projects – ones that use a database, or are run as a website.
But, now you know how to copy this game over to your friend or family member’s computer, so they can see the program you created and play the game.
Source code for this lesson
No source code for this lesson
Next lesson: Lesson 18.1 – Future enhancements for the game
Previous lesson: Lesson 16.3 – Functions to use weapons and potions
All lessons: Learn C# by Building a Simple RPG Index