title: How to build MSI for .net core 7 worker service as windows service using Installer (WIX/ Visual Studio Installer Projects)
body: <p>How to build MSI for .net core 7 worker service as windows service using Installer (WIX/ Visual Studio Installer Projects)</p>
  <p>net core worker service that will be used as a windows service.
  Program .cs</p>
  <pre><code>IHost host = Host.CreateDefaultBuilder(args)
  .ConfigureLogging(options =&gt;
  {
      if (OperatingSystem.IsWindows())
      {
          options.AddFilter&lt;EventLogLoggerProvider&gt;(level =&gt; level &gt;= LogLevel.Information);
      }
  })
  .ConfigureServices(services =&gt;
  {
      services.AddHostedService&lt;Worker&gt;();
  
      if (OperatingSystem.IsWindows())
      {
          services.Configure&lt;EventLogSettings&gt;(config =&gt;
          {
              if (OperatingSystem.IsWindows())
              {
                  config.LogName = &quot;Prith Service&quot;;
                  config.SourceName = &quot;Prith Worker Service&quot;;
              }
          });
      }
  })
  .UseWindowsService()
  .Build();
  </code></pre>
  <p>I have tried building the Installer using WIX tool  (<a href="https://wixtoolset.org/documentation/manual/v3/howtos/general/install_windows_service.html" rel="nofollow noreferrer">https://wixtoolset.org/documentation/manual/v3/howtos/general/install_windows_service.html</a>)
  I am getting an error on service installation &quot;Service ''(PrithWinService) failed to start. Verify that you have sufficient privilege to start system service.&quot;
  The same WIX installer project code works fine for .net framework windows project.</p>
  <p>I also looked into using Visual Studio Installer Project, using the Setup Project.
  The installation will work but it will not be set up as a service, (we don't want to manually add that as a windows service).
  In .net framework windows service, we can add an installer to the service to do that.
  In .net core worker service there is no such option, I tried to add the installer manually just to find out .net core doesn't have access to &quot;System.Configuration.Install.Installer&quot;</p>
  <p>Any suggestion on how to have the installer project?</p>