Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use CustomAction - "No CA or UI entry points found in module" #1624

Closed
exedor opened this issue Sep 2, 2024 · 4 comments
Closed

Comments

@exedor
Copy link

exedor commented Sep 2, 2024

Hi, thank you for putting this great project together! I did a comprehensive writeup of what I'm seeing here:
https://stackoverflow.com/questions/78938862/how-to-compile-wixsharp-managed-actions

I'm running Visual Studio 2022 with the latest updates. Repro steps are:

  • Create a new project with the project template.
  • Add simple CustomAction.
  • Try to build project.

Compilation will fail. I cannot figure out how to make these work nor the BinaryFileAction from the Samples to work.. Either will do. This is a very stripped down example I'm working with. The larger project uses all kinds of things including Dir, File, CreateUser, Registry Entries, Firewall ports, and more. All of that works. The ever elusive, yet powerful CustomAction continues to evade me.

using System;
using WixSharp;
using WixToolset.Dtf.WindowsInstaller;


namespace WixSharpInstall
{
    internal class Program
    {

        static void Main()
        {
            var project = new Project("My Proj",
                new ManagedAction(CATest, Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed)
                )
            {
                Platform = Platform.x64,
                GUID = new Guid("23ba4376-a6c1-4bec-af74-16c672702d9d"),
            };
            project.BuildMsi();
        }

        [CustomAction]
        public static ActionResult CATest(Session session)
        {
            return ActionResult.Success;
        }
    }
}

Here's the full text of the error:

Error: Invalid argument: No CA or UI entry points found in module: C:\Users\Jared\source\repos\VoyagerPlatform\WixSharpTest\bin\Debug\net472\WixSharpTest.exe

Unhandled Exception: System.ApplicationException: Cannot package ManagedCA assembly(%this%)
at WixSharp.Compiler.PackageManagedAsm(String asm, String nativeDll, String[] refAssemblies, String outDir, String configFilePath, Nullable`1 platform, Boolean embeddedUI, String batchFile)
at WixSharp.Compiler.ProcessCustomActions(Project wProject, XElement product)
at WixSharp.Compiler.GenerateWixProj(Project project)
at WixSharp.Compiler.BuildWxs(Project project, String path, OutputType type)
at WixSharp.Compiler.BuildWxs(Project project, OutputType type)
at WixSharp.Compiler.Build(Project project, String path, OutputType type)
at WixSharp.Compiler.Build(Project project, OutputType type)
at WixSharp.Project.BuildMsi(String path)
at WixSharp.Program.Main() in C:\Users\Jared\source\repos\VoyagerPlatform\WixSharpTest\Program.cs:line 44

Can someone please tell me why this won't even build? The CustomActions sample project looks like it might be outdated. It's also confusing because it creates a "Binaries" array, which appears to be completely pointless. Just creating a new Id does not seem to make it usable in the project. That throws errors as well.

@oleg-shilo
Copy link
Owner

Create a new project with the project template.

I assume you are referring to the WixSharp template, not just a console app. Right?

But the real problem is your Program class. It has to be public. Unfortunately, WiX compiler only tells you that it did not find the entry point but does not say that "it's there but not public"

And, if you use the template the the class will be already public. so the user cannot make this mistake.

@exedor
Copy link
Author

exedor commented Sep 2, 2024

Ahh, of course! Thank you!! Yes, I am referring, specifically to the project template named "WixSharp Setup (WiX4)" and I did use that template to create both projects.

OK, the Program class in my other project is marked internal and it works just fine, but the reason it works is because it isn't using Custom Actions. I see now. Under the covers, the Custom Actions must be built using a separate assembly so the one loses access to the other. Thank you very much!

So I guess the real question is why does the Program class get a an "internal" designation when using that project template?

@oleg-shilo
Copy link
Owner

oleg-shilo commented Sep 3, 2024

an "internal" designation when using that project template?

It is a mistake. It should be public. Fixed now.
Will fix the templates in the next release.

As for internal... it's interesting...

I checked. And if I change the public to internal for the CustomActions class in the DTF_MangedCA project. Then it fails with the very same message:

image

@exedor
Copy link
Author

exedor commented Sep 3, 2024

Makes sense. Thank you! Feel free to close whenever it makes sense for you issue/release management process.

oleg-shilo added a commit that referenced this issue Sep 21, 2024
- Remove Caliburn.Micro dependency for WPF UI
- #1638: Simplify Custom UI
- #1641: How to set or use Launchcondition Action in Wix#
- #1613: Hidden child features in FeaturesDialog.UserSelectedItems
- #1604: Some strings in Dialogs from .wxl are not replaced in Custom WPF UI
- #1637: Custom WPF FeaturesDialog (possibly default too) non-functional.
- Improved VSTemplates. Triggered by #1624
- Updated VS project Templates for supporting Caliburn.Micro removal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants