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

Unable to use Third party dll in custom actions. #1648

Closed swapnilpachkude closed 1 month ago

swapnilpachkude commented 1 month ago

I have created wixsharp application that creates the config.json file after installation is completed. I have used the Newtonsoft.json package in application. After installation it's not creating a json file.

Torchok19081986 commented 1 month ago

morning, first of all, which version of wixsharp do you use for msi creation ? Second: there is sample from oleg, where it shows how to call Assemblies / dll´s , in CA. Download latest release Folder. In Folder navigate to ... Source\src\WixSharp.Samples\Wix# Samples\DTF (ManagedCA)\Different Scenarios. Here is explanation, how to use third party assemblies in CA. AFAIK this works, only for wixtoolset 3.X, for 4.X you have to looks for latest description of CA and Assemblies.

oleg-shilo commented 1 month ago

Thank you @Torchok19081986, yep that is the folder containing all asm dependency scenarios samples.

@swapnilpachkude, most likely you forgot to add Newtonsoft assembly to your project.

you can do it either explicitly with the project.DefaultRefAssemblies.Add("<assembly>dll"); or even ask WixSharp compiler to add them automatically.

// Script is the build script class that defines your custom action.
project.AddCustomActionRefAssembliesOf(typeof(Script)); 

The technique works in all editions/versions of WixSharp.

swapnilpachkude commented 1 month ago

Hi @oleg-shilo @Torchok19081986, Thank you so much for the quick response and guidance. It's working now.

oleg-shilo commented 1 month ago

@Torchok19081986, yep the sample you quoted is the correct one.