Zay Lau
Zay Lau

Reputation: 1864

Visual Studio cannot handle nested submodule as expected

I am having 3 solutions which

Solutions

Solution A

Solution B

Solution C

File Structure

The Solutions/Projects are imported through Git submodules where the structure as below:

- \
--- \Solution C
------ \Project C1
------ \submodules
--------- \Solution A
------------ Project A1
--------- \Solution B
------------ \Project B1
------------ \Project B2
------------ \submodules
--------------- \Solution A
------------------ \Project A1

Issue

While I use Visual Studio to open Solution C and compile the projects inside, the results are various: (note: I didn't include \Solution C\submodules\Solution B\submodules\Solution A\Project A1 in the solution since VS not allow 2 projects with same name)

VS always said Project B2 cannot find the Project A1 (which path is \Solution C\submodules\Solution B\submodules\Solution A\Project A1), unless I right click on Project A1 and select clean, then rebuild Project B2 (clean is a must), below is the message:

Error NU1105 Unable to find project information for '\Solution C\submodules\Solution B\submodules\Solution A\Project A.csproj'. Inside Visual Studio, this may be because the project is unloaded or not part of current solution. Otherwise the project file may be invalid or missing targets required for restore.

However I tried to clone only Solution B to a new position (with submodules Solution A) and it can be compile and run as expected.

Guesses

Update

Guids


Any help will be appreciated

Upvotes: 1

Views: 2210

Answers (1)

Zay Lau
Zay Lau

Reputation: 1864

After hours of research, it is confirmed a .NET mechanical issue which the same project is being saved across different location and be referenced by multiple other projects. Which .NET cannot recognize they are the same project even they are all cloned from git server and sharing the same name.

As jessehouwing suggested (thanks for all your help jessehouwing!!) we could wrap all projects(submodules) into one giant solution for development (I guess this approach match perfectly the name solution)

However what we are trying to do is having the below architecture:

  • Cores.Library
  • ACompany.Cores.Library
  • ACompany.Cores.Web
  • BCompany.Cores.Library1
  • BCompany.Cores.Library2
  • BCompany.Cores.Console
  • BCompany.Cores.Web

So finally I decided to go for an internal NuGet feed while VS2017 already could auto generate the nupkg file on build which has been tested and working perfectly as expected.

@jessehouwing you may answer the question and I would set yours as the answer, thanks again!

Upvotes: 2

Related Questions