Support System.Configuration.Install for dotnet core. Used version from full framework .NET 4.0.
Help support the project:
Sample usage TestInstaller.cs
using System.Collections;
using System.ComponentModel;
using System.IO;
namespace TestInstaller
{
[RunInstaller(true)]
public class TestInstaller:Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
File.Create("test");
}
public override void Uninstall(IDictionary savedState)
{
File.Delete("test");
base.Uninstall(savedState);
}
}
}
InstallUtil:
class Program
{
static int Main(string[] args)
{
Console.WriteLine($"InstallUtil - {Assembly.GetExecutingAssembly().GetName().Version}");
try
{
ManagedInstallerClass.InstallHelper(args);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return -1;
}
return 0;
}
}
We can use installUtil as global tool (https://github.com/flamencist/InstallUtil/)
dotnet add package Core.System.Configuration.Install
var log = new StringBuilder();
InstallerLogHandler.Instance.OnLog += (source, message) => { log.AppendLine(message); };
ManagedInstallerClass.InstallHelper(new[] {"TestInstaller.dll"});
Console.Write(log);
ManagedInstallerClass.InstallHelper(new[] {"-LogToConsole=True","TestInstaller.dll"});
Syntax looks like for InstallUtil: [-u | -uninstall] [option [...]] assembly [[option [...]] assembly] [...]]
InstallUtil help:
InstallUtil executes the installers in each given assembly.
If the -u or -uninstall switch is specified, it uninstalls
the assemblies, otherwise it installs them. Unlike other
options, -u applies to all assemblies, regardless of where it
appears on the command line.
Installation is done in a transactioned way: If one of the
assemblies fails to install, the installations of all other
assemblies are rolled back. Uninstall is not transactioned.
Options take the form -switch=[value]. Any option that occurs
before the name of an assembly will apply to that assembly's
installation. Options are cumulative but overridable - options
specified for one assembly will apply to the next as well unless
the option is specified with a new value. The default for all
options is empty or false unless otherwise specified.
Options recognized:
Options for installing any assembly:
-AssemblyName
The assembly parameter will be interpreted as an assembly name (Name,
Locale, PublicKeyToken, Version). The default is to interpret the
assembly parameter as the filename of the assembly on disk.
-LogFile=[filename]
File to write progress to. If empty, do not write log. Default
is <assemblyname>.InstallLog
-LogToConsole={true|false}
If false, suppresses output to the console.
-ShowCallStack
If an exception occurs at any point during installation, the call
stack will be printed to the log.
-InstallStateDir=[directoryname]
Directory in which the .InstallState file will be stored. Default
is the directory of the assembly.
Individual installers used within an assembly may recognize other
options. To learn about these options, run InstallUtil with the paths
of the assemblies on the command line along with the -? or -help option.
This software is distributed under the terms of the MIT License (MIT).
Alexander Chermyanin / LinkedIn
Contributions and bugs reports are welcome.