Any project including a CustomAction seems to fail. My own project looks like this:
using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.Deployment.WindowsInstaller;
using WixSharp;
namespace Installer
{
class Program
{
static void Main()
{
var project = new Project("Test",
new Dir(@"%ProgramFiles%\Test",
new DirFiles(@"C:\Test\*.*")),
new Dir(@"%ProgramMenu%",
new ExeFileShortcut("Test", Path.Combine("[INSTALLDIR]", "Launcher.exe"),
arguments: "")
{ WorkingDirectory = "[INSTALLDIR]" }),
new ManagedAction(CustomActions.MyAction));
project.GUID = new Guid("93fefff9-91b2-4c44-8b13-9aad00c8f6a3");
project.Platform = Platform.x64;
project.Version = new Version(2, 0, 0, 0);
project.UI = WUI.WixUI_ProgressOnly;
project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
project.BuildMsi();
}
}
public static class CustomActions
{
[CustomAction]
public static ActionResult MyAction(Session session)
{
MessageBox.Show("Test", "Test");//Environment.GetCommandLineArgs().ConcatItems(" "));
session.Log("Begin MyAction Hello World");
return ActionResult.Success;
}
}
}
Also, I tried building the AdminInstall sample in Visual Studio, which also fails to build. Still a problem with the VS integration?
Can you confirm that it is still failing for you with yesterday VS Project template update?
Confirmed. Still fails.
Let me know if there's anything I can provide to help diagnose.
i had same error. Try add to your CA, values like Return.check, When.before, Step.INSTALL, Condition.NOT_Installed. After added this parameters my error not appear anymore.
Just to rule out the environment as a suspect, tr to open and build the attached sample. It includes the NuGet package so you do not depend on you environment ability to download the packages.
WixSharp Setup3.zip
Confirmed - doesn't build.
The it means that your and my environments are different. The only WixSharp dependency that does not come from WixSharp package is WiX itself.
Any chance you have version 4? or even both v3.11 and v4?
My WIXSHARP_WIXDIR is set to C:\bin\WixSharp.1.9.3.0\Wix_bin\bin
No version 4 installed. It's very puzzling. I'll try it at home tonight with a completely different system.
Yes, that's odd.
My advice, minimize the amount of "variables in this equation". Replace project.Build(...) with project.BuildCmd(...). This wil prepare the WiX source files (*.wsx) and a batch file that can invoke WiX compilers directly and build the msi.
Effectively from that moment WixSharp is no longer in the picture. If one cannot build msi then it is either because there is a mistake in the produced wxs or there is a problem with the WiX compilers.
This would be the easiest way to minvestigate it.
It can't build it with BuildMsiCmd either.
Good. :)
The we have one suspect less.
What is the error output?
1>------ Build started: Project: WixSharp Setup3, Configuration: Debug Any CPU ------
1> WixSharp Setup3 -> C:\Downloads\WixSharp.Setup3\WixSharp Setup3\bin\Debug\WixSharpSetup.exe
1> Building MSI
1> <- Packing managed CA:
1> C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\MakeSfxCA.exe "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\%this%.CA.dll" "C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\x86\sfxca.dll" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\WixSharpSetup.exe" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\CustomAction.config" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\WixSharpSetup.pdb" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\bin\Debug\WixSharp.dll" "C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\Microsoft.Deployment.WindowsInstaller.dll"
1> ->
1>EXEC : error : C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\x86\sfxca.dll
1>
1> Unhandled Exception: System.ApplicationException: Cannot package ManagedCA assembly(%this%)
1> at WixSharp.Compiler.PackageManagedAsm(String asm, String nativeDll, String[] refAssemblies, String outDir, String configFilePath, Nullable`1 platform, Boolean embeddedUI, String batchFile)
1> at WixSharp.Compiler.ProcessCustomActions(Project wProject, XElement product)
1> at WixSharp.Compiler.GenerateWixProj(Project project)
1> at WixSharp.Compiler.BuildWxs(Project project, String path, OutputType type)
1> at WixSharp.Compiler.BuildWxs(Project project, OutputType type)
1> at WixSharp.Compiler.BuildCmd(Project project, String path, OutputType type)
1> at WixSharp.Compiler.BuildMsiCmd(Project project, String path)
1> at WixSharp.Compiler.BuildMsiCmd(Project project)
1> at WixSharp.Project.BuildMsiCmd(String path)
1> at WixSharp_Setup3.Program.Main() in C:\Downloads\WixSharp.Setup3\WixSharp Setup3\Program.cs:line 25
1>C:\Downloads\WixSharp.Setup3\packages\WixSharp.1.9.4\build\WixSharp.targets(6,5): error MSB3073: The command ""C:\Downloads\WixSharp.Setup3\WixSharp Setup3\bin\Debug\WixSharpSetup.exe" "/MSBUILD:WixSharp Setup3" "/WIXBIN:"" exited with code -532459699.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What is the target CLR in the project props?
.Net Framework 3.5
OK.
Try to define the assembly name explicitly, just in case it's not resolved correctly:
c#
new ManagedAction(CustomActions.MyAction)
{
ActionAssembly = typeof(CustomActions).Assembly.Location
}
If this does not help see if you can build ManagedProject with events. It defines managed assembly slightly differently.

One thing is for sure we are failing to pack the managed CA.
The managed setup also fails to build.
Although I can see that the WixSharp Setup4.g.wxs file is missing.
For completeness, I have:
WixSharp Project Templates 1.7.1
Visual Studio 2017 Enterprise 15.9.6
That's normal. We are failing before it is generated.
We are failing to generate the WiX assembly package.
Collect the exact CLI command and try to execute it command prompt.
It will be something like that:
C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\MakeSfxCA.exe "C:\Downloads\WixSharp.Setup3\WixSharp Setup3%this%.CA.dll" "C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\x86\sfxca.dll" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\WixSharpSetup.exe" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\CustomAction.config" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\WixSharpSetup.pdb" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\bin\Debug\WixSharp.dll" "C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\Microsoft.Deployment.WindowsInstaller.dll"
For some reason MakeSfxCA.exe (one of WiX compilers) is failing.
See if it produces any extra error output that WixSharp may be missing.
Progress!!
OK, the exact command line is:
C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\MakeSfxCA.exe "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\WixSharpSetup.CA.dll" "C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\x86\sfxca.dll" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\bin\Debug\WixSharpSetup.exe" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\CustomAction.config" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\bin\Debug\WixSharpSetup.pdb" "C:\Downloads\WixSharp.Setup3\WixSharp Setup3\bin\Debug\WixSharp.dll" "C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\Microsoft.Deployment.WindowsInstaller.dll"
It still fails, with the error:
Error: C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\x86\sfxca.dll
Went to have a look at that file, and the C:\bin\WixSharp.1.9.3.0\Wix_bin\sdk\x86\ directory is empty. So is the x64 directory, so is the wixui directory.
I downloaded a fresh copy of 1.9.4, installed it, and it's now building.
So somehow, the installation in my C:\bin folder had been partially missing. I'm not sure how that happened. But all seems fine now. Thanks for your help getting to the bottom of it!
Great.
I am glad we sorted it out