Visual Studio 2019 MSBuild replaces $(SolutionDir) with ".." for projects included from file system, but not for projects included from Git submodules.

For instance, project file (Project0.csproj) below has 4 referenced projects.

  • Project 1 and Project 2 were checked out as Git submodules.
  • Project 3 and 4 were created on the same repo as Project0.

They all started with $(SolutionDir), but as soon as VS builds the solution, $(SolutionDir) macro for Project 3 and 4 gets replaced with ".."

How can I prevent this?

 <ItemGroup>
    <ProjectReference Include="$(SolutionDir)\Project1\Project1.csproj">
        <Name>Project1</Name>
    </ProjectReference>
    <ProjectReference Include="$(SolutionDir)\Project2\Project2.csproj">
        <Name>Project2</Name>
    </ProjectReference>
    <ProjectReference Include="..\Project3\Project3.csproj">
        <Name>Project3</Name>
    </ProjectReference>
    <ProjectReference Include="..\Project4\Project4.csproj">
        <Name>Project4</Name>
    </ProjectReference>
</ItemGroup>
0

There are 0 best solutions below