I have a Wix set up project, and I am trying to figure out a way to not be including every dependency manually as I have to it to a bunch of different projects.
I'm trying to use a batch file on pre-build, which looks like
@echo off
set TARGETDIRECTORY=%1
set OUTPUTFILE=%2
set PROJDIR=%3
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="MyWebApiBinaries" Directory="INSTALLFOLDER"^> >> %OUTPUTFILE%
for %%F in (%TARGETDIRECTORY%\*.dll) do (
echo "-- Adding %%~nxF"
echo "-- Calling %PROJDIR%Uuidgen.Exe"
%PROJDIR%Uuidgen.Exe> %PROJDIR%temp.txt
set /p aGUID=<%PROJDIR%temp.txt
del %PROJDIR%temp.txt
echo "-- Adding %aGUID%"
echo ^<Component Id="%%~nxF" Guid="%aGUID%"^> >> %OUTPUTFILE%
echo ^<File Id="%%~nxF" 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.
Got this idea from this answer except that I needed to add a GUID because I'm installing on inetpub instead of Program Files. So I've included uuidgen.exe into the project to generate a GUID. I call the exe and echo the guid into a temp file, which I later tried to read from, except that it doesn't read it. I've tried this approach on a different batch file and manually calling it and it does read it, so I don't know why it doesn't work here. Basically I'm talking about these two lines:
%PROJDIR%Uuidgen.Exe> %PROJDIR%temp.txt
set /p aGUID=<%PROJDIR%temp.txt
I've remove the delete to check that the file is generating the guid and being created, and it is there, so I know it would have to be the second line.
I've also tried running
for /f %%i in ('"%PROJDIR%\Uuidgen.Exe"') do set GUID=%%i
instead of the other two lines, but I don't get the guid on the variable
I know it doesn't get there because I added an echo with the variable, and also %OUTPUTFILE%
is being generated with an Guid="" (just an empty string/variable). Any ideas why it wouldn't get the guid on the variable?