3
votes

I have a ASP.NET 5 NuGet package called Boilerplate.Web.Mvc6. I am unable to to reference the NuGet package in my ASP.NET 5 website. Here is my project.json file referencing "Boilerplate.Web.Mvc6": "1.0.11".

{
  // Omitted

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-beta6",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta6",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta6",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta6",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta6",
    "Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-beta6",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta6",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta6",
    "Microsoft.Framework.Logging": "1.0.0-beta6",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta6",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta6",
    "Newtonsoft.Json": "7.0.1",
    "System.Runtime": "4.0.20-beta-23109",
    "Boilerplate.Web.Mvc6": "1.0.11"
  },

  // Omitted
}

When I add the package above, the references in the project shows an error and I get the following printed in the output window:

PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\Rehan Saeed\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7-12364\bin\dnx.exe "C:\Users\Rehan Saeed\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7-12364\bin\lib\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" restore "C:\Temp\WebApplication2\WebApplication2" -f "C:\Program Files (x86)\Microsoft Web Tools\DNU"
Microsoft .NET Development Utility CLR-x86-1.0.0-beta7-12364
Restoring packages for C:\Temp\WebApplication2\WebApplication2\project.json
  CACHE https://api.nuget.org/v3/index.json
  CACHE http://MyGet.org/aspnetmaster/
  CACHE https://az320820.vo.msecnd.net/v3-flatcontainer/boilerplate.web.mvc6/index.json
  GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
  Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
  GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
  Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
  GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Error: FindPackagesById: Boilerplate.Web.Mvc6
  Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
----------
System.IO.InvalidDataException: Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response. ---> System.Xml.XmlException: 'doctype' is an unexpected token. The expected token is 'DOCTYPE'. Line 2, position 3.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
   at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2)
   at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
   at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.EnsureValidFindPackagesResponse(Stream stream, String uri)
   --- End of inner exception stack trace ---
   at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.EnsureValidFindPackagesResponse(Stream stream, String uri)
   at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.<>c__DisplayClass25_0.<FindPackagesByIdAsyncCore>b__0(Stream stream)
   at Microsoft.Dnx.Tooling.Restore.NuGet.HttpSource.<GetAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.<FindPackagesByIdAsyncCore>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dnx.Tooling.RemoteWalkProvider.<FindLibrary>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dnx.Tooling.RestoreOperations.<FindLibrary>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryByVersion>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryMatch>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryEntry>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dnx.Tooling.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Dnx.Tooling.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dnx.Tooling.RestoreCommand.<CreateGraphNode>d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Dnx.Tooling.RestoreCommand.<RestoreForProject>d__70.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dnx.Tooling.RestoreCommand.<>c__DisplayClass69_0.<<Execute>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dnx.Tooling.RestoreCommand.<Execute>d__69.MoveNext()
----------
Restore failed
Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
NuGet Config files used:
    C:\Users\Rehan Saeed\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
    https://az320820.vo.msecnd.net/v3-flatcontainer/
    http://MyGet.org/aspnetmaster/
    C:\Program Files (x86)\Microsoft Web Tools\DNU

What's going wrong?

UPDATE

These are my NuGet package feeds:

  1. nuget.org - https://api.nuget.org/v3/index.json
  2. My Get - http://MyGet.org/aspnetmaster
  3. Microsoft .NET - https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/

UPDATE 2

I ran dnu restore --ignore-failed-sources and got the following output, where it still can't find my NuGet package. The strange thing is that I can reference 1.0.10 of the same package from my ASP.NET 5 project but not from an ASP.NET 5 class library.

Restoring packages for C:\Temp\WebApplication2\WebApplication2\project.json
  GET https://api.nuget.org/v3/index.json
  OK https://api.nuget.org/v3/index.json 130ms
  GET http://MyGet.org/aspnetmaster/
  OK http://MyGet.org/aspnetmaster/ 142ms
  GET https://az320820.vo.msecnd.net/v3-flatcontainer/boilerplate.web.mvc6/index.json
  GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
  Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
  GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
  OK https://az320820.vo.msecnd.net/v3-flatcontainer/boilerplate.web.mvc6/index.json 103ms
Warning: FindPackagesById: Boilerplate.Web.Mvc6
  Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
  GET http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6'
Warning: FindPackagesById: Boilerplate.Web.Mvc6
  Response from http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' is not a valid NuGet v2 service response.
Unable to locate Boilerplate.Web.Mvc6 >= 1.0.11
Writing lock file C:\Temp\WebApplication2\WebApplication2\project.lock.json
Restore complete, 1210ms elapsed

Errors in C:\Temp\WebApplication2\WebApplication2\project.json
    Unable to locate Boilerplate.Web.Mvc6 >= 1.0.11

NuGet Config files used:
    C:\Users\Rehan Saeed\AppData\Roaming\NuGet\NuGet.Config

Feeds used:
    https://az320820.vo.msecnd.net/v3-flatcontainer/
    http://MyGet.org/aspnetmaster/
2
Can you post all the nuget feeds you are using? You can find this under Tools->Options->Package Manageruser844705
I'm on my phone so I cant check, but try deselecting all feeds except the feed with the boilerplate package and then run Update-Package -reinstall Boilerplate.Web.Mvc6 in the package console.user844705
The feed url is wrong. It should be myget.org/F/aspnetmaster/api/v2davidfowl

2 Answers

3
votes

It might be a myget bug. I opened a bug on dnu anyway (see it here) and also pinged the myget folks.

The issue is that http://MyGet.org/aspnetmaster/FindPackagesById()?id='Boilerplate.Web.Mvc6' returns 200 OK and HTML when the package is not found and we try to parse it as XML.

You can pass --ignore-failed-sources to dnu restore to unblock yourself.

2
votes

I have tried deleting the project.lock.json file and re-opening Visual Studio which usually solves this problem for me.

I have since retried installing version 1.0.11 of the package and it magically worked. Since previous versions were working and I made no changes to the project or my installation, I suspect this to be a NuGet package on-boarding problem. It has taken three days for NuGet to register the new version of the package.