Visual C++
How to: Deploy a Setup and Deployment Project

This topic focuses on a Setup and Deployment Project project type. 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, and 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, select Add and click File.

  2. Find the folder that contains 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 MFC90.dll and MSVCR90.dll. You must add the corresponding Merge Modules for these DLLs.

  5. From the Project menu, point to Add and click Merge Module. Select Microsoft_VC90_CRT_x86.msm and Microsoft_VC90_MFC_x86.msm, and click OK. For the debug versions of these merge modules, select Microsoft_VC90_DebugCRT_x86.msm and Microsoft_VC90_DebugMFC_x86.msm.

    NoteNote:

    Verify that the corresponding policy*.msm modules are incorporated into your project. For example, policy_9_0_microsoft_vc90_crt_x86.msm and policy_9_0_microsoft_vc90_mfc_x86.msm correspond to Microsoft_VC90_CRT_x86.msm and Microsoft_VC90_MFC_x86.msm, respectively. Visual Studio will detect that the main modules depend on these policy modules and list them under Detected Dependencies. If the dependencies are not detected automatically, you will have to manually merge the policy modules.

    For deploying 64-bit applications to a 64-bit operating system, select the merge module for the corresponding platform. For x64, select Microsoft_VC90_CRT_x86_x64.msm and Microsoft_VC90_MFC_x86_x64.msm; for Itanium, Microsoft_VC90_CRT_x86_ia64.msm and Microsoft_VC90_MFC_x86_ia64.msm.

Build setup.exe

  • Click Build Solution from the Build menu.

Run setup.exe

  • Now if you take the setup.exe you just built and run it on an operating system that supports manifest-based binding of applications to their dependencies (Windows XP Home Edition, Windows XP Professional, Windows Server 2003), the following things occur:

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, and 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, select Add and click File.

  2. Find the folder that contains 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 MFC90.dll and MSVCR90.dll. You must 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.VC90.CRT and Microsoft.VC90.MFC. Drag these folders to Visual Studio and drop them into the Application folder.

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

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

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

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

    If mfcm90.dll, mfcm90u.dll, or msvcm90.dll is included in the setup project, an installation of the .NET Framework is required. Your setup will not 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

  1. Now if you take the setup.exe you just built and run it on an operating system that supports manifest-based binding (Windows XP Home Edition, Windows XP Professional, Windows Server 2003), the following things occur:

    • Your application is installed in the specified target folder.

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

  2. On an operating system that does not support manifest-based binding (Windows 2000), this deployment method is not recommended. If you try to deploy Visual Studio assemblies as private assemblies on these operating systems following the steps described earlier, the operating system loader will be unable to locate the CRT and MFC DLLs. The folders that contain Microsoft.VC90.CRT and Microsoft.VC90.MFC must be added to the PATH environment variable for the loader to locate them. Under this mode, the following things occur:

    • Your application is installed in the specified target folder.

    • The system loader will resolve the location of the CRT and MFC private assemblies from the Microsoft.VC90.CRT and Microsoft.VC90.MFC folders through the PATH environment variable at runtime.

See Also

Tasks

Concepts

Tags : alicent


Community Content

RiteshJain
Dependencies defined in reverse direction

I am running VS 2008 SP1. In Installshield 12, the merge modules policy*.msm are shown to depend on their corresponding CRT and MFC merge modules, whereas, it should be the other way around. The CRT and MFC merge modules should depend on the policy* merge modules.

Tags : contentbug

Karel Zikmund
VS 2008 path is 9.0, not 8
The path for VS 2008 (in Private Assemblies section, step #5) is %ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\redist\x86
Tags : contentbug

turquoiseowl
Policy MSMs are problematic
Introducing the Policy merge modules causes problems with the Windows Installer validation (VS 2008 SP1). In addition, the Note in the article regarding them contradicts an MSDN blog which states that they are not necessary (sorry, I've lost the link to that). More information on the WHYs and WHEREFOREs of these Policy modules please....
Tags : contentbug

Page view tracker