Export (0) Print
Expand All
26 out of 84 rated this helpful - Rate this topic

How to: Deploy using a Setup and Deployment Project 

This topic demonstrates deployment using a Setup and Deployment Project. For background on this deployment scenario, see Scenarios for Deployment Examples.

Procedures for deploying Visual C++ library DLLs as shared assemblies

Create a Setup and Deployment Project

  • From the File menu, click New Project, open the Other Project Types node and select Setup and Deployment, then click Setup Project. Supply a name and click OK.

    NoteNote

    Visual C++ Express does not support Setup Projects. To redistribute Visual C++ libraries with applications built in Visual C++ Express, use the Visual C++ Redistributable Package. Please see How to: Deploy using XCopy for more information.

Add the EXE and DLL to the project and specify where they should be installed on the target computer

  1. From the Project menu, choose Add and click File.

  2. Find the folder containing MyApplication.exe and MyLibrary.DLL and select them both.

  3. In the File System window, right click on Application Folder, point to Add and click Create to create a new folder. Call it MyLibrary.

  4. Click on Application Folder again, select MyLibrary.DLL and drag it to the MyLibrary folder.In Solution Explorer, under your project in Detect Dependencies you should see that the Visual Studio detects dependencies on MFC80.dll and MSVCR80.dll. You need to add the corresponding Merge Modules for these DLLs.

  5. From the Project menu, point to Add and click Merge Module. Select Microsoft_VC80_CRT_x86.msm and Microsoft_VC80_MFC_x86.msm, and click OK.

    NoteNote

    The debug versions of these merge modules are named Microsoft_VC80_DebugCRT_x86.msm and Microsoft_VC80_DebugMFC_x86.msm.

    For deploying 64-bit applications to a 64-bit operating system, select the merge module for the corresponding platform. For x64, select Microsoft_VC80_CRT_x86_x64.msm and Microsoft_VC80_MFC_x86_x64.msm; for Itanium, Microsoft_VC80_CRT_x86_ia64.msm and Microsoft_VC80_MFC_x86_ia64.msm.

Build setup.exe

  • Click Build Solution from the Build menu.

Run setup.exe

  • Your application is installed in the specified target folder.

  • Merge modules install the CRT and MFC assemblies as shared side-by-side assemblies. You can verify this by checking folders %WINDIR%\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50613.12800_x-ww_b7acac55\ and %WINDIR%\WinSxS\x86_Microsoft.VC80.MFC_1fc8b3b9a1e18e3b_8.0.50613.12800_x-ww_88931f5a\

  • The application and DLL use the CRT and MFC assemblies at runtime. You must add %TARGET%\MyLibrary to the PATH environment variable so that MyApplication.exe can find Mylibrary.Dll. (Or you could rebuild it as a side-by-side assembly.)

On an operating system that does not support manifest-based binding (Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows 2000), this is what happens:

  • Your application is installed in the specified target folder.

  • Merge modules install the CRT and MFC assemblies in two locations:

    • %WINDIR%\System32—This ensures that applications run on this operating system even though it does not support manifest-based binding.

    • %WINDIR%\WinSxS (similar to Windows XP Home Edition, Windows XP Professional, Windows Server 2003)—This ensures that when the operating system is upgraded to Windows XP Home Edition, Windows XP Professional, Windows Server 2003, your application will still run and start using the DLLs in WinSxS. The DLLs in System32 will be removed in the process by which Windows Upgrade informs already-installed applications about operating system upgrades.

  • The application and DLL use the CRT and MFC DLLs from System32 at runtime.

Procedures for deploying Visual C++ library DLLs as private assemblies

Create a Setup and Deployment Project

  • From the File menu, click New Project, open the Other Project Types node and select Setup and Deployment, then click Setup Project. Specify a name and click OK.

Add EXE and DLL to the project and specify where they should be installed on the target computer

  1. From the Project menu, choose Add and click File.

  2. Find the folder containing MyApplication.exe and MyLibrary.DLL and select them both.

  3. In the File System window, right click Application Folder, point to Add and click Create to create a new folder. Call it MyLibrary.

  4. Click Application Folder again, select MyLibrary.DLL and drag it to the MyLibrary folder.In Solution Explorer, under your project in Detect Dependencies you should see that Visual Studio detects dependencies on MFC80.dll and MSVCR80.dll. You need to add a corresponding folder for these assemblies from the \vc\redist folder.

    NoteNote

    For debug builds, use \vc\redist\debug_nonredist.

  5. Open %PROGDIR%\Microsoft Visual Studio 8\VC\Redist\x86 in Windows Explorer.

  6. Holding the Ctrl key, click the folders Microsoft.VC80.CRT and Microsoft.VC80.MFC. Drag these folders to Visual Studio and drop them into the Application folder.

  7. Repeat step 7, but this time drag the folders to the MyLibrary folder.

    You may see a message from Visual Studio saying that you are including a DLL that is part of a Merge Module. This is exactly what you want to do, so click No to indicate that you do not want to use an MSM for this DLL.

    You need mfcm80.dll and its Unicode version mfcm80u.dll only if you use MFC/Winforms integration. Otherwise you can remove these DLLs from your setup.

    You need msvcm80.dll only if you are using managed code in your applications, for example, if your projects are built with /clr or /clr:pure.

    If mfcm80.dll, mfcm80u.dll, or msvcm80.dll is included in the setup project, an installation of the .NET Framework is required. Your setup won't work without .NET Framework 2.0 installed on the target machine.

    For debug installation, change CRT to DebugCRT and MFC to DebugMFC in the previous step.

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

Build setup.exe

  • Click Build Solution from the Build menu.

Run setup.exe

  • Your application is installed in the specified target folder.

  • The application and DLL use the CRT and MFC assemblies from the Microsoft.VC80.CRT and Microsoft.VC80.MFC folders at runtime.

On an operating system that does not support manifest-based binding (Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows 2000), this deployment method is not recommended. You are strongly urged to use MSMs instead. If you attempt to install, this is what happens:

  • Your application is installed in the specified target folder.

  • By default, the operating system loader won't find the CRT and MFC DLLs. Microsoft.VC80.CRT and Microsoft.VC80.MFC have to be added to the PATH.

NoteNote

MSMs allow you to do custom steps depending on the target machine's operating system. You may want to add these directories to the PATH only on operating systems that don't support manifest-based binding; that is, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition and Windows 2000, but not Windows XP Home Edition, Windows XP Professional, Windows Server 2003.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.