2

I develop client-server UWP app, and I want it to be deployed by sideloading (probably using WinAppDeployCmd or MDM) to the large set of devices by administrator. But to launch, my application needs to know server IP address, which varies for each customer. I need to pass this setting somehow during deployment by administrator to every device.

Is there a way to set remote application settings? Or pass an XML config file along with appx? Or any other way to add some parameters during installation process?

  • For "But to launch, my application needs to know server IP address" Could you please tell how your client application requires the server IP address? Inside the `Onlaunch()` method? Why not save the server IP information in a xml file inside the app package and update the file before you deploy? If I misunderstand you, please tell more details. – Sunteen Wu Apr 12 '17 at 07:20
  • UWP apps are working in "sandbox". AFAIK, there is no way to distribute config along with appx. The config file should be inside the appx. – Scavenger Apr 12 '17 at 07:23
  • As an example, using MSI installer for regular apps, I can create dialogs so user can set some properties during installation. And for instance user can set server IP address during installation, and then MSI installer will save this value to registry or config file, so installed app can use it. I am looking for similar process for UWP. – Vitaliy Nesterenko Apr 12 '17 at 16:37

1 Answers1

2

Unlike e.g. MSI, there's no option to pass along "initial data" with a package for installation. One option is to install the package and then add your 'data' e.g.

  1. Add-AppxPackage foo.appx
  2. appdata = ApplicationDataManager.CreateForPackageFamily(foo_pkg_family)
  3. appdata.LocalSettings.CreateContainer("x").values["y"] = z

Step 1 installs the package, most notably it will register the package for the user. That creates the package's appdata storage resources for the user. You can then use ApplicationDataManager (from a Win32/non-UWP process) to access appdata.

You may find AppData.exe handy. A simple exe using ApplicationDataManager to provide a cmdline interface to AppData. Given this or equivalent you could write a batch file

@ECHO Off
powershell -c Add-AppxPackage foo.appx
appdata.exe SET foopkgfamilyname local\configuration --value=x --type=string --data=y