0

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>
neualex
  • 51
  • 11
  • Maybe you can make `$(SolutionDir)\Project3\Project3.csproj` as a marco, then add it into ProjectReference. 1. Add `$(SolutionDir)\Project3\Project3.csproj` in `PropertyGroup`, 2. call it :`` – Dylan May 31 '21 at 02:19
  • @DylanZhu-MSFT No luck, after closing, reopening solution and rebuilding, VS 2019 (with latest update) still replaces the `$(ReferencedProject)` macro with ".." – neualex Jun 01 '21 at 13:41

0 Answers0