wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 24 forks source link

<ExePackage> SourceFile attribute behaves differently if populated with a "string" vs "wixVariable\string" #6707

Closed ghost closed 2 years ago

ghost commented 2 years ago

Wix 3.11.2.4516 Visual Studio 2017 15.9.43 WiX Toolset Visual Studio Extension version: 1.0.0.18 .NET version: 4.5.2 Windows version (Development and Build machine): Windows 10 Pro 21H2-19044.1466 Windows version (target to install on): Windows 7 Professional SP1

I'm bundling the .NET 4.5.2 embedded exe into my installer using the following code:

  <?define NetFx452MinRelease = 379893 ?>

  <Fragment>
    <util:RegistrySearchRef Id="NETFRAMEWORK45"/>

    <WixVariable Id="NetFx452RedistDetectCondition" Value="NETFRAMEWORK45 &gt;= $(var.NetFx452MinRelease)" Overridable="yes" />
    <WixVariable Id="NetFx452RedistPackageDirectory" Value="redist\" Overridable="yes" />

    <PackageGroup Id="NetFx452Redist_local">
      <ExePackage
          InstallCommand="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;"
          RepairCommand="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;"
          UninstallCommand="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;"
          PerMachine="yes"
          DetectCondition="!(wix.NetFx452RedistDetectCondition)"
          Id="NetFx452Redist_local"
          Vital="yes"
          Permanent="yes"
          Protocol="netfx4"
          LogPathVariable="NetFx452FullLog"
          Compressed="yes"
          Name="!(wix.NetFx452RedistPackageDirectory)\NDP452-KB2901907-x86-x64-AllOS-ENU.exe"
          SourceFile="!(wix.NetFx452RedistPackageDirectory)\NDP452-KB2901907-x86-x64-AllOS-ENU.exe">
      </ExePackage>
    </PackageGroup>
  </Fragment>

During installation of the resulting .exe, the bundled NDP452-KB2901907-x86-x64-AllOS-ENU.exe file is extracted into a folder with the same path as the machine which built the installer:

image

Changing the SourceFile file to a hardcoded string fixes the issue.

The NDP452-KB2901907-x86-x64-AllOS-ENU.exe file is still bundled, but isn't extracted to the same source directory:

  <?define NetFx452MinRelease = 379893 ?>

  <Fragment>
    <util:RegistrySearchRef Id="NETFRAMEWORK45"/>

    <WixVariable Id="NetFx452RedistDetectCondition" Value="NETFRAMEWORK45 &gt;= $(var.NetFx452MinRelease)" Overridable="yes" />
    <WixVariable Id="NetFx452RedistPackageDirectory" Value="redist\" Overridable="yes" />

    <PackageGroup Id="NetFx452Redist_local">
      <ExePackage
          InstallCommand="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;"
          RepairCommand="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;"
          UninstallCommand="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;"
          PerMachine="yes"
          DetectCondition="!(wix.NetFx452RedistDetectCondition)"
          Id="NetFx452Redist_local"
          Vital="yes"
          Permanent="yes"
          Protocol="netfx4"
          LogPathVariable="NetFx452FullLog"
          Compressed="yes"
          Name="!(wix.NetFx452RedistPackageDirectory)\NDP452-KB2901907-x86-x64-AllOS-ENU.exe"
          SourceFile="redist\NDP452-KB2901907-x86-x64-AllOS-ENU.exe">
      </ExePackage>
    </PackageGroup>
  </Fragment>

I would expect the WixVariable based value to behave in the same way, rather than have the absoluteURI of the source file prepended.

This is the output from from installer build script:

Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 20/01/2022 11:01:12.
Project "C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\Bootstrapper.wixproj" on node 1 (Rebuild target(s)).
CoreClean:
  Deleting file "obj\Debug\Bundle.wixobj".
  Deleting file "obj\Debug\VC2010.wixobj".
  Deleting file "obj\Debug\NetFx4.wixobj".
UpdateConstants:
  DefineConstants=;Debug;SpecialBuildMessage=DEBUG build for internal use only!;Version=2.17.1.1
Compile:
  C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe -dDebug -d"SpecialBuildMessage=DEBUG build for internal use only!" -dVersion=2.17.1.1 -dConfiguration=Debug -dOutDir=bin\
  Debug\ -dPlatform=x86 -d"ProjectDir=C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\\" -dProjectExt=.wixproj -dProjectFileName=Bootstrapper.wixproj -dProjectNam
  e=Bootstrapper -d"ProjectPath=C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\Bootstrapper.wixproj" -d"TargetDir=C:\src\tfs\MyProject\Dev\src\Insta
  ller\Bootstrapper\bin\Debug\\" -dTargetExt=.exe -dTargetFileName=MyProject-Setup.exe -dTargetName=MyProject-Setup -d"TargetPath=C:\src\tfs\MyProject\Dev\src\Installer\B
  ootstrapper\bin\Debug\MyProject-Setup.exe" -out obj\Debug\ -arch x86 -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\\WixNetFxExtension.dll" -ext "C:\Program Files (x86)\WiX To
  olset v3.11\bin\\WixUtilExtension.dll" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\\WixBalExtension.dll" Bundle.wxs NetFx4.wxs VC2010.wxs
  Windows Installer XML Toolset Compiler version 3.11.2.4516
  Copyright (c) .NET Foundation and contributors. All rights reserved.

  Bundle.wxs
  NetFx4.wxs
  VC2010.wxs
Link:
  C:\Program Files (x86)\WiX Toolset v3.11\bin\Light.exe -out "C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\bin\Debug\MyProject-Setup--dbg.exe" -pdbout "C:\src\t
  fs\MyProject\Dev\src\Installer\Bootstrapper\bin\Debug\MyProject-Setup--dbg.wixpdb" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\\WixNetFxExtension.dll" -ext "C:
  \Program Files (x86)\WiX Toolset v3.11\bin\\WixUtilExtension.dll" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\\WixBalExtension.dll" -loc 1033\CustomRtfTheme.wxl -contents
  file obj\Debug\Bootstrapper.wixproj.BindContentsFileList.txt -outputsfile obj\Debug\Bootstrapper.wixproj.BindOutputsFileList.txt -builtoutputsfile obj\Debug\Bootstrapper.wixproj
  .BindBuiltOutputsFileList.txt -wixprojectfile "C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\Bootstrapper.wixproj" obj\Debug\Bundle.wixobj obj\Debug\NetFx4.wi
  xobj obj\Debug\VC2010.wixobj
  Windows Installer XML Toolset Linker version 3.11.2.4516
  Copyright (c) .NET Foundation and contributors. All rights reserved.

  Bootstrapper -> C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\bin\Debug\MyProject-Setup--dbg.exe
AfterBuild:
  Copying file from "C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\bin\Debug\MyProject-Setup--dbg.exe" to "\..\Deploy\MyProject-Setup--dbg.exe".
Done Building Project "C:\src\tfs\MyProject\Dev\src\Installer\Bootstrapper\Bootstrapper.wixproj" (Rebuild target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:26.43
rseanhall commented 2 years ago

I can't reproduce this.

C:\Users\admin\AppData\Local\Temp\CustomV3Theme_20220120085511.log

[05A8:0BE8][2022-01-20T08:55:11]i001: Burn v3.11.2.4516, Windows v10.0 (Build 19041: Service Pack 0), path: C:\Users\admin\AppData\Local\Temp\{837AFC19-230A-4EA5-A4AD-AF30B56F991E}\.cr\CustomV3Theme.exe
...
[1A78:1DC8][2022-01-20T08:55:16]i305: Verified acquired payload: NetFx452Redist_local at path: C:\ProgramData\Package Cache\.unverified\NetFx452Redist_local, moving to: C:\ProgramData\Package Cache\89F86F9522DC7A8A965FACCE839ABB790A285A63\redist\\NDP452-KB2901907-x86-x64-AllOS-ENU.exe.
...
[1A78:11E8][2022-01-20T08:55:16]i301: Applying execute package: NetFx452Redist_local, action: Install, path: C:\ProgramData\Package Cache\89F86F9522DC7A8A965FACCE839ABB790A285A63\redist\\NDP452-KB2901907-x86-x64-AllOS-ENU.exe, arguments: '"C:\ProgramData\Package Cache\89F86F9522DC7A8A965FACCE839ABB790A285A63\redist\\NDP452-KB2901907-x86-x64-AllOS-ENU.exe" /q /norestart /ChainingPackage "CustomV3Theme" /log "C:\Users\admin\AppData\Local\Temp\CustomV3Theme_20220120085511_000_NetFx452Redist_local.log.html"'

Burn manifest

<Payload Id="NetFx452Redist_local" FilePath="redist\\NDP452-KB2901907-x86-x64-AllOS-ENU.exe" FileSize="69999448" Hash="89F86F9522DC7A8A965FACCE839ABB790A285A63" Packaging="embedded" SourcePath="a1" Container="WixAttachedContainer" />
<ExePackage Id="NetFx452Redist_local" Cache="yes" CacheId="89F86F9522DC7A8A965FACCE839ABB790A285A63" InstallSize="69999448" Size="69999448" PerMachine="yes" Permanent="yes" Vital="yes" RollbackBoundaryForward="WixDefaultBoundary" LogPathVariable="NetFx452FullLog" RollbackLogPathVariable="WixBundleRollbackLog_NetFx452Redist_local" DetectCondition="NETFRAMEWORK45 &gt;= 9979893" InstallArguments="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;" UninstallArguments="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;" RepairArguments="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx452FullLog].html&quot;" Repairable="yes" Protocol="netfx4"><PayloadRef Id="NetFx452Redist_local" /></ExePackage>
rseanhall commented 2 years ago

I can reproduce this in v3.11.2 if the value of the WixVariable is an absolute path.

<WixVariable Id="NetFx452RedistPackageDirectory" Value="C:\path\to\redist\" Overridable="yes" />

This was already fixed in v4 in https://github.com/wixtoolset/Core/pull/201.