Setting Helix Core Server environment variables using P4CONFIG

P4CONFIG is an environment variable that you can use to point to a file that stores other Helix Core Server environment variables. The current working directory and its parents are searched for the file. If the file exists, then the variable settings within the file are used.

P4CONFIG makes it easy to switch Helix Core Server settings when switching between different solutions or projects. If you place a configuration file in each of your client workspaces and set P4CONFIG to point to that file, your Helix Core Server settings change to the settings in the configuration files automatically as you move from directories in one workspace to another.

To use P4CONFIG to switch settings between client workspaces on P4VS, you must create separate Visual Studio shortcuts for each workspace, setting the Start in property as the workspace directory (which is also the directory where the configuration file resides). If you launch Visual Studio using a shortcut defined this way, P4VS will read the Helix Core Server settings from the configuration file in that workspace’s directory. This is required because Visual Studio otherwise uses its own directory as the current working directory.

To use P4CONFIG with P4VS:

  1. Create a configuration file that contains the Helix Core Server environment variable settings you want, and put it in the workspace directory for the relevant Visual Studio solution.
  2. Using p4, the Helix Core Server Command Line Client, unset the P4CLIENT, P4PORT, and P4USER environment variables and set P4CONFIG to the configuration file name.
  3. Using P4VS, go to Tools > Options > Source Control > Helix Core - Connections and select Connect to the server using my Helix Core environment settings.
  4. Create a Windows desktop shortcut for Visual Studio that is dedicated to the workspace with which you want to use the configuration file.

    1. Right-click on the desktop and select New > Shortcut.
    2. Enter the location of the Visual Studio executable and click Next.
    3. Enter a shortcut name and click Finish.
    4. In the shortcut properties, under Start in, enter the workspace directory where the configuration file is located, and click OK.

    Repeat for each workspace for which you want a different configuration file.

  5. Whenever you want to work in that workspace using the configuration file settings, use the shortcut to launch Visual Studio.

For more information about P4CONFIG and Helix Core Server environment variables, see the Helix Core Command-Line (P4) Reference and Setting P4VS preferences.