Aspnetcore: dotnet restore fails after getting version 1

Created on 27 Jun 2016  路  19Comments  路  Source: dotnet/aspnetcore

This issue popped up this morning after the Microsoft.NETCore.App (>= 1.0.0) was upgraded to version 1 from RC2. The problem occurs when I run a dotnet restore as a VSTS build step as well as locally on my VS2015 box.

Steps to reproduce

run dotnet restore on a MVC website

Expected behavior

dotnet restore works

Actual behavior

Errors in S:\portal\src\portal.Web\Portal.Web.xproj
    Version conflict detected for Microsoft.CodeAnalysis.Common.
     Portal.Web (>= 1.0.0) -> Microsoft.NETCore.App (>= 1.0.0) -> Microsoft.CodeAnalysis.VisualBasic (>= 1.3.0) -> Microsoft.CodeAnalysis.Common (>= 1.3.0)
     Portal.Web (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Tools (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Utils (>= 1.0.0-preview1-final) -> Microsoft.CodeAnalysis.CSharp.Workspaces (>= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Workspaces.Common (= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Common (= 1.3.0-beta1-20160429-01).
    Package Microsoft.AspNetCore.Mvc 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.AspNetCore.Mvc 1.0.0 supports:
      - net451 (.NETFramework,Version=v4.5.1)
      - netstandard1.6 (.NETStandard,Version=v1.6)
    One or more packages are incompatible with .NETCoreApp,Version=v1.0.
Feeds used:
    https://api.nuget.org/v3/index.json
    https://dotnet.myget.org/F/cli-deps/api/v3/index.json
    https://dotnet.myget.org/F/dotnet-core/api/v3/index.json

Environment data

`dotnet --info` output:

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64

project.json file

{
  "userSecretsId": "aspnet-FamilyPortal.Web-a9159440-714e-4476-81ad-8d47121b825f",

  "dependencies": {
    "Microsoft.NETCore.App": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.Extensions.SecretManager.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

.nuget/Nuget.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
    <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
    <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>

</configuration> 

Most helpful comment

I have resolved the build issue, though not sure if this is the right fix. I changed this line:

"Microsoft.NETCore.App": "1.0.0",

to this:

"Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },

All 19 comments

Try updating your tools to preview2

updating SDK tools and VS 2015 tools to preview 2 seems to not resolve the issue.

Update your dotnet to preview 2 also

Yes I did both. I removed all dotnet from add/remove programs and installed the following two:

DotNetCore.1.0.0-SDK.Preview2-x64.exe
DotNetCore.1.0.0-VS2015Tools.Preview2.exe

I obtained both installers from here -> https://www.microsoft.com/net/core#windows

Umm, okay... when I said tools I also meant this stuff

"Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },

This seems to resolve the dotnet restore issues, however now I get compile issues:

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win10-x64, win81-x64, win8-x64, win7-x64'. Possible causes:
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : 1. The project has not been restored or restore failed - run `dotnet restore`
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : 2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : 3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.

Here is my new project.json after upgrading the tools through nugget package manager:

{
  "userSecretsId": "aspnet-FamilyPortal.Web-a9159440-714e-4476-81ad-8d47121b825f",

  "dependencies": {
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "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.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.NETCore.App": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview2-final"
  },

  "tools": {
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

I have resolved the build issue, though not sure if this is the right fix. I changed this line:

"Microsoft.NETCore.App": "1.0.0",

to this:

"Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },

@jsouthron - not that this is causing the issue you are seeing but your references to tools seem to be misplaced. Some tools do need to be called out in application dependencies but tools that don't need to load/compile your project need to be only in the tools section. You can use this announcement to see what tools should go where. Razor tools (not there) should go in both "dependencies" and "tools" (similar to EF tools). Also, I believe you no longer need "imports".

@moozzyk - I had the same thoughts as you did. I updated the tools through Nuget Package Manager and that is how they ended up looking in project.json. I thought they didn't quite look right as dependencies rather than tools, however after playing around with this for hours, and having it work, I am satisfied for now. I imagine .net team will clean a lot of this up soon.

@yishaigalatzer - any thoughts on Nuget Package Manager moving tools references out? I am not sure if what is in the project after the changed made by Nuget Package Manager can even run...

Tool packages must be updated by editing the project.json file directly.

This scenario isn't supported in the NuGet UI today, and when the request to update/install is made it goes through the project system to update the project.json file.

@moozzyk it turns out that the site can run, however you cannot run dotnet publish-iisso if you are trying to substitute the web.config correctly (i.e., run the site in IIS), you will need to manually add this back in

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

Yes, you have to have:

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

without this the tool won't get restored and the postpublish script will fail (note - it won't fail publish) so you will end up with a web.config file that don't have correct entries and the application will not start in IIS.

Thank You @jsouthron
I was having an error after upgrading mvc core from 1.0 to 1.0.1

Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win10-x64, win81-x64, win8-x64, win7-x64'

and replacing in project.json
"Microsoft.NETCore.App": "1.0.1"
to

"Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    }

fixed it for me

I'm encountering this issue when I do this: dotnet new -t web followed by dotnet restore.

> dotnet restore
log  : Restoring packages for D:\VST\AspCore4\project.json...
error: Unable to resolve 'Microsoft.VisualStudio.Web.CodeGeneration.Tools (>= 1.0.0-preview2-update1)' for '.NETCoreApp,Version=v1.0'.
error: Unable to resolve 'Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 1.0.0-preview2-update1)' for '.NETCoreApp,Version=v1.0'.
> dotnet --info
.NET Command Line Tools (1.0.0-preview2-003133)

Product Information:
 Version:            1.0.0-preview2-003133
 Commit SHA-1 hash:  74df06500c

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64

Here's the project.json as initially created by by the dotnet new command:

{
  "userSecretsId": "aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a",

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.1",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-update1",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-update1",
      "type": "build"
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.Extensions.SecretManager.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "tooling": {
    "defaultNamespace": "WebApplication"
  }
}

@CalvinDale don't know why i am getting this same issue today, i had worked on the same package earlier and it used to work for me......nothing has changed since than only thing is my VS2015 has expired.

@its-saurabhjain I haven't had any luck with it. I've tried repaving all .NET Core and VS 2015 installs several times. My next step should be to repave the OS and start over. But instead I'm waiting for a new machine before I proceed.

Are the .Net Core / Angular 2 project templates fixed yet ?

Today, I've installed the latest version of .Net Core into VS2015 Update 3, and now, when I create a new project of type "ASP.Net Core Angular 2 Starter Application (.Net Core)", I get this error:

Errors in C:\Projects\DotNetCoreAngular2ApplicationTest\DotNetCoreAngular2ApplicationTest\DotNetCoreAngular2ApplicationTest.xproj
    Unable to resolve 'Microsoft.AspNetCore.AngularServices (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.

Looking at the project.json, a of of these libraries are underlined, as though they're not installed:

dotnetdependences

And if I try doing "Restore NuGet Packages" on this solution, I get a message to say:
All packages are already installed and there is nothing to restore.
... which is ironic, given what's waiting for me in the "Error List" tab...

dotnetdependences2

Errrrm.... I'm not impressed so far....

Again, all of these errors occur just by attempting to create a new Project. I haven't attempted to write one line of code yet...

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

githubgitgit picture githubgitgit  路  3Comments

guardrex picture guardrex  路  3Comments

markrendle picture markrendle  路  3Comments

rbanks54 picture rbanks54  路  3Comments

ermithun picture ermithun  路  3Comments