2

Background

I have complex C++ application which is installed using msi installer (defined with wix). My application need MSVC run time libraries so Microsoft_VC141_CRT_x64.msm is merged to my installer.

        <DirectoryRef Id="APPDIR">
            <Merge Id="M.visualStudioRuntime" Language="0" SourceFile="$(var.DependenciesPath)/Microsoft_VC141_CRT_x64.msm"
             DiskId="1" />
        </DirectoryRef>
....
        <FeatureRef Id="F.SomeComponent">
            ....
            <MergeRef Id="M.visualStudioRuntime" />
        </FeatureRef>

Now during installation process some data on remote server have to be verified. For that task, I'm extracting my application dll to temporary folder, loading library and execute some function with required parameters. Depending on outcome installation setup is allowed to continue or not.

This dll depends on third party (ok not fully third party it comes from other team) C++ library which also uses MSVC run-time so static linking is not acceptable solution.

Problem

When I'm loading my application dll from temporary folder it needs those MSVC run time libraries. To do that I need exact those dlls to this temporary folder.

Problem is observed only on Windows 2012, other supported Windows versions have this run time preinstalled.

Question

What is best way to extract those MSVC runtime libraries to temporary folder?

Notes

I've inherited this installer and current implementation manually embeds those dll (as duplicates) in installer extract them based on predefined id. This is bad solution and I wish need to fix it properly.

Marek R
  • 32,568
  • 6
  • 55
  • 140

1 Answers1

1

C++: Are you running a C++ custom action that needs those runtimes? Try to statically link as explained here - then there is no need for the VCRuntime files. If you are not running C++, please let us know.

Inlined Essence: Project settings => C/C++ => Code Generation => Change the runtime library setting to multithreaded instead of multithreaded dll.

Custom Action Tips: Here is an answer on common C++ custom action problems: Interrupt installation when custom action returns error.


Secondary Answer: To extract files from a merge module, the easier approach is to add it to a project, build an MSI and then run administrative installation on the MSI - which is a glorified file extraction from the MSI: What is the purpose of administrative installation initiated using msiexec /a?

Basic Command:

msiexec.exe /A MySetup.msi 
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Yest this is C++. Can't use static linking since dll-s involved is coming from third parties which also uses MSVC runtime. – Marek R Mar 11 '20 at 16:06
  • Any chance you can postpone until after installation? Run via application launch? – Stein Åsmul Mar 11 '20 at 16:09
  • Sadly no. Application is a service which communicates with other server/service and this step configures this connection. – Marek R Mar 11 '20 at 16:37
  • I suppose you could ask for statically linked components from that other team? I once recommended static linking for a team who delivered monthly updates for their software. Then you can generally get security fixes out faster than a runtime update will be approved for corporate deployment - and you are shielded from a number of runtime errors (including WinSxS manifest errors). All depends on environment. Static linking is almost always wrong, but not for deployment components who have to run on any machine, in any state, in any language, in any region on a wide range of OSs. IMHO. – Stein Åsmul Mar 12 '20 at 14:29