gallivantor
gallivantor

Reputation: 1221

Errors upgrading .NET Core app to 1.1

So, I have a happily working ASP.NET Core 1.0 app targeting net461 framework.

Today I tried to upgrade it to the new ASP.NET Core 1.1 (according to the instructions on this page all you need to do is a Nuget package upgrade)

This resulted in the following slew of errors:

error: Unable to resolve 'Microsoft.AspNetCore.Diagnostics.Abstractions (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.AspNetCore.Hosting.Abstractions (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.AspNetCore.Http.Extensions (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.AspNetCore.WebUtilities (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.Extensions.FileProviders.Physical (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.Extensions.Logging.Abstractions (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.Extensions.Options (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'System.Diagnostics.DiagnosticSource (>= 4.3.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'System.Reflection.Metadata (>= 1.4.1)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.AspNetCore.Mvc.ApiExplorer (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
error: Unable to resolve 'Microsoft.AspNetCore.Mvc.Cors (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'.
...

what am I missing here? Shouldn't this just work?

For reference, here are the relevant sections of the project.json (before running the Nuget upgrade):

  "dependencies": {
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.AspNet.WebApi.Client": "5.2.3"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net461": {
       "imports": [
      ]
    }
  }

EDIT: after running the Nuget upgrade, the dependencies section was changed to this by Visual Studio:

  "dependencies": {
    "Microsoft.AspNet.WebApi.Client": "5.2.3",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0"
  },

Upvotes: 3

Views: 5461

Answers (2)

Nikita R.
Nikita R.

Reputation: 7503

I suspected something similar to what @gallivantor mentioned in his #1, but somehow something kept rewriting the NuGet.config file behind the UI and when I re-started Visual Studio per @jim-w's suggestion, the NuGet.org item would go back to un-checked.

So I decided to look into the NuGet.config file and noticed that there were two sections: <packageSources> and <disabledPackageSources>. And the source with the NuGet.org key was in both. I tried to remove it from the disabled packages section and everything started working.

Before:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  <disabledPackageSources>
    <add key="nuget.org" value="true" /> <!-- This is what I was referring to -->
  </disabledPackageSources>
</configuration>

After:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

Warning: I omitted a number of details (in particular about the environment) to keep the answer simple. Before applying this solution to your situation make sure it is appropriate to your circumstances.

Upvotes: 0

gallivantor
gallivantor

Reputation: 1221

I finally figured it out, in case anyone else has the same problem.

There were three steps to make it work:

  1. For some reason, the standard "Microsoft and .NET" Nuget feed was not including these packages.. I had to open the Nuget Settings and tick the "nuget.org" feed as well. Having done that it was able to restore the v1.1 packages

  2. The blog post that I was referencing didn't mention that you need to open your global.json file and change the SDK Version to "1.0.0-preview2-1-003177" (for some reason, v1.1 still has an SDK called v1.0.0 -- any ideas what's going on there?!?)

  3. Having done those two things, trying to run the app produced a 500 error, but after enabling stdoutLogEnabled in web.config you can see the exception is:

System.IO.FileLoadException: Could not load file or assembly 'System.Collections.Immutable, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

To solve this, you need to delete your application's bin folder and then rebuild (for some reason "Rebuild Solution" isn't enough). When you deploy to Production, presumably you'll also need to delete the bin folder there or you might get the same problem.

Upvotes: 9

Related Questions