Distributing a Program on CD: Publishing with ClickOnce
In this lesson, you will learn how to publish your program to a CD-ROM or DVD in order to share it with others.
To share your program with others, you will first need to create a Setup program and copy it onto a CD-ROM or other media. In addition to the program itself, the Setup program will need to include other components or files that your program needs in order to run; these are known as prerequisites.
As you might imagine, determining exactly what prerequisites you need can be a difficult task; fortunately, the ClickOnce publishing tools in Visual Basic do all of this and more for you. You can also use ClickOnce publishing to publish your program on the Internet or a local network. However, in this lesson, you will be publishing your program to a CD.
To publish a program to a CD-ROM or DVD, you must have the appropriate hardware and software on the computer that you are using to write the program. If you can burn music CDs, you should also be able to publish to a CD. If you do not have this capability, you may still be able to share your program using another method—for more information, see Sending a Program in E-mail: Creating a Compressed (Zipped) File.
Publishing your program using ClickOnce is a fairly simple process involving making a few choices in the Publish Wizard and then burning the resulting files to a CD.
Before publishing your program, make sure that you have tested it and that it runs without any errors. Once you are ready to publish, you can launch the Publish Wizard by choosing the Publish command on the Build menu.
The Publish Wizard consists of three steps. The first step is to select where you want the Setup program and any associated files to be located. If you are publishing to a CD, select a folder on your local disk; you will later re-select this location to burn the program to a CD. The second step is to specify how users will install your program—in this case, from a CD-ROM.
The final step involves specifying whether your program will automatically check for a newer version of the program each time it starts. If you have access to a Web server, it is possible to publish updated versions of your program there as described in Closer Look: Distributing Your Program on the Internet. In this case, however, since you are publishing to a CD, your program will not have the ability to check for updates.
When the Publish Wizard runs, it automatically determines any prerequisites for your program. By default, prerequisites such as the .NET Framework are not actually packaged with the setup program—during installation, the setup program checks for the prerequisites and, if necessary, downloads and installs them from the Internet.
To include the prerequisites in the Setup program on the CD, you can set a property in the Project Designer. However, you must first download the redistributable files for the prerequisites to your local computer. To learn more, see Closer Look: Including Prerequisites with Your Program.
To publish to a CD
On the File menu, choose Open Project.
In the Open Project dialog box, browse to any Windows Application project that you created in an earlier lesson, and then click Open.
Press F5 to run the project. If there are any errors, you will need to fix them before continuing.
On the Debug menu, choose Stop Debugging.
On the Build menu, choose Publish Projectname, where Projectname is the name of your project.
The Publish Wizard launches.
On the Where do you want to publish the application? page of the Publish Wizard, enter the path where you want to publish your program, for example, C:\My Programs. If the folder does not exist, you are prompted to create it.
Click Next to go to the next page of the wizard.
On the How will the users install the application? page, select From a CD-ROM or DVD-ROM, and then click Next.
On the Where will the application check for updates? page, select The application will not check for updates.
Click Finish. The program will be published to the location that you specified on the first page of the wizard.
You can now use your CD or DVD burning application to burn a CD or DVD for your program. You should include all of the files in the folder where you published the program.
Take the finished CD or DVD to another computer, and then run the Setup.exe file. If any prerequisites such as the .NET Framework need to be installed, you are prompted to download and install them.
Once the installation is complete, you can run the program from the shortcut located on the Start menu.
To learn how to package prerequisites with your program, keep the project open—you will use it in the lesson Closer Look: Including Prerequisites with Your Program.
In this lesson, you learned how to publish a program to a CD-ROM using ClickOnce publishing. At this point, you have several choices on where to go next.
If you have access to a Web server and want to learn how to publish your program to the Internet, see Closer Look: Distributing Your Program on the Internet.
If you were unable to burn a CD-ROM or DVD-ROM, see the next lesson, Sending a Program in E-mail: Creating a Compressed (Zipped) File.
If you want to learn how to package prerequisites with your program, see Closer Look: Including Prerequisites with Your Program.
Otherwise, you are done with the main part of the guided tour. You can go on to the next set of topics for some suggestions on resources for learning more about Visual Basic in Moving Forward: Where Do I Go from Here?