0

I made a project and made it a nuget package and when I install that nuget package in a project it works fine and all looks good.

The issue occurs when I close the project and re-open it (using visual studio). In the reference list the nuget package is double for some reason and one has no path/no version e.t.c. The project runs and everything is using the correct reference but there is a warning in the output window of this double reference that is added.

enter image description here

I cant figure out why it occurs. In the .csproj there is only one reference to this nuget and in the packages folder also.

Has anyoone experienced this?

JohnChris
  • 1,360
  • 15
  • 29

2 Answers2

0

Double reference appears after re-opening project

Adding a nuget reference adds a node as follows to the .csproj file:

<Reference Include="xx.xxx.Parameters, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\xx.xxx.Parameters.1.0.0\lib\net461\xx.xxx.Parameters.dll</HintPath>
</Reference>

Since there double reference appears in the References, so, first, we need double check if only one reference to this nuget in the .csproj file.

If yes, please try to clean the build after re-open the project, sometimes Visual Studio will reference from bin\ folder.

If above not help, please remove the reference with a yellow mark, then close the project and re-open it, check if this issue is reproduced.

Besides, you can install other nuget packages to check if there is the same problem, so that we could to know this issue is related to your Visual Studio or the nuget package itself.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • So it turns out that in my nuget package the .targets file and .props file needs to have the version number in the name that matches the nuget version for this problem to be solved... – JohnChris Apr 04 '18 at 08:12
  • @JohnChris, so you have found the reason for this issue? You can share it as answer, this can be beneficial to other community members reading this thread. Thanks. – Leo Liu Apr 04 '18 at 08:54
0

When creating a nuget package some scenarios require a .props and a .targets file. For example using multiple architecture where I have answered here. - I have updated this answer to reflect what I found out from trying to solve the double reference issue

One point that was not clarified well was the naming of the .target and .props needs to be the same as the nuget package file name (meaning the version as well). As without this the double reference would appear when re-opening visual studio.

JohnChris
  • 1,360
  • 15
  • 29