Packages node does not exist in packages.config - visual-studio

When I try to update Dapper (or any other NuGet package), Visual Studio displays:
An error occurred while writing file 'T:\ProjectPath\packages.config': Packages node does not exists in packages.config at T:\ProjectPath\packages.config.
The exact contents of said file are:
<?xml version="1.0" encoding="utf-8"?>
<packages xmlns="urn:packages">
<package id="Antlr" version="3.5.0.2" targetFramework="net45" xmlns="" />
<package id="Dapper" version="1.42" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" xmlns="" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" xmlns="" />
<package id="Moment.js" version="2.10.2" targetFramework="net451" xmlns="" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" xmlns="" />
<package id="NLog" version="4.0.1" targetFramework="net451" xmlns="" />
<package id="NLog.Config" version="4.0.1" targetFramework="net451" xmlns="" />
<package id="NLog.Schema" version="4.0.1" targetFramework="net451" xmlns="" />
<package id="Oracle.ManagedDataAccess" version="12.1.021" targetFramework="net451" xmlns="" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" xmlns="" />
</packages>
A package node certainly seems to exist.
I have tried update-package dapper, update-package dapper -Reinstall, and uninstall-package dapper -Force. All yield:
PM> Update-Package dapper
Attempting to gather dependency information for multiple packages with respect to project 'ImplantRecipeDatabase', targeting '.NETFramework,Version=v4.5.1'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Install failed. Rolling back...
Package 'Dapper 1.42' already exists in project 'ImplantRecipeDatabase'
Update-Package : An error occurred while writing file 'T:\Dropbox\WorkProjects\DataManager\ImplantRecipeDatabase\packages.config': Packages node does not exists in packages.config at T:\Dropbox\WorkProjects\DataManager\ImplantRecipeDatabase\packages.config.
At line:1 char:15
+ Update-Package <<<< dapper
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
Note that the most recent version of Dapper found by NuGet as of this writing is 1.50.1
The errors aren't helpful, so I am not sure where to go from here. I have tried installing the most recent update for VS2015 Update 3 (kb3165756) and have the most recent version of NuGet (3.4.4.1321).
What should I try next?

Your packages.config file does not look correct. It has xmlns attributes where a normal packages.config would not have any. Having the root packages element in a different namespace may well be the cause of the problem. I would expect the packages.config file to look more like:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />

Related

uninstall nuget package that no longer exists

We had our nuget server die and the admin never made a backup. So now building on a new install won't work b/c there is nothing in the cache and it can't recreate the dependency list. I tried to force uninstall but it says that I have to restore the package before uninstalling it so it can build the dependency tree. Argh. I just want the package out of the solution so we can rebuild the site. I also tried removing it from packages.config but that didn't help.
Is there a way to manually force delete a nuget package without having access to it anymore? Otherwise I need to build a new solution from scratch and migrate the files over.
Here are the commands I tried:
uninstall-package packagename -RemoveDependencies -force
and
uninstall-package packagename -force
Here is the config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="custom.serialization" version="2017.3.20.142224" targetFramework="net462" />
<package id="custom.themes.flat-blue" version="2016.12.9105400" targetFramework="net452" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net462" />
<package id="NLog" version="4.4.5" targetFramework="net462" />
<package id="NLog.Extended" version="4.0.0.1" targetFramework="net452" />
<package id="NLog.Web" version="4.4.0" targetFramework="net452" />
</packages>
Thanks
Looks like I got it working. Here are the steps:
Close the solution.
Delete references to the package from .csproj file
Delete reference from the packages.config file.
Delete all packages from the packages folder in the root.
Open the NuGet configuration and remove the source that had the old files.
Open the solution and tell it to reload all packages. It will then pull down fresh copies of all packages except the one you deleted.
So far the solutions is building and running without any errors about the missing package!

NuGet and/or PM not working correctly all of the sudden

I have a VS 2015 Community solution with a single ASP.NET MVC C# project that has been working correctly, but all of the sudden NuGet starts behaving flaky after installing and uninstalling a package. The package name was Bogus which is a port of the Faker library that generates Fake data. The Bogus package didn't quite do all I needed, so I attempted to uninstall it using Nuget. An error occurred, but I don't remember what the error said. :S
After trying a few simple things like cleaning the solution, restarting VS, and emptying the ./packages folder and rebuilding, the problem persists.
So I shut down VS and rebooted. Then removed the contents of the AppData/Local/Nuget/cache/ and again removed all contents of the solution's packages/ folder (again). Restarted VS and performed a Build. No errors, but I still have symptoms:
Package Manager no longer recognizes the 'Add-Migration' command:
PM> add-migration Misc1
add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
add-migration Misc1
~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
NuGet cannot uninstall/update most of the project's installed packages. As an example, I have WebGrease v1.5.2 installed and Latest stable v1.6.0 is available. When I click the Update button I receive the following error in VS Error List pane:
Error An error occurred while retrieving package metadata for 'Newtonsoft.Json.10.0.3' from source 'C:\Users\ME\Projects\MyProject\packages'. 0
and the following error in the Output pane:
Attempting to gather dependencies information for package 'WebGrease.1.6.0' with respect to project 'MyProject', targeting '.NETFramework,Version=v4.6.1'
An error occurred while retrieving package metadata for 'Newtonsoft.Json.10.0.3' from source 'C:\Users\ME\Projects\MyProject\packages'.
========== Finished ==========
I'm really stuck at this point. I have no idea how to fix this/these problem(s) and it's cost me a day of downtime already.
One thing that's odd is that I can apparently downgrade Newtonsoft.Json to 10.0.2 and then Update it to 10.0.3 again without any errors seemingly. Can't uninstall it though and like I said, all of the other installed packages I've tried to update or uninstall generate an error - usually pointing to Newtonsoft.Json like above.
Here is packages.config:
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net461" />
<package id="bootstrap" version="3.0.0" targetFramework="net461" />
<package id="EntityFramework" version="6.1.3" targetFramework="net461" />
<package id="jQuery" version="1.10.2" targetFramework="net461" />
<package id="jquery.datatables" version="1.10.15" targetFramework="net461" />
<package id="jQuery.Validation" version="1.11.1" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="1.2.0" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.DependencyCollector" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.JavaScript" version="0.15.0-build58334" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.Web" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.WindowsServer" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Owin" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Cookies" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Facebook" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Google" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.MicrosoftAccount" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.OAuth" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Twitter" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
<package id="Modernizr" version="2.6.2" targetFramework="net461" />
<package id="NBuilder" version="5.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net461" />
<package id="Respond" version="1.2.0" targetFramework="net461" />
<package id="WebGrease" version="1.5.2" targetFramework="net461" />
</packages>
My problem was resolved using the simple solution provided by #Oleksandr Pshenychnyy in this SO question:
Go to VS menu Tools > Extensions and Updates > Updates and check if
there is no updates for NuGet Package Manager. Installing the latest
version solved the problem for me.
After updating NuGet everything appears to be working as expected again.

Web Api built with msbuild does not work due to Microsoft.DiaSymReader.Native assemblies

I recently started running into an issue when building my web api project using MSBuild on VSTS and I managed to reproduce it locally.
My Web Api is a standard, run of the mill api with nothing fancy added.
It has the following packages installed:
<packages>
<package id="Autofac" version="4.5.0" targetFramework="net461" />
<package id="Autofac.Owin" version="4.0.0" targetFramework="net461" />
<package id="Autofac.WebApi2" version="4.0.1" targetFramework="net461" />
<package id="Autofac.WebApi2.Owin" version="4.0.0" targetFramework="net461" />
<package id="AutoMapper" version="6.0.2" targetFramework="net461" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net461" />
<package id="EntityFramework" version="6.1.3" targetFramework="net461" />
<package id="Kentico.Libraries" version="10.0.16" targetFramework="net461" />
<package id="Kentico.Libraries.Dependencies" version="10.0.16" targetFramework="net461" />
<package id="log4net" version="2.0.8" targetFramework="net461" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="2.0.1" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Owin" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Cors" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net461" />
<package id="PagedList" version="1.17.0.0" targetFramework="net461" />
<package id="System.Linq.Dynamic" version="1.0.7" targetFramework="net461" />
</packages>
When I build the project locally using Visual Studio 2015, the API works as expected.
However, when I build the project using msbuild:
msbuild Portal.WebApi.csproj /p:Platform="Any CPU" /p:Configuration="Nightly" /p:VisualStudioVersion="14.0" /p:OutputPath="C:\Temp\BuildOutput"
and point my IIS to the the _PublishedWebsites\Portal.WebApi\ folder, it fails with the following error:
Could not load file or assembly
'Microsoft.DiaSymReader.Native.amd64.dll' or one of its dependencies.
The module was expected to contain an assembly manifest.
If I remove Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers packages from the API project and build it again using MSBuild, the API works again as expected.
If I compare the bin folders (Visual studio build vs MSBuild), the msbuild bin folder has additional dlls and all the content of the roslyn folder is added directly to the bin folder.
Has anyone encountered such an issue?

Could not load type 'Xamarin.Forms.Preserve Attribute' from assembly 'Xamarin.Forms.Core'

I've just inherited an old Xamarin Forms application and I'm trying to upgrade all the packages. App was initially running fine, but since upgrading to the latest version of all packages, I'm now getting a crash calling Xamarin.Forms.Forms.Init(this, bundle);:
Could not load type 'Xamarin.Forms.PreserveAttribute' from assembly 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.
Here's my packages.config file contents:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ExifLib.PCL" version="1.0.1" targetFramework="MonoAndroid50" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="MonoAndroid50" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="MonoAndroid50" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="MonoAndroid50" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Forms" version="2.3.0.38-pre2" targetFramework="MonoAndroid50" />
<package id="Xamarin.Forms.Labs" version="1.2.1-pre2" targetFramework="MonoAndroid44" />
<package id="Xamarin.Forms.Maps" version="2.2.0.31" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Base" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Basement" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Maps" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.Insights" version="1.12.3" targetFramework="MonoAndroid50" />
</packages>
I closed Xamarin Studio and cleared obj and bin folders and started Xamarin Studio again and everything worked fine
I had the same issue but I noticed that the Xamarin.Forms package had an update. I updated this package and the issue went away.
I had the same message from a freshly created default Xamarin Forms app (Native, with Portable Class Library) after adding a new Form to the PCL (via the "Add New Item" context menu in Visual Studio and selecting Xamarin.Forms/Content Page).
It turned out that the packages.config in the PCL specified a different version for Xamarin.Forms than the one in UWP project.json file.
Making both projects use the same version of Xamarin.Forms by editing the packages.config fixed the problem.
The path of project must have not '#' character
In my case i had downgraded the Xamarin version from 3.x to 2.5 for all the projects. But somehow the .Net Standard project was not downgraded.
Started working after downgrading the .net standard project.

Why Microsoft.Owin.Host.SystemWeb failed to install?

I started with an empty solution with Web API only. (no mvc)
Using NuGet to upgrade all the built-in packages to the latest stable.
Then,
Install-Package Microsoft.AspNet.WebApi.Owin
Everything's good. I get a version 5.2.2 of Microsoft.AspNet.WebApi.Owin.
After that, install Owin.Host.SystemWeb.
Install-Package Microsoft.Owin.Host.SystemWeb
It shows a Successfully installed... message. But when I look into the References of the project, the icon before Microsoft.Owin.Host.SystemWeb has a yellow triangle in its bottom.
Here is my packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
The solution can be built but with a Warning, not even an error:
The referenced component 'Microsoft.Owin.Host.SystemWeb' could not be found.
The question: what is the correct way to install Microsoft.Owin.Host.SystemWeb? Is there some version requirement?
Try changing
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net45" />
to
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net452" />

Resources