If you want to create a solution that builds the foreground application and the background application into the same .APPX file it will require manual steps to combine the two projects.
- File>New>Project…
- Create a new Blank App
- Select desired target version and click OK when prompted for target version
- In Solution Explorer right-click on the solution and choose Add>New Project …
- Create a new Background Application
- Select desired target version and click OK when prompted for target version
- In Solution Explorer right-click on the background application Package.appxmanifest and choose View Code
- In Solution Explorer right-click on the foreground application Package.appxmanifest and choose View Code
-
At the top of the foreground Package.appxmanifest add xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" and modify IgnorableNamespaces to include iot.
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" IgnorableNamespaces="uap mp iot"> -
Copy the from the Background Application project Package.appxmanifest to the Foreground Application Package.appxmanifest. It should look like this:
<Applications> <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="MyForegroundApp.App"> <uap:VisualElements DisplayName="MyForegroundApp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="MyForegroundApp" BackgroundColor="transparent"> <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/> <uap:SplashScreen Image="Assets\SplashScreen.png" /> </uap:VisualElements> <Extensions> <Extension Category="windows.backgroundTasks" EntryPoint="MyBackgroundApplication.StartupTask"> <BackgroundTasks> <iot:Task Type="startup" /> </BackgroundTasks> </Extension> </Extensions> </Application> </Applications> -
In Solution Explorer right-click on the Foreground Application References node and choose Add Reference…
-
In Solution Explorer right-click the foreground application project and choose Unload Project, then right-click the background application project and choose Unload Project.
-
In Solution Explorer right-click on the foreground application project and choose Edit MyForegroundApp.csproj and then right-click on the background application project and choose Edit MyBackgroundApp.csproj.

-
In the background project file comment the following lines:
<!--<PackageCertificateKeyFile>MyBackgroundApplication_TemporaryKey.pfx</PackageCertificateKeyFile>--> <!--<AppxPackage>true</AppxPackage>--> <!--<ContainsStartupTask>true</ContainsStartupTask>--> -
In the foreground project file add true</ ContainsStartupTask> to the first PropertyGroup
<PropertyGroup> <!-- snip --> <PackageCertificateKeyFile>MyForegroundApp_TemporaryKey.pfx</PackageCertificateKeyFile> <ContainsStartupTask>true</ContainsStartupTask> </PropertyGroup> -
In Solution Explorer right-click on each project and choose Reload Project
- In Solution Explorer delete Package.appxmanifest from the background application
- At this point the project should build (and run the implementation you have added to the foreground and background applications).
Unfortunately, GitHub does not support downloading individual code.
Navigate to ms-iot/samples and select Clone or download to download the whole repository.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.











