Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are C# references added differently between NuGet and Visual Studio

Tags:

We use NuGet (NuGet Version: 3.5.0.1996) two different ways. Either we run it from the command line or we use the NuGet Package Manager in Visual Studio (2015).

The problem is that these two ways add references to the .csproj file with different formats. If we use the command line, we get a reference that looks like this:

<Reference Include="Dummy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">   <HintPath>..\packages\Dummy.1.27.10\lib\net452\Dummy.dll</HintPath>   <Private>True</Private> </Reference> 

If we use the NuGet Package Manager in Visual Studio, we get a reference that looks like this:

<Reference Include="Dummy, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">   <HintPath>..\packages\Dummy.1.27.10\lib\net452\Dummy.dll</HintPath>   <Private>True</Private> </Reference> 

Notice that ones adds the reference with the PublicKeyToken attribute and the other adds it with the processorArchitecture attribute.

This causes issues with our source control with frequent (and unnecessary) updates and merges.

It would be nice to know why this happens, but I would much rather have a way to prevent it from happening. Any suggestions?

like image 685
melvers Avatar asked Jul 13 '17 18:07

melvers


People also ask

Why is C not A or B?

Because C comes after B The reason why the language was named “C” by its creator was that it came after B language. Back then, Bell Labs already had a programming language called “B” at their disposal.

Why are we using C?

C is a general-purpose programming language and can efficiently work on enterprise applications, games, graphics, and applications requiring calculations, etc. C language has a rich library which provides a number of built-in functions. It also offers dynamic memory allocation.

Why is C so popular language?

The C programming language is so popular because it is known as the mother of all programming languages. This language is widely flexible to use memory management. C is the best option for system level programming language.


1 Answers

Starting with Visual Studio 2015, Nuget comes embedded and you cannot change the version used. I don't have a VS 2015 at hand to check, but most likely it is using a version different than the one you have in the command line.

Nuget has "suffered" (or enjoyed) a lot of changes and I think this is just a manifestation on how two different versions of nuget handles package references.

My suggestion, to avoid having issues with source control, is to standardize one way of using Nuget and stick to it. My suggestion would be to use it inside Visual Studio, either by means of Package Manager Console (similar to the CLI) or though the visual interface.

like image 154
ecastro Avatar answered Oct 08 '22 16:10

ecastro