15

So in Visual Studio 2017, I get the following warning in the auto-generated packages.config file:

The 'packages' element is not declared.

It is the same issue as here: The 'packages' element is not declared

And here: nuget 'packages' element is not declared warning

The consensus seems to be that this warning can be safely ignored. Moreover, some of the comments suggest that attempts at fixing this can cause other issues and/or be hard to maintain.

For example, one contributor said:

None of the answers will solve your problem permanently. If you go to the path of adding XSD (From Xml menu, select "Create schema"), you will end up having problems with the package manager as it will clean up your packages.config file when you add a new package.

However, the most recent contributor suggested simply changing <packages> to <packages xmlns="urn:packages">. Doing this makes the error go away and I saw no OBVIOUS problem (my experience here is very limited).

However, I don't want to risk causing Nuget problems over a warning that does not need to be addressed. On the other hand, every project created in VS, I'm guessing, will have this error by default, so an easy, safe, and easily maintainable fix would be good to have.

So my bottom line question is: what exactly does changing <packages> to <packages xmlns="urn:packages"> in the packages.config file do, and are there any risks or downsides to doing this?

user247702
  • 23,641
  • 15
  • 110
  • 157
Pennywise
  • 281
  • 2
  • 4
  • 11

2 Answers2

21

what exactly does changing <packages> to <packages xmlns="urn:packages"> in the packages.config file do, and are there any risks or downsides to doing this?

Using <packages xmlns="urn:packages"> in the packages.config file adds the schema to the file. The xmlns (namespace) declaration is nothing more than a string in the form of a uniform resource identifier (URI) and this declaration is not required. NuGet uses the <packages> node in packages.config to restore project dependencies as is described in the Schema section of the packages.config reference. This is why Microsoft used <packages> instead of <packages xmlns="urn:packages">.

The packages.config file is auto-generated and can be used by NuGet as-is. There is no need to change the file and there no risks or downsides associated with ignoring the warning.

plr108
  • 1,201
  • 11
  • 16
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Thanks! Very informative. I am just going to leave well enough alone and ignore the warning. – Pennywise Apr 03 '17 at 05:32
  • I was having the following error: error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this... I was not able to compile. But, by replacing for my error got solved. What happened? Thank you. – Diego Orellana Mar 13 '18 at 18:45
  • 5
    `` also seems to get rid of the warning. However, both of these prevent my nuget package manager from finding my installed packages. – bornfromanegg Aug 08 '18 at 10:30
-2

add a reference to EntityFramework.SqlServer ... 100% tested , I had the same problem and that's what worked for me .

Ali3lo
  • 19
  • 1
  • 4
  • For me also.. this seems like an answer... in his/her case they had some issue and he added reference and it removed the warning... – Ziggler Dec 18 '18 at 20:11