c# – Custom actions (.Net Standard 2.1) not working with Visual Studio Installer Projects for my Net Core 3.1 Application


I’m trying to use visual studio installer projects to make an installer for my .Net core 3.1 project. I’ve followed the guidance below for how to use installer projects with net core:

Visual Studio Installer Projects

I want the installer to perform a custom action on commit, so I created a .Net Standard 2.1 class library project and overrode this method:

(RunInstaller(true))
public partial class UpdateIniFile : Installer   {
    (System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand))
    public override void Commit(IDictionary savedState) {
       base.Commit(savedState);
       UpdateAndModifyIni();
       }
    }

As discussed in the article above, for a net core application, you publish the application then select ‘Publish Items’ for the project output group in the installer project.

When I’ve added custom actions to framework based projects in the past, I’d add the custom actions project as a primary output into the installer project then reference it in the custom actions screen of the installer project.

This however doesn’t seem to work for the current set of projects when I add the custom actions project to the installer project as a primary output. If I test the installer it creates, when the custom action runs I get this error:

Error 1001: Unable to get installer types in C:……IniFileUpdaterAction.dll assembly -> Unable to load one or more of the requested types

I’ve tried the other way round… attempting to publish the custom actions project and then adding it to the installer project as a ‘Publish Items’, but on attempting to publish the custom actions project I get this:

Publish has encountered an error. We were unable to determine the cause of the error

I saw in one response to the post linked below that there can be issues running custom actions when using the publish items output type, but I wondered, if this is the issue if there have been any workarounds, and if this is not the case, is there something else I’ve missed or am I going about adding the custom action in the wrong way.

How to package .NET Core 3 in Visual Studio Installer Project

Thanks very much in advance!