1

I have following component in installer

  <Component Id="my.dll" Guid="*" Win64="no">
    <File Id="my.dll" Name="my.dll" KeyPath="yes" ReadOnly="yes" DiskId="1" Source="$(var.TargetDir)/my.dll" />
  </Component>

In visual studio configuration manager for solution platform x64 the installer project is set to x64.

When building x64, the build is still failing on this part, looking for my.dll although Win64 is set to "no".

In the wixproj I have manually added by copying the x86 section:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
  <OutputPath>bin\$(Configuration)\</OutputPath>
  <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
  <DefineConstants>Debug</DefineConstants>
</PropertyGroup>

Did same for 'Release|x64'. and also tried removing following:

<Platform Condition=" '$(Platform)' == '' ">x86</Platform>

and also changing the x86 to x64 but this did not help.

Why is x64 build still regarding this line although Win64="no"?

grunt
  • 662
  • 1
  • 8
  • 24
  • If you want to exclude authoring, use the preprocessor as @SteinÅsmul suggests. `Win64` controls the component attributes, not whether it's included. – Bob Arnson Apr 07 '19 at 17:55

1 Answers1

0

Reference: Using Project References and Variables.


TargetPath: Maybe try to use $(var.ProjectName.TargetPath) instead of $(var.TargetDir)/my.dll. I think that is what is wrong. The TargetPath will be the whole path with file name for what you build. See the above "Reference" link for all these parameters (preprocessor variables).


Extra Notes: A couple of further things:

  • Notice the ProjectName section: if your Visual Studio project is called MyLittleProject, then you should add: $(var.MyLittleProject.TargetPath).
  • The Win64="no" attribute for the Component element in WiX files affects where the file is installed on the target system where end-user installation happens, not where the Visual Studio build files are located on disk after successful build:
    • Program Files (x86) (32-bit) or Program Files (64-bit)
    • Windows (64-bit) or SysWOW64 (32-bit, yes amazingly)

Quick Sample: This is from memory and probably not very good, but here is a sample of Preprocessor variables in action (got this long answer on such constructs):

<?if $(var.MyProjectName.Platform) = "x64" ?>      
  <Component>
     <File Source="C:\Test\Test1.exe" />
  </Component>
<?endif?>

<?if $(var.MyProjectName.Platform) = "Win32" ?>
  <Component>
     <File Source="C:\Test\Test2.exe" />
  </Component>
<?endif?>

<Component>
   <File Source="$(var.MyProjectName.TargetPath)" />
</Component>

Make sure the configuration is set to rebuild all projects including your WiX project. There could be unexpected exclusions. Notice how platform might say Win32 versus x64 for platforms (instead of the perhaps expected x86) - common errors. Inspect the compiled MSI. Also be sure to set a proper project build order (manipulate project dependencies).


sys.BUILDARCH: There is also the sys.BUILDARCH built-in variable, which has me a little confused to be honest. I have not used it. Search for it here: Preprocessor. And github.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • So can I control which files are included per platform (e.g `x64`) & which are ignored? – grunt Apr 07 '19 at 15:29
  • Might be a smarter way, but there are always [Preprocessor variables](http://wixtoolset.org/documentation/manual/v3/overview/preprocessor.html) that you can use. Will update the answer with a quick hint. And [a generic hint on how to search github.com](https://github.com/search?l=XML&q=%3C%3Fif+%24%28var.+Platform+Wix&type=Code) for clues (must be logged into github.com to work). – Stein Åsmul Apr 07 '19 at 16:11