PM2 Process Manager + NET Core = Build Loop

PM2 Process Manager LogoI use the wonderful PM2 process manager to handle processes on my Linux servers. Sometimes though, I’ll get a weird error about “N/A” not being a valid version string when running NET Core applications.

So… what’s the problem with PM2?

It manifests itself by emitting an error like the following:

/usr/share/dotnet/sdk/8.0.204/NuGet.targets(169,5): error : 'N/A' is not a valid version string. (Parameter 'value') [/home/coburn/path/to/some/app/BestAppEver.csproj]
The build failed. Fix the build errors and run again.

This will continuously repeat itself until I shoot it to end its misery and try to figure out what’s going on.

How do we fix this so we can use PM2 to control our NET Core apps?

This is a bit of a long answer.

It seems the culprit is due to the PM2 process manager setting a environment variable called “version”. As I use a bash script to bootstrap the NET Core application, I worked around this by unsetting the version environment variable in the shell script via a simple one liner:

unset version

…before calling any dotnet commands like clean or build in the shell script.

This successfully resolved the build error for a website application. I hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *