10 out of 30 rated this helpful - Rate this topic

How to: Deploy using XCopy

Updated: October 2008

This topic demonstrates how to deploy applications by copying application files from one computer to another. This technique is useful for debugging applications on another computer. For background on this deployment scenario, see Scenarios for Deployment Examples.

Visual C++ Redistributable Package can be used to deploy release versions of all Visual C++ libraries. These are three versions of this package—x86, x64, and IA64–that can be used on the corresponding versions of Windows. This package only installs release versions of Visual C++ libraries. Debug versions can either be deployed as private assemblies or by using the debug versions of Visual C++ Merge Modules. Debug versions of merge modules can be packaged together with the debug version of the application using Setup and Deployment project as described in How to: Deploy a Setup and Deployment Project. For more information, see Preparing a Test Machine To Run a Debug Executable.

To deploy Visual C++ libraries by using Visual C++ Redistributable Package, perform the following steps:

Steps

  1. Create a folder structure on the development computer that matches the folder structure to be used on the target computer. For this example, create a \bin folder and copy myapplication.exe there. Then create a \bin\mylibrary folder and copy MyLibrary.dll there.

  2. Copy this folder to the target computer.

  3. Copy Visual C++ Redistributable Package (vcredist_x86.exe) from %WindowsSdkDir%\Bootstrapper\Packages\vcredist_x86\vcredist_x86.exe to the target computer

    Note Note:

    For applications built in Visual C++ Express, it is recommended to redistribute Visual C++ libraries using the Visual C++ Redistributable Package (vcredist_x86.exe). Visual C++ Express does not install this package; however, it can be downloaded from Microsoft Visual C++ 2008 Redistributable Package (x86).

  4. Run vcredist_x86.exe on the target computer.This installs all Visual C++ libraries as shared assemblies. On a target computer with support for manifest-based binding of applications to their dependencies (Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Vista) the libraries are installed in the WinSxS folder. On a computer without such support (Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows 2000), the libraries are installed to both the WinSxS and System32 folders.

    Note Note:

    For deploying 64-bit applications to 64-bit operating systems, use vcredist_x64.exe or vcredist_ia64.exe. These packages can also be downloaded from Microsoft Visual C++ 2008 Redistributable Package (x64) and Microsoft Visual C++ 2008 Redistributable Package (ia64)

    Note Note:

    vcredist_*.exe installs only the release versions of Visual C++ DLLs. Debug versions should only be deployed as private assemblies; see the next procedure for more details.

    Note Note:

    Running vcredist_x86.exe on Windows Vista requires elevation.

  5. Your application is ready to be run.

In this scenario, the application is deployed by just copying a folder from the development computer to the target computer, and installing dependent assemblies as private side-by-side assemblies. To deploy Visual C++ libraries as private assemblies, perform the following steps:

Steps

  1. Create a folder structure on the development computer that matches the folder structure to be used on the target computer. For this example, create a \bin folder and copy myapplication.exe there. Then create a \bin\mylibrary folder and copy MyLibrary.dll there.

  2. On the development computer, from %PROGDIR%\Microsoft Visual Studio 9.0\VC\Redist\x86, copy Microsoft.VC90.CRT and Microsoft.VC90.MFC to \bin and to \bin\MyLibrary.

    Note Note:

    Visual C++ Express does not create %PROGDIR%\Microsoft Visual Studio 9.0\VC\Redist\ during installation on the development computer. To redistribute Visual C++ libraries with applications built with Visual C++ Express, please use Visual C++ Redistributable Packages (VCRedist_*.exe). See section "Deploying Visual C++ library DLLs as shared assemblies" above for more information.

    Note Note:

    For deploying 64-bit applications to 64-bit operating systems, use \vc\redist\amd64 or \vc\redist\ia64.

  3. Copy the \bin folder to the target computer. On a target computer with manifest-based binding support (Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Vista) no further preparation is necessary. On a computer without such support (Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows 2000), Microsoft.VC90.CRT and Microsoft.VC90.MFC must be on the path.

    Note Note:

    For debug applications, use debug DLLs from \vc\redist\debug_nonredist\. However, remote debugging may not work for an application that deploys debug versions of Visual C++ libraries as private assemblies. For more information, see Preparing a Test Machine To Run a Debug Executable.

    Note Note:

    If you want to do remote debugging on the target machine, you must copy over the debug DLLs or follow the procedure to install debug DLLs in Preparing a Test Machine To Run a Debug Executable.

Date

History

Reason

October 2008

Removed out-of-date content.

Customer feedback.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Missing info
Ok, I finally figured out what is wrong with this page. The so called Xcopy private deployment is missing a very important piece of information about by default using the original version of the VS 2008 runtime DLLs, not the latest which was installed after SP1. Using the latest will never work as all the executables and DLLs created with VS 2008 will dcpend on the original version unless a special binding was used at build time. After I used the original version, 9.0.21022.8, everything worked fine with the original locally integrated Microsoft runtime DLLs if no later version was installed in the Windows\winsxs directory. If the later DLLs are installed in the Windows\winsxs directory, those later DLLs are always used instead of the local ones. This is the important piece of information that is missing on this page.

Does not work at all
Microsoft, you need to either (a) correct the wrong information presented here, or (b) clarify it.  On Windows 7 x86 with VS 2008 SP1 copying the DLLs from the redist\x86 folder does not work for runtime version 9.0.30729.6161.  It only works if the DLLs are installed in the Windows\winsxs folder with the redistributable installer or using the merge module.
Doesn't work
Oh man how I wished this worked.  Unfortunately, I can't deploy private CRT and MFC DLLs using this technique with VS 2008 and Windows 2008 R2.  Welcome to the brand new DLL ***!
All's OK
Ruud van Gaal, beware that dependances versions compiler generates MAY differ from ones at Debug_NonRedist folder.
Not enough
It seems just copying the Microsoft.VC90.* directories is not enough. Perhaps you need to reference them in your manifest file(s). At least this solution doesn't work for me (after having compiled an exe using CRT dll's, then trying to get the local copy to run).

Installing Microsoft.VC90.CRT as private assembly in several folders is not a good idea!

If you install Microsoft.VC90.CRT in more than one folder, you have to keep in mind that there may be more than one instance (*) of the runtime-library in memory if you embed a manifest in a DLL. This results in many problems. In example you cannot allocate memory in one instance and free this in a different one.

The best way is to create a dependency manifest in only one place (the executable). And build the extension DLL without a manifest. (/manifest:no as linker option).


(*) This behavior occurs only, if the runtime is not installed in WinSxS


Advertisement