HOW TO: Upgrade a Nonversioned File That Is Included in a Setup Project by Using Microsoft Visual Studio .NET (827027)



The information in this article applies to:

  • Microsoft Windows Installer
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SUMMARY

This step-by-step article describes how to upgrade a nonversioned file during a Microsoft Windows Installer package installation. In the sample, you add a nonversioned file to the Windows Installer package by using a Microsoft Visual Studio .NET Setup project.

Windows Installer upgrades the nonversioned file while the Windows Installer package is running. When Windows Installer starts to install the nonversioned file that you added to the Visual Studio .NET Setup project, the installer searches for a file in the destination folder that has the same name as the file that you want to install.

If Windows Installer locates a file in the destination folder that has the same name as the file that you want to install, the installer compares the following properties of the two files:
  • Version
  • Date
  • Language
Windows Installer uses the file versioning rules to determine whether to install the file that is included in the package.

However, if both the file in the destination folder and the file in the installation package are nonversioned files, Windows Installer compares the Create dates and the Modified dates of these files to determine whether to upgrade the nonversioned file.

For more information about file versioning rules, visit the following Microsoft Developer Network (MSDN) Web site:back to the top

Requirements

This article assumes that you are familiar with the following topic:

Visual Studio .NET Setup Projects

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
  • Microsoft Windows 2000, Microsoft Windows XP, or Microsoft Windows Server 2003
  • Microsoft Visual Studio .NET
back to the top

Create a Nonversioned File

To create a nonversioned file such as a text file, follow these steps:
  1. On drive C of your computer, create a folder that is named UpgradeFiles.
  2. In the UpgradeFiles folder, create a new text file that is named Testfile.txt.
  3. Add the following statement to the file:

    This is a nonversioned text file.

  4. Save and then close the file.
back to the top

Create a Setup Project to Install the Nonversioned File

To create a Setup project that installs the nonversioned file on your computer, follow these steps:
  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. In the New Project dialog box, click Setup and Deployment Projects under Project Types.
  4. Under Templates, click Setup Project, and then click OK. By default, Setup1 is created.
  5. In Solution Explorer, right-click Setup1, point to Add, and then click File.
  6. In the Add Files dialog box, locate the Testfile.txt file in the C:\UpgradeFiles folder.
  7. Click Testfile.txt, and then click Open.
  8. In Solution Explorer, right-click Setup1, and then click Build.
back to the top

Install the Nonversioned File

To install the nonversioned file on your computer, follow these steps:
  1. Locate the Setup1.msi file in the Path of Setup1\Debug folder on your computer.

    Note If you want to install the Testfile.txt file on a different computer that has the Microsoft .NET Framework 1.0 or the .NET Framework 1.1 installed, copy Setup1.msi to that computer.
  2. Right-click Setup1.msi, and then click Install.
  3. On the Welcome to the Setup1 Setup Wizard page, click Next.
  4. On the Select Installation Folder page, type C:\NonVFiles in the Folder text box, and then click Next.
  5. On the Confirm Installation page, click Next.
  6. On the Installation Complete page, click Close.
  7. In Windows Explorer, locate the Testfile.txt file in the C:\NonVFiles folder. Double-click Testfile.txt to open the file and view the statement, and then close the file.
back to the top

Upgrade the Nonversioned File by Using the Setup Project

To upgrade the nonversioned file while you are installing the Windows Installer package, follow these steps:
  1. In Solution Explorer of the Setup1 project, right-click Testfile.txt, and then click Open.
  2. In the Testfile.txt file, replace the existing statement with the following statement:

    This is a modified nonversioned file.

  3. In the Properties window of Setup1, set the RemovePreviousVersions property to True.
  4. Set the Version property to 1.0.1.
  5. In the Microsoft Development Environment dialog box, click Yes.
  6. In Solution Explorer, right-click Setup1, and then click Build.
  7. Locate the Setup1.msi file in the Path of Setup1\Debug folder on your computer.

    Note If you installed the Testfile.txt file on a different computer, copy Setup1.msi to that computer.
  8. Right-click Setup1.msi, and then click Install.
  9. On the Welcome to the Setup1 Setup Wizard page, click Next.
  10. On the Select Installation Folder page, type C:\NonVFiles in the Folder text box, and then click Next.
  11. On the Confirm Installation page, click Next.
  12. On the Installation Complete page, click Close.
  13. In Windows Explorer, locate the Testfile.txt file in the C:\NonVFiles folder. Double-click Testfile.txt to open the upgraded file and view the new statement.
back to the top

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site:

back to the top

Modification Type:MinorLast Reviewed:5/23/2005
Keywords:kbHOWTOmaster kbhowto kbfile kbAppSetup kbUpgrade kbsetup kbDeployment KB827027 kbAudDeveloper