I am trying to create a batch file that loads a VS2015 solution file. We use source control branches, so the paths to the projects that are included in the .sln may vary, depending on the selected branch like this: trunk\ branches\B1\ branches\B2\ etc...
In the .sln file, an included projects definition looks either like this:
Project("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX}") = "My.Awesome.Project", "..\..\..\My\Awesome\Project\trunk\HelloWorld\HelloWorld.csproj", "{YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY}"
or this:
Project("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX}") = "My.Awesome.Project", "..\..\..\..\My\Awesome\Project\branches\B1\HelloWorld\HelloWorld.csproj", "{YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY}"
I had an idea to use these environment variables:
@SET BACKPATH=..\..\..
@SET FORWARDPATH=trunk
Project("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX}") = "My.Awesome.Project", "%BACKPATH%\My\Awesome\Project\%FORWARDPATH%\HelloWorld\HelloWorld.csproj", "{YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY}"
When the solution is loaded, the processed string will switch to absolute path, as soon as I start using these environment variables. So it will look like this:
C:\Team1\Work\My\Awesome\Project\trunk\HelloWorld\HelloWorld.csproj
As you can see, the environment variable that contains relative movement among folders is ignored completely, but the other env. variable is added to the string OK.
Is there any way to keep the relative path while at the same time use environment variables?
(I know there would be a way to overcome this issue using the subst command with absolute paths, but I would like to avoid that if there is a better way.)