oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.12k stars 175 forks source link

.Net 8 project with external dependency fails to build #1649

Open Davidvanluijk opened 1 month ago

Davidvanluijk commented 1 month ago

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

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?

oleg-shilo commented 1 month ago

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

Davidvanluijk commented 1 month ago

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)

oleg-shilo commented 1 month ago

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.