David H
David H

Reputation: 151

Wix4 C# CustomAction project compile error - WixToolset.Dtf.WindowsInstaller reference

I am looking to write my first C# CustomAction project in .net7 using Wix4.

I have a very simple class in the project with one function decorated with the CustomAction attribute.

The reading that I have carried out, as well as a clone of the Wix4 repo suggested I just needed to add the following NuGet reference to my cs project file.

When I come to compile I get two errors:

    Invalid argument: WixToolset.Dtf.WindowsInstaller.dll must be included in the list of support files. 
     If using the MSBuild targets, make sure the assembly reference has the Private (Copy Local) flag set.
    The command ""******\..\tools\WixToolset.Dtf.MakeSfxCA.exe" "*****" "****\.nuget\packages\wixtoolset.dtf.customaction\4.0.1\build\..\tools\x86\SfxCA.dll" "****\obj\Debug\net7\****.dll" "****\obj\Debug\net7\****.CA.rsp"" exited with code 1

(Reported as an error in WixToolset.Dtf.CustomAction.targets code MSB3073)

As per sample CA project in the Wix4source, I have just one NuGet package reference to WixToolset.Dtf.CustomAction - though I can't get the Wix4 Custom Action project to build in VS2022 either.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="WixToolset.Dtf.CustomAction" Version="4.0.1" />
  </ItemGroup>

</Project>

I have a test class as follows in the project:

using WixToolset.Dtf.WindowsInstaller;

namespace TestCustomAction
{
    public static class DemoCustomAction
    {
        [CustomAction]
        public static ActionResult TestAction(Session session)
        {
            return ActionResult.Success;
        }
    }
}

Upvotes: 9

Views: 1770

Answers (1)

David H
David H

Reputation: 151

So after a lot of digging, the conclusion was I should not have been making use of .net7 or any core editions of .net. There is a Wix4 Custom Action project template provided by FireGiant as part of their Heatwave product. This only makes use of .Net Framework. I am now up and running on .Net Framework 4.8 for my Custom Action project. This is a shame as all other C# projects in my solution are .net7.

Upvotes: 6

Related Questions