SOLVED

MSIX - Permissions to App Folder?

%3CLINGO-SUB%20id%3D%22lingo-sub-1450568%22%20slang%3D%22en-US%22%3EMSIX%20-%20Permissions%20to%20App%20Folder%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1450568%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20an%20application%20which%20creates%20a%20log%20file%20in%20the%20application%20install%20directory%20(e.g.%20C%3A%5CProgram%20Files%5Cxyz%5C)%20upon%20shortcut%20launch.%20This%20can%20achieved%20well%20by%20granting%20permissions%20to%20the%20folder%20xyz%20under%20C%3A%5CProgram%20Files%20using%20a%20custom%20action%20script%20with%20a%20traditional%20WI%20approach.%20Well%20with%20the%20MSIX%2C%20how%20can%20we%20achieve%20this%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1450568%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMSIX%20Permissions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1450665%22%20slang%3D%22en-US%22%3ERe%3A%20MSIX%20-%20Permissions%20to%20App%20Folder%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1450665%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20a%20classic%20challenge%20where%20PSF%20(Package%20Support%20Framework)%20can%20help%20you%2C%20more%20specifically%20one%20of%20its%20fixups%20called%20File%20Redirection%3A%3C%2FP%3E%3CP%3E-ERR%3AREF-NOT-FOUND-%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FMicrosoft%2FMSIX-PackageSupportFramework%2Ftree%2Fmaster%2Ffixups%2FFileRedirectionFixup%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FMicrosoft%2FMSIX-PackageSupportFramework%2Ftree%2Fmaster%2Ffixups%2FFileRedirectionFixup%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20cannot%20set%20the%20permissions%20though%2C%20the%20MSIX%20has%20a%20built-in%20tamper%20protection%2C%20and%20prevents%20you%20from%20changing%20anything%20in%20the%20install%20directory.%20Instead%2C%20what%20PSF%20does%20for%20you%20is%20to%20redirect%20these%20calls%20to%20a%20place%20where%20there%20is%20a%20write%20grant%20(a%20special%20folder%20in%20local%20app%20data)%2C%20and%20ensures%20that%20there%20is%20a%20transparent%20redirection%20on%20subsequent%20calls.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESome%20basic%20regular%20expression%20knowledge%20may%20be%20required%20to%20achieve%20the%20desired%20results%20(depending%20on%20the%20pattern%20for%20the%20files%20to%20be%20redirected).%26nbsp%3BA%20step-by-step%20instruction%20is%20here%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fpsf%2Fpackage-support-framework%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fpsf%2Fpackage-support-framework%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDepending%20on%20the%20tooling%20you%20use%2C%20the%20support%20for%20PSF%20runtime%20from%20GUI%20may%20be%20also%20there%2C%20most%20of%20key%20players%20have%20already%20implemented%20it%20either%20way.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1456629%22%20slang%3D%22en-US%22%3ERe%3A%20MSIX%20-%20Permissions%20to%20App%20Folder%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1456629%22%20slang%3D%22en-US%22%3E%3CP%3EExpanding%20Marcin's%20answer%2C%20here%20is%20a%20link%20to%20my%20%3CSTRONG%3EMicrosoft%26nbsp%3BIgnite%202018%3C%2FSTRONG%3E%20talk%20where%20I%20demo%20exactly%20how%20you%20can%20fix%20such%20packages%2C%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.advancedinstaller.com%2Fexpress-edition.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Efree%20Express%20edition%20from%20Advanced%20Installer%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fyoutu.be%2Ff3Z7j1XEPgs%3Ft%3D721%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E-%20MSIX%20%26amp%3B%20PSF%20video%26nbsp%3B%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I have an application which creates a log file in the application install directory (e.g. C:\Program Files\xyz\) upon shortcut launch. This can achieved well by granting permissions to the folder xyz under C:\Program Files using a custom action script with a traditional WI approach. Well with the MSIX, how can we achieve this?

2 Replies
best response confirmed by Sharla_Akers (Microsoft)
Solution

This is a classic challenge where PSF (Package Support Framework) can help you, more specifically one of its fixups called File Redirection:

https://github.com/Microsoft/MSIX-PackageSupportFramework/tree/master/fixups/FileRedirectionFixup

 

You cannot set the permissions though, the MSIX has a built-in tamper protection, and prevents you from changing anything in the install directory. Instead, what PSF does for you is to redirect these calls to a place where there is a write grant (a special folder in local app data), and ensures that there is a transparent redirection on subsequent calls.

 

Some basic regular expression knowledge may be required to achieve the desired results (depending on the pattern for the files to be redirected). A step-by-step instruction is here:

https://docs.microsoft.com/en-us/windows/msix/psf/package-support-framework

 

Depending on the tooling you use, the support for PSF runtime from GUI may be also there, most of key players have already implemented it either way.

Expanding Marcin's answer, here is a link to my Microsoft Ignite 2018 talk where I demo exactly how you can fix such packages, using the free Express edition from Advanced Installer.

 

- MSIX & PSF video