My solution contains absolute paths to projects inside the solution folder

Will Pittenger 281 Reputation points

I have a solution where all the projects are inside the solution's folder. But VS Community 2022 insists on writing their location in the solution file and other project files as absolute paths. Now when I check everything into Git, VS doesn't upload the projects that it was using absolute paths for. What can I do?

Well, I tried to change the paths I was seeing manually to relative paths. And it was looking like VS was accepting the new paths. But then I checked the error list. Seems it can't find files when compiling. If the paths were absolute, it now fails to find the compiler output files while compiling for dependencies. I verified the paths exist. But it's very confused. It's the DLL, pdb, and XML (documentation) that it can't find for the dependency. So if project A.csproj depends on B.csproj which is a DLL, it's not finding B.dll, B.pdb, and B.xml while compiling A.

I don't know if it matters, but the directory where my solution is at can be accessed from several different paths. Those include b:\Contents\Best Chat, e:\Contents\Projects\Best Chat, and c:\users\willp\Documents\Projects\Best Chat.

Microsoft Technologies based on the .NET software framework.
3,438 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,674 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,355 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 57,641 Reputation points

    A solution file only contains project file locations. It does not have any information about project a references to project b. These are in the project a .proj file. These references should be relative. But if the drive letters do not match when the project reference was added then they can not be relative.

    when adding a project reference the solution file is used to get the location. So first fix the solution file.

    most likely you need to go through all your project file and fix the project references.

    If you don’t know how it edit the project files, just open the solution. For each project in the solution, remove all project references, save, then re-add, then save. The same for the solution file.

    0 comments No comments