Another new fixup for MSIX PSF: EnvVar

Image Attribution: VectorHuman

A summer ‘staycation’ project from me. This project is now accepted into the develop branch of the Microsoft PSF repository.

EnvVarFixup is a new type of MSIX Package Support Framework intercept that addresses the issue of MSIX not supporting new/changed environment variables inside the package.

The fixup allows for the specification of environment variables and values in two ways, and supports intercepts for the application to read and/or write values.

In essence, the overall effect is to change the scope of environment variables, which previously were either system-wide or user-session wide, into an application-package-wide scope.  Specification is done in one of two modes.

Mode 1: When the fixup is configured in the PSF JSON file, variable names and values may be directly specified there with a “ReadOnly” setting set to true.  This is primarily intended for developers creating their package and does not require any entries for the environment variable in the Registry.dat file.  The effect of this mode is that the application using the shim will see this application scoped environment variable, however the app will not be able to change the value at runtime.

Mode 2: When the the fixup is configured in the PSF JSON file, variable names are directly specified there without the “ReadOnly” setting.  At runtime the application will read the value from the registry, so the Registry.dat application hive will contain the value.  The effect of this mode is that the application will be allowed to update the value.

Keep in mind that this is only for things inside the container, so changes to things like Path variables might need a different solution.  But if the app installer normally adds a new environment variable for use by the app, this should do the trick.

EnvVarFixup does not conflict with any other existing fixups, so you can mix, even with RegLegacyFixups in the same process.

The readme.md file in the “fixups\EnvVarFixup” folder of the link at the beginning of the article contains more details on the fixup and Json syntax.

Shortly we’ll have a release of PsfTooling (4.2) that supports this new fixup type when repackaging apps using the Microsoft MSIX Packaging Tool.  Stay tuned for a post on that as soon as it clears the submission process in the Microsoft Store!

By Tim Mangan

Tim is a Microsoft MVP, and a Citrix CTP Fellow. He is an expert in App-V and MSIX.