Forum Discussion
File redirection question
Hi,
This file redirection feature is very confusing to me. I have an application that writes to the temp folder (in localappdata) and the roaming appdata folder. Right now these files are stored in localappdata\packages\appname\localcache (or something like that).
I want to store these files in their original location outside the package. So in appdata\roaming and in appdata\local\temp on the normal drive, so native.
Can this be achieved with file redirection?
Let's say I want to redirect all localappdata files and all roaming appdata files. Would this be the config or do I need something else? The base and patterns is not really clear to me.
I appreciate any help. Thanks.
"redirectedPaths": {
"knownFolders": [
{
"id": "LocalAppData",
"relativePaths": [
{
"base": "C:",
"patterns": [
".\\"
]
}
]
},
{
"id": "RoamingAppdata",
"relativePaths": [
{
"base": "C:",
"patterns": [
".\\"
- AppsPackGBrass Contributor
martijnk79 might be worth checking out the latest release of MSIX Packaging Tool 1.2023.1005.0 as the GUI is quite useful now for the fixups.
I had a similar query regarding the config.json patterns and currently experimenting with the syntax. It seems that it follows a json regex format which could be checked using the checker https://regexr.com/3opa6.- martijnk79Brass Contributor
Yes, been using that since the preview. Works like a charm. I can even convert my old App-V packages and just use the PSF fixes and I'm done in minutes. It's getting better and better 🙂
Answers for three scenarios:
1) First of all, if you don't have any VFS\AppData files inside the package, you don't need to redirect that folder, and you would get the effect of those write attempts going to the original location. To achieve this, add the "isExclusion" entry to the entry for AppData.
2) If the app needs visibility to VFS\AppData files from the package but you want the app to be able to update/add to them but have the updated/new files under the user's AppData folder this can be achieved.
2A) The FileRedirectionFixup has a feature (not added to the MfrFixup I just realized) that allows you to add an entry in a PackageRelative entry of the FileRedirectionFixup. It is called "redirectTargetBase". RetargetBase is an override to indicate that the entry should not redirect to the package redirection area, but to this specific location.
But certain locations, especially AppData (as in the user's AppData/Remote folder) are subject to being redirected by the container at a level lower than the PSF and we can't control that from happening. But is you specify the value of "redirectTargetBase" to a path that looks like something else you can. For example, let's say that your system uses FolderRedirection to map the AppData/Roaming to a home drive already. Then if you specify the value of the home drive folder, the redirection will go there and the container will not interfere.
2B) The third alternative is for situation where another product is being used for general user redirections, such as FsLogix, Microsoft UEV, and Ivanti for example. These products also redirect at a level lower than the PSF, and in this case customers generally let the PSF redirect to the WritableRootFolder and then add a rule in those products to redirect the WritableRootFolder to wherever they store things.
See:
MSIX-PackageSupportFramework/fixups/FileRedirectionFixup at develop · TimMangan/MSIX-PackageSupportFramework (github.com) scroll down for specific information on the json entry for the PackageRelative entries.
Also the general Wiki page for the FileRedirectionFixup:
Fixup: FileRedirectionFixup · TimMangan/MSIX-PackageSupportFramework Wiki (github.com)
- martijnk79Brass ContributorThanks for the extensive answer! Option 1 would be sufficient for us, but somehow it's not working. By adding the 'isExclusion' entry I assume you mean in the packager I go to files ,right-click the directory and choose 'Add Exclusion' is what I did. Am I correct?
I also tried to add '[{AppData}]' to the global exclusion list but files still appear under AppData\Local\Packages\<PackageName>\LocalCache\Roaming.
Which is weird, because the TEMP directory is excluded as well and those do show up outside of the package. - martijnk79Brass Contributor
You probably mean this right? For some reason when I add the file redirection fixup, the app won't launch any longer. With procmon I see an invalid parameter error.
No. In option 1 you are not including the FileRedirectionFixup at all. If you need the fixup, you are looking at option 2.
In Option 2, you need to edit the config.json to be more like this:
"redirectedPaths": {
"knownFolders": [
{
"id": "AppData",
"relativePaths": [
{
"base": "C:",
"patterns": [
".\\"
]
},
"IsException": "true"
]
},...
But in all honesty I don't use the new built-in PSF that the Packaging Tool now has; it is over 2 years out of date with changes. So I can't swear that will work with that version of the PSF. Instead, I would use PsfTooling, which has an up-to-date PSF, while in monitoring mode of the Packaging Tool (right after you installed the app) to add and configure the PSF.
- Sushant_BansalMicrosoft
Along with trying out community suggestions to resolve this issue through redirectTargetBase, Could you let us know more details on the issue you are facing of having appdata in package's appdata folder (localappdata\packages\appname\localcache). It is usually not recommended to write any MSIX application app data outside of Package AppData folder (localappdata\packages\appname\).
- martijnk79Brass ContributorYes I did some research on it and it seems to be by design that it writes to that directory. No big deal since FSLogix is saving that location to the profile. So I just removed the redirecttargetbase, not redirecting anything right now and will leave it like this. It's just that some users want to manipulate that file, so I just have to instruct them of the new location.
Thanks.