2

I have read in some threads that MSIX will start to support also windows services from the January build. But I only seem to find information of how to migrate an existing installer containing a service to MSIX. How should I do if I want to create a completely new MSIX bundle from scratch, containing a UWP project and a Windows Service? I can´t seem to find no information about this no matter how much i search. If someone have succeeded in this it would be vary appriciated to hear how you did this!

I have a sollution in visual studio containing  a UWP project and a Windows Service Project. I try to simply add those two projects to a new windows application packaging project but no matter how I do this I only manage to install the UWP app from the created bundle. Is it still not possible to include the Service project in my MSIX? I get no errors when I build my sollution. I have simply added the UWP project and the service under "Applications" in my windows Application Packaging project.

I have also read that background tasks may be prefered to services in msix packages. But I am afraid that a background task may be a bit too limitied for my intentions. My main requirement for a service is not to have something running in the background, but to access functions outside the UWP sandbox. Like USB storage and other functionality. But maybe this can be achieved by a background task as well?

Maybe the MSIX sollution is a bad idea in my case, do you think I need to relay on some other packaging sollution for my projects instead? Like Wix or similar? I have very little experience in packaging installations so I prefer a tool that is as simple as possible.

Berglund
  • 73
  • 7
  • In UWP applications, you cannot use windows service. If background tasks have limited functionality for you, you can consider transforming your app with the help of a desktop bridge and creating an [app service](https://learn.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service?redirectedfrom=MSDN&f=255&MSPPError=-2147217396), here is an example: [AppService Bridge Sample](https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/AppServiceBridgeSample) – Richard Zhang Mar 04 '20 at 23:36
  • Thank you for the answer! I actually have used a Windows Service together with a UWP app in a previous project. In that project I was not part of creating the actual link between the service and the app but it definitely worked. We used the service link for UDP communication, storage access (USB) and windows logout function. The installation bundle was created with Wix toolkit and this created a msi file that installed both the UWP app and the service. But maybe a background task is a better way for handling theese tasks in a new App? I will look into your link and try to make it work. – Berglund Mar 05 '20 at 10:31
  • I wish you good research progress, if you have new content, please share it, it will help more people – Richard Zhang Mar 05 '20 at 12:23
  • I followed your link and ended up at this [project](https://blogs.windows.com/windowsdeveloper/2017/12/04/extend-desktop-application-windows-10-features-using-new-visual-studio-application-packaging-project/) The third example here lets me access functionality outside the UWP sandbox, which is what I was looking for. Seems to be working well so far! – Berglund Mar 06 '20 at 12:19

1 Answers1

0

The recommendation for apps in development is to use background tasks instead of trying to add a Windows Service. 

For the case where you're trying to access content outside the UWP container, you can consider adding a desktop extension component to your UWP package and then using that for your required functionality. Have a look at this blog post for more details - https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/