4

When my UWP app builds, it goes into the output path of the current project. Inside this, there is always an additional folder called "AppX" that contains duplicates of everything.

When the same app installed from the store, there is no AppX folder associated with it. 

Why is there this useless folder of duplicated data when developing?

Jarryd
  • 572
  • 4
  • 13
  • 1
    That folder exists as well when you download an app from the Store. It is just very well hidden, c:\program files\windowsapps. Stores the content of the appx package so the program can run. It is not useless. – Hans Passant Feb 21 '17 at 08:37
  • No, there is just one copy of the application, and it's assets and content. There is no AppX folders of installed apps in the WindowsApps directory. – Jarryd Feb 21 '17 at 13:00

1 Answers1

4

With Visual Studio 2015 Update 3, we have added the option for developers to specify the layout path for their UWP apps. This determines where the package layout is copied to on disk when you build your app. By default, this property is set relative to the project’s root directory. If you do not modify this property, the behavior will remain the same as it has for previous versions of Visual Studio.

From MSDN source.

This folder will be generated when deploying and debuging. It actually is your app's debuging installedLocation path. You could use Package.Current.InstalledLocation.Path to test. The debuging app's installed location would be like this:

D:\App170221\AppPackage\bin\x86\Debug\AppX

Xie Steven
  • 8,544
  • 1
  • 9
  • 23
  • This just inverts my question. Why is there duplicate data in the debug directory then? Why is there two copies of my app? Using Package.Current.InstalledLocation.Path does point to the AppX, but I can also just use File.Exists() and risk looking into the wrong place, since there are two. – Jarryd Feb 21 '17 at 13:03
  • 3
    @Jarryd As I've said, this is just app's debuging installed location path. If you check that installed apps from windows store, you will find they're installed in `C:\Users\...\AppData\Local\Packages`, but when debuging in visual studio, the app will not be installed there. That's why the AppX folder existed in Debug directory. About `File.Exists()` method, since the uwp apps run in sandbox, so if you call it like this `File.Exists(@"D:\text.txt")`, it always return false, no matter if the file exists. In UWP, we should use Windows​.Storage APIs to do file operation. Thank you. – Xie Steven Feb 22 '17 at 02:44
  • So the AppX is an install folder then. When the app is packaged for submission, is the AppX folder involved? And we use File.Exists only within the scope of the app, so the save directory and the app directory at ApplicationData.Current.LocalFolder. Are you saying this will work during development, but fail on the store? – Jarryd Feb 23 '17 at 00:19
  • 3
    `is the AppX folder involved? ` No. `Are you saying this will work during development, but fail on the store?` Maybe, I have not explained clearly. What I meant in my above comment is `Windows Store apps run sandboxed and have very limited access to the file system. For the most part, they can directly access only their install folder and their application data folder. They do not have permission to access the file system elsewhere` Please check Rob's blog:[Skip the path: stick to the StorageFile](https://blogs.msdn.microsoft.com/wsdevsol/2012/12/04/skip-the-path-stick-to-the-storagefile/) – Xie Steven Feb 23 '17 at 02:00
  • Anyway, you don't need to care about AppX folder, it just is a debuging and deploying folder. It has nothing to do with package in windows store. – Xie Steven Feb 23 '17 at 02:04
  • I have a solution that can be built in four ways based on defines and store association to create four separate titles we have for sale on the Windows Store. Leftovers assets and content from one product affect another due to the AppX when switching between titles. Understanding the AppX is important to me. – Jarryd Feb 23 '17 at 03:12
  • One problem that this may cause is that AppContext.BaseDirectory will point to AppX folder during debugging but at run time to other location – IronHide Feb 15 '23 at 08:47