One of the things I like most about PACX is how easy it is to add features when a new need arises from actual daily usage.
Typically, my work is focused: one client, one project at time.
Lately, however, I've been working on one main client, but also on several side, small, projects, and I was quite frustrated by the need of switching between authentication profiles.
🧑🏻🏫 How does PACX manages scope?
All PACX settings are stored in a global settings folder, under C:\Users\<username>\AppData\Local\Greg.Xrm.Command
.
The list of the configured authentication profiles, the default solution to be used for each profile, and the current default authentication profile are saved in the connection.json
file (connection strings are encrypted).
This means that whenever you type
pacx auth select --name myconn
This setting is global, and affects all the subsequent commands. A behavior that is borrowed from PAC CLI, it works the same way.
It's really useful when scripting because you can authenticate once, define once the solution to work with, and all the subsequent commands will inherit that configuration.
When you're on a single client-project everything's smooth, but if you're working with different clients or different projects, or if you adopted a segmented solution approach on a single client, this forces you to call:
pacx auth select --name myconn
-- or --
pacx solution setDefault --name mysolution
Too often from my POV.
💡 The idea
Starting from the fact that when I'm working on a given client/project, the first thing I do is to create a local folder that will be the local repository of all customizations I'll made (plugins, WebResources, PCFs, but also extracted and unpacked solution files)...
...it would have been really useful if all the commands run from inside that folder would inherit a specific configuration of scope (a given auth profile, and a specific default solution).
🚨 PACX Projects to the rescue
A PACX Project file 📄 (.pacxproj
) it's a local configuration file that can be set in a given directory to make it a PACX Project folder 📂, and defines a local configuration of scope (a given auth profile, and a specific default solution).
You can create a new PACX Project file 📄 (.pacxproj
) via
pacx project init
You can also specify the following optional arguments:
-
conn
(c
): to specify the name of the authentication profile that allows to connect to the environment associated to the current command. If not provided, the current default auth profile is used. -
solution
(s
): to specify the default solution to use to store the customizations for the current project. If not provided, the default solution for the selected auth profile is used.
When a folder becomes a PACX Project folder 📂, all commands that are run from that folder or from a subfolder of that folder will inherit the configuration of scope provided by the PACX Project file 📄, it means they will no longer rely on the default configuration provided via global settings.
pacx project init
can also be used to update the current PACX Project file 📄 (.pacxproj
), if needed.
If you have a terminal on a given folder, and you want to show the authentication profile and the default solution defining the current scope, you can do it via pacx project info
:
Suspend / Resume the default settings override
Running a command inside a PACX project folder overrides the default auth. profile and default solution. If you need to temporary suspend this override, without deleting the PACX Project file 📄, you can do it via:
pacx project suspend
Once you suspended the project, all subsequent commands will run against the global, default, auth profile and solution.
To resume the override, you can use the resume
command:
pacx project resume
Conclusion
This command suite will save me hours, and headaches. If you want to know more about it, please refer to the official WIKI:
-
pacx project command namespace
- pacx project init command
- pacx project info command
- pacx project suspend command
- pacx project resume command
Give it a try, and let me know what do you think about it!
Top comments (0)