I'm trying to make a Windows service in .NET 8 to go along with a WinUI3 desktop application. The service program works fine when debugging in Visual Studio, but I'm running into issues packaging it. I'm trying to follow the instructions here: .NET Core Service Guide and MSIX Service Guide, but I'm not able to get the package to successfully build.
The MSIX instructions say to add a <desktop6:Service>
element to the Package.appxmanifest
file, which I have done. The documentation says that the Executable
and EntryPoint
Attributes in the parent desktop6:Extension
are optional, but I get an error when building the package without them. If I try to specify them, I get this error: Manifest validation error: Line 33, Column 136, Reason: The file name "BootManagerService.exe" declared for element "*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='Extensions']/*[local-name()='Extension' and not(@Category='windows.backgroundTasks' or @Category='windows.appService')]" doesn't exist in the package.
Here is the relevant section of my Package.appxmanifest
:
<Extensions>
<desktop6:Extension
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
Category="windows.service"
Executable="BootManagerService.exe"
EntryPoint="BootManager.Service.Program">
<desktop6:Service
Name="BootManager Service"
StartupType="auto"
StartAccount="localSystem">
</desktop6:Service>
</desktop6:Extension>
</Extensions>
I'm not sure if I'm using the desktop6:Service
element correctly or if I have another issue. Anyone have any suggestions?
The error you're getting is that you are missing a file BootManagerService.exe
from your MSIX package.
MakeAppx.exe
will validate that any target entry points detailed in the AppxManifest.xml
and ensure that the file targeted is present in the MSIX package.
I've sanitized this copy of the AppXmanifest.xml
, but this is a live app out with customers.
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:build="http://schemas.microsoft.com/developer/appx/2012/build"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="build uap uap3 uap10 desktop6 rescap">
<Identity Name="Service" Publisher="CN=Service" Version="2.0.0.0" ProcessorArchitecture="x64" />
<Properties>
<DisplayName>Service</DisplayName>
<PublisherDisplayName>Service Group Limited</PublisherDisplayName>
<Description>Service </Description>
<Logo>Assets\Logo.png</Logo>
<uap10:PackageIntegrity>
<uap10:Content Enforcement="on" />
</uap10:PackageIntegrity>
</Properties>
<Resources>
<Resource Language="en-us" />
</Resources>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19044.0" MaxVersionTested="10.0.22631.0" />
<TargetDeviceFamily Name="Windows.Server" MinVersion="10.0.17763.0" MaxVersionTested="10.0.20348.0" />
</Dependencies>
<Capabilities>
<rescap:Capability Name="packagedServices" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<Applications>
<Application Id="Service"
Executable="VFS\ProgramFilesX64\Service.exe"
EntryPoint="Windows.FullTrustApplication">
<uap3:VisualElements
DisplayName="Service"
Description="Service"
BackgroundColor="#3a0951"
Square150x150Logo="Assets\Logo.png"
Square44x44Logo="Assets\Logo.png"
AppListEntry="none"
VisualGroup="AVEVA" />
<Extensions>
<desktop6:Extension Category="windows.service"
Executable="VFS\ProgramFilesX64\Service.exe"
EntryPoint="Windows.FullTrustApplication">
<desktop6:Service Name="Service"
StartupType="auto"
StartAccount="localService" />
</desktop6:Extension>
</Extensions>
</Application>
</Applications>
</Package>