NuGetSwitcher icon indicating copy to clipboard operation
NuGetSwitcher copied to clipboard

Adds a duplicate project reference in any project that already contains a project reference to a project that exists in a configuration path

Open jkappel71 opened this issue 2 years ago • 1 comments

We use a microservice style architecture. So, we have a lot of small solutions that mostly contain a project, then a test project for testing the other project in the solution. The problem we have run into is that we have a CoreProject which becomes a NuGet Package and is referenced by everything else. Therefore, the path to the CoreProject is configured in the configuration file.

The problem appears when I load the CoreProject solution which contains 2 projects: CoreProject and CoreProjectTests. Now, the CoreProjectsTests project contains a Project Reference to the CoreProject. It also contains a Package Reference to our BastTesting project.

I would like to be able to use the NuGetSwitcher on this solution to replace the PackageReference to our BaseTesting Project with a Project Reference. When I do so, it also adds a duplicate reference to the CoreProject in the CoreProjectTests project.

Let me try to illustrate:

We have 2 Projects that get built as NuGet packages that everything else uses:

  • CoreProject
  • BaseTesting

The path for each of these is in the configuration file. I then have the following solution:

Solution:

  • Project: CoreProject
  • Project: CoreProjectTests

The CoreProjectTests project file has:

  • Project Reference: CoreProject
  • Package Reference: BaseTesting

When I use the NuGetSwitcher, it updates the CoreProjectTests project file to use a project reference for the BaseTesting as expected, but also adds a duplicate project reference to CoreProject.

I looked into fixing it myself, but didn't have much luck. One very important caveat that I should point out is that my existing Project Reference to CoreProject uses a relative path rather than an absolute path, and must continue to do so because of our CI pipeline and build environment. In looking at the code for this extension, I see absolute path comparisons, and I suspect that may have something to do with the issue.

Any help you could provide would be GREATLY appreciated.

I have attached a sample project structure for testing purposes.

SampleProjectStructure.zip

jkappel71 avatar Mar 01 '23 22:03 jkappel71

Will check this week. Thank for reporting.

0UserName avatar May 11 '23 09:05 0UserName