Create PCF Controls on Linux – the dreaded $PATH

Yes, I know, who does that? Actually, it’s not as uncommon as you might think.

You can do .NET work on Linux just fine (for most non-windows workflows). For Power Platform, you can easily do your client side scripting. But can you create PCF Controls? Well, yes, once you’re setup correctly.

Had a questions recently about an interesting issue on a machine running Ubuntu 22.04. It had the .NET 6 setup from the standard repo, VSCode installed, and everything worked just fine. And then, we decided to test creating PCF Controls.

You’re supposed to simply install the Power Platform Tools extensions in VSCode, and Bob’s your uncle, right? Well, almost.

You will not be able to run pac commands from the terminal. You should only be able to do it from the VSCode Terminal. No problem, just know about it.

But the moment you run pac, you are greeted with the following message:

You must install .NET to run this application.

Running dotnet –info does return the expected information, and checking for runtime and sdk all looks good. You do that by running

dotnet –list-runtimes

and of course

dotnet –list-sdks

On this version of Ubuntu you can install .NET version 6 from the standard repository, so nothing too complicated. You could also do it from the Microsoft package feed (and you get the newest version), but it’s advisable to choose either/or, and not to mix the sources.

So, then, this issue must be a $PATH issue. Let’s see.

You can simply type echo $PATH to display the path, but this can be a little hard to read as it joins everything together in a long string. Instead, you can run:

echo “${PATH//:/$’\n’}”

and that will display each entry on it’s own line, making it much easier to read.

To edit the $PATH, you can find the definitions in the .bashrc file in your user folder (if you’re using the standard bash). Edit it using either vi or nano (easier), and you will probably find the DOTNET_ROOT path defined, along with the PATH and MSBuildSDKsPath.

On this machine where we had the issue, the DOTNET_ROOT was the culprit. For some reason, it was set to:

Bingo!

Changing that to the correct root folder should look like so:

Now, in the VSCode Terminal run pac and you should be greeted with the correct information. You might have to restart VSCode or the Terminal for the change to take effect.

And there you have it. Hopefully this saves someone a bit of time trying to figure out what’s what.

Enjoy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: