Updating a windows service project to .NET 5, System.Configuration.Installer, how can I add it to my project?

Viewed 6203

Now that .NET 5 has been released I thought I'd look into upgrading some of the applications we have, and in one of them we have a windows service.

It seems that some of the namespaces that we rely on, one of them being System.Configuration.Install, doesn't exist in .NET 5 out of the box. I'm assuming there is a trick to it, like adding support for Windows forms does it with the <UseWindowsForms>true</UseWindowsForms>, or that there is a nuget package I can add that will provide the missing bits but after trying for about an hour to find the right thing I thought I'd ask here instead.

Is there a way to bring that namespace and other related bits into a .NET 5 project? If so, how?

And yes, I have set target framework to net5.0-windows first.

1 Answers

There are no plans to port this to .NET Core. There's a Github issue discussion about this. The source is getting released to Microsoft/References this very month but the PR wasn't merged yet. Some people have decompiled the classes and created packages from it, like Core.System.Configuration.Install

Few people would recognize that namespace as the classes used to "simplify" Windows Installer actions much less use it. I think last time I used it was 2004? 2005? I've used proper installers generators after that and lately, declarative configuration management scripts like Powershell DSC or Puppet.

It's probably easier to write the PowershellDSC script that defines the services, counters, event logs to install than try to create the equivalent MSI actions. Never mind deploying to more than one servers.

Another option may be to wait for a week or two until the source code is merged into ReferenceSource or wait until someone works out the kinks and packages it.

Related