wixsharp icon indicating copy to clipboard operation
wixsharp copied to clipboard

.Net 8 project with external dependency fails to build

Open Davidvanluijk opened this issue 1 year ago • 3 comments

A follow up from: Cannot build .net 8 example project #1574

I've been able to build the sample project and convert one of our Wix 3.x based projects using .net8 and WixSharp.Core/WixSharp.Msi.Core 2.4.0. However: we have a couple of installer projects which use common code from a shared library. This I can't get to work. The setup

  • A library project containing utilities like setting all the common project settings, but also containing a couple of custom actions. I added <PublishAot>true</PublishAot>
  • A installer project which references the library project.

The build currently fails on (InstallerPartBase being a class in the library project): 1>aot.entrypoints.cs(17,66): Error CS0012 : The type 'InstallerPartBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'project.Installer, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. [C:\projectl.Installer\bin\AnyCPU\Release\aot.project.Installer\project.Installer.aot.csproj]

How do I fix this? Can I have CustomActions and/or dependent types in a separate library?

Davidvanluijk avatar Sep 30 '24 13:09 Davidvanluijk

Yes, you can. The was just a question about that: https://github.com/oleg-shilo/wixsharp/issues/1648

A word of warning, ensure that your utility is compiled as standardlibrary2 image

And.... .NET Core (e.g. .NET8) support is rather limited. Some features may be impacted. See this wiki: https://github.com/oleg-shilo/wixsharp/wiki/.NET-Core-support

oleg-shilo avatar Oct 01 '24 06:10 oleg-shilo

I've got it to compile/work now: I am using a baseclass from the library for adding actions to the installer. This happens to be the same class which the customaction is defined in. This doesn't work, you will get the Error CS0012 : The type 'InstallerPartBase' is defined in an assembly that is not referenced. I now define the customaction in a static class separate from the adding of the customaction to the installer, which works.

FYI: The generated code also fails on enum's defined in a class, I needed to change that as well.

With WixSharp.Core and WixSharp.Msi.Core can I still influence the wix.exe that is being called? I used to do this:

...
<PackageReference Include="wix" Version="3.14.1" />
<PackageReference Include="WixSharp.bin" Version="1.25.3" />
...
<Exec Command="&quot;$(TargetPath)&quot; &quot;/MSBUILD:$(ProjectName)&quot; /WIXBIN:$(WixExtDir) /Configuration:$(Configuration) /Platform:$(Platform)" WorkingDirectory="$(ProjectDir)" />

Which ensured Wix 3.14.1 was used, I don't see how this works with the Core packages? (Then using Wix version 4.0.5)

Davidvanluijk avatar Oct 01 '24 15:10 Davidvanluijk

If you are interested in controilling wix.exe then you can use WixTools to set the desired version:

WixTools.SetWixVersion(Environment.CurrentDirectory, "5.0.0");

Note, wix.exe is part of the Wix4 toolser. WiX3 uses completely different set of compilers. And Core packages are only designed to be used with WiX4.

oleg-shilo avatar Oct 02 '24 12:10 oleg-shilo