1

I am integrating Wix into daily builds, and I am trying to build a custom action without having Wix Toolset installed locally. I am therefore using the binaries provided by wix, and they work fine for the basic installer itself.

The problem arises when I try to build the C# custom action, the build itself passes, but it only generates the .dll, and not the CA.dll which I require. I suspect the problem is in the .csproj itself that I modified

.csproj for the custom action:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{970397C2-1306-47C4-8E61-20949BD061E3}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>InstallerExtensions</RootNamespace>
    <AssemblyName>InstallerExtensions</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
    <PropertyGroup>
        <WixToolPath>$(SystemDrive)\WixTools\</WixToolPath>
        <WixTargetsPath>$(WixToolPath)wix.targets</WixTargetsPath>
        <WixExtDir>$(WixToolPath)</WixExtDir>
        <WixTasksPath>$(WixToolPath)WixTasks.dll</WixTasksPath>
        <WixSdkPath>$(WixToolPath)sdk\</WixSdkPath>
        <WixCATargetsPath>$(WixSdkPath)wix.nativeca.targets</WixCATargetsPath>
    </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Xml">
      <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Deployment.WindowsInstaller">
    <HintPath>$(WixSdkPath)Microsoft.Deployment.WindowsInstaller.dll</HintPath>
      <Private>True</Private>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Configuration.cs" />
    <Compile Include="CustomAction.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Content Include="CustomAction.config" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\Company\Company.Util\Company.Util.csproj">
      <Project>{02c36290-8ce5-43ec-a21a-b61151e17642}</Project>
      <Name>Company.Util</Name>
    </ProjectReference>
  </ItemGroup>
    <Import Project="$(WixCATargetsPath)" />
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
  • WiX VS Extension installs a project template WiX C# Custom Action project. Use that to create a new project and compare the .CSPROJ files. – Christopher Painter Mar 05 '21 at 13:36
  • Hi, the template uses the installed version of wix toolset, and I use the binaries. The imports are all the same – Professional_Amateur_Dev Mar 05 '21 at 13:45
  • I have never tried this. Did you check the details on `MakeSfxCA.exe` here (bottom): https://www.firegiant.com/wix/tutorial/events-and-actions/how-to-manage/ - this binary creates a self-extracting managed MSI CA in dll form that MSI can invoke. Locate the help file `DTF.chm` in the WiX installation folder for more details. Search for `MakeSfxCA.exe`. [An older answer on DTF and the custom action DLLs](https://stackoverflow.com/a/58145510/129130). – Stein Åsmul Mar 06 '21 at 02:59
  • 1
    Personally I would make the WiX toolset a prerequisite software for the build process. However, the MakeSfxCA.exe is discussed in [this thread](http://lists.wixtoolset.org/pipermail/wix-devs-wixtoolset.org/2020-June/001564.html) (first message in thread) on the WiX dev mailing list. Click the "Next message (by thread)" link to go to the next message. There are about 16 in [the thread](http://lists.wixtoolset.org/pipermail/wix-devs-wixtoolset.org/2020-June/thread.html#1564). Make sure to read [this answer](http://lists.wixtoolset.org/pipermail/wix-devs-wixtoolset.org/2020-June/001601.html) – Stein Åsmul Mar 06 '21 at 13:44
  • I will check it out, thank you – Professional_Amateur_Dev Mar 10 '21 at 10:10

1 Answers1

1

add this to the end of the project file:

  <Import Project="$(WixCATargetsPath)" Condition=" '$(WixCATargetsPath)' != '' " />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets" Condition=" '$(WixCATargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets') " />
  <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixCATargetsImported)' != 'true' ">
    <Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
  </Target>
Andrew Rebane
  • 199
  • 3
  • 12