I'm using MSBuild to build a solution file from the command line. In it, the path to the vcxproj file is specified by an environment variable FOO by %FOO%\ProjName.vcxproj
When I open the sln in the IDE, I the project is found and loaded. When I use msbuild from the command line (on the same machine) I get an error of:
The Project File "C:\Blah\Blah\%FOO%\ProjName.vcxproj" was not found,
In the same command prompt
echo %FOO%
Gives me the correctly expanded path.
From the comments; this is a known bug and a wontfix from MS. I ended up writing a batch file to copy the sln file and expand the environment variables, build that, and delete the new sln. Works fine.
As @maccard stated, this is a known bug. (See https://developercommunity.visualstudio.com/content/problem/248631/msbuild-doesnt-parse-environment-variables-in-sln.html and https://github.com/Microsoft/msbuild/issues/120 )
You can use the following script to replace all environment variables in a .sln file with their values. (Script is only very lightly tested).