Including all dependencies

2019-03-17 19:58发布

问题:

I'm just starting out with WiX as I need to be able to automate building an MSI on our CI server. Is there anyway to automatically include all the dependencies of a project?

回答1:

The "proj" extension to heat.exe is getting better. Heat isn't quite ready to be used for production in an automated fashion. It's a very reasonable way to get the initial structure put together but doesn't quite do the right thing with repeated runs (for example, Component/@Guids aren't stable, yet...).

When the above issues are solved in heat.exe then incorporating it into your build process will certainly save all the trouble that people mention above. It's on our list to do better after the most egregious bugs are fixed in the core toolset.



回答2:

I just started with WIX also and I did a quick-and-dirty trick to add references automaticaly. The idea is to scan all .dll in the output folder of the project you want to package.

In pre-build of your WIX project, add

call "$(ProjectDir)GenerateDependency.bat" "$(SolutionDir)" "$(ProjectDir)Dependencies.wxs"

Add a GenerateDependency.bat file in your WIX project containing

@echo off
set SOLUTIONDIR=%1
set OUTPUTFILE=%2
echo Starting Dependency check...
echo ^<?xml version="1.0" encoding="UTF-8"?^> > %OUTPUTFILE%
echo ^<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"^> >> %OUTPUTFILE%
echo   ^<Fragment^> >> %OUTPUTFILE%
echo     ^<ComponentGroup Id="MesDependance" Directory="INSTALLFOLDER"^> >> %OUTPUTFILE%

for %%F in (%SOLUTIONDIR%WixServiceInstallerExample\bin\Debug\*.dll) do (
   echo "-- Adding %%~nxF" 
    echo       ^<Component Id="%%~nF"^> >> %OUTPUTFILE%
    echo                     ^<File  Id="%%~nF" Name="%%~nxF" Source="%%~dpnxF" Vital="yes" KeyPath="yes" DiskId="1"/^> >> %OUTPUTFILE%
    echo       ^</Component^> >> %OUTPUTFILE%
)
echo     ^</ComponentGroup^> >> %OUTPUTFILE%
echo   ^</Fragment^> >> %OUTPUTFILE%
echo ^</Wix^> >> %OUTPUTFILE%
echo Dependency check done.

Modify the "WixServiceInstallerExample\bin\Debug" according to your need. This soulhd be the output folder of the project you want to package

Note : Beware that often VisualStudio mess around with encoding. Better edit this file with Notepad++ and make sure its in ANSI, not UTF8.

This will generate a Dependencies.wxs that you can include in your project. If you are under source control, exclude it from it.

Each build will rescan .dll and rebuild the Dependencies.wxs before actually making the package.



回答3:

Have a look at paraffin, from Wintellect.



回答4:

In my experience, Wix is a still a very manual process. You have to add each dependency singly - I think the idea was that you would build the Wix installer at the same time you are building your project and add each item in as you are adding it in the code. This way it seems less daunting than having to go back and do a retrospect on the project. It certainly would be a great suggestion for an enhancement though!



回答5:

I haven't seen something in WIX that can do that, you are supposed to know all the dependencies that your solution/project requires. Read this blog, inside is a quote:

Keep your source close and your dependencies closer (apologies Sun-tzu.)

The best way I found to make sure nothing was forgotten in the MSI, was to test the Installer on a clean installed virtual PC.

The closest I've seen, for something you want is this guy's blog.

For now, we are stuck to do it by hand.



回答6:

I just started with WIX and think that WixEdit(http://wixedit.sourceforge.net/) rocks for adding multiple files/dlls, solved my frustration with Wix of getting the files in easily. Just keep your files organized and then use the import folder function. Of course it doesnt support the new 3.0 recommendations of having one component per file.

Heat is good also and supports one component per file. Next on my list is to get some automation so these files are updated automatically a la visual studio.