sdk: Bad error message if Microsoft.NETCore.App isn't a "platform" in the project.json

Steps to reproduce

Create a new project/exe that uses the netcoreapp1.0 framework.

Add a dependency “Microsoft.NETCore.App”:“1.0.0-rc2-24015”

Expected behavior

A better error saying that the type needs to be a platform. The entry should be “Microsoft.NETCore.App”: { “version”: “1.0.0-rc2-24015”, “type”: “platform” } And that fixes the error correctly.

Actual behavior

Errors that suggest putting in RID’s

Severity    Code    Description Project File    Line    Suppression State
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:   Dapper.Tests    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets  241 
Error       1. The project has not been restored or restore failed - run `dotnet restore`   Dapper.Tests    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets  241 
Error       2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.   Dapper.Tests    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets  241 

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc2-002418)

Product Information: Version: 1.0.0-rc2-002418 Commit Sha: a8686e58fc

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

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 14
  • Comments: 28 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Hopefully this helps someone, I ran into this error message after upgrading some nuget packages in an ASP.NET Core project.

My project.json file had this line before nuget upgrade: "Microsoft.NETCore.App": { "version": "1.0.1", "type": "platform" }

Then after upgrade, that line was removed and this was added: "Microsoft.NETCore.App": "1.0.1"

Since this now doesn’t list the platform (the focus of this GitHub issue), you just need to revert the newly added line to the previous block (with the “type”: “platform”).

@wilfredogr the solution is to add type: platform to the Microsoft.NETCore.App dependency, like so:

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

I don’t think “A better error saying that the type needs to be a platform.” is accurate. It’s entirely reasonable to use Microsoft.NETCore.App without "type": "platform" in a standalone project. In which case, the exception line …

Error 2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 
'runtimes' section.

… is fairly clear. I agree though with the sentiment of @onovotny that this is bound to come up and confuse devs new to the application types.

Perhaps, the exception could be a bit more explicit:

Error 2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 
'runtimes' section. If the project does not include '"type": "platform"' with the 
'Microsoft.NETCore.App' dependency and this is a self-contained standalone application, 
list one or more of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section of 
'project.json', restore the project, and use 'dotnet publish --runtime {RID}' to obtain 
executable output.

… wordy, yes, but utterly clear what needs to be done. Outside of that, another option would be for exceptions to hotlink to stable documents … e.g., this would link directly to @blackdwarf’s upcoming application types document, which also makes it clear what the dev should do.

I agree with @wilfredogr this issue should NOT be closed. First of all, the underlying issue (that a nuget update suddenly breaks a working .NET Core Website by removing “type”: “platform”) is not fixed and is a critical issue.

Secondly the error message is crap as it’s not clear that a nuget upgrade may have simply broken the project.json. So a much better error message is needed, perhaps something that also describes what it means to be a “type”: “platorm” (i.e. this is the default needed for a .NET Core Website) would help save people from wasting more than 10 minutes on something NuGet/Visual Studio breaks.

thanks it works for me, 😃 I got this bug when transfering my .net core solution to other laptop, I changed my global.json from “version”: “1.0.0-preview2-003121” to “version”: “1.0.0-preview2-003131” and got error, what does this setting “type”: “platform” do exactly ?

How do you close if the solution is not clear? I have the same issue with ASPNetCore 1.1.0. I didn’t change anything because it is supposed Visual Studio 2015 creates everything from the template I’m using (MVC) right? So how do you determine is JSON problem? Users don’t create this file.

This is my project.json: { “dependencies”: { “Microsoft.AspNetCore.Razor.Tools”: { “version”: “1.0.0-preview2-final”, “type”: “build” }, “BundlerMinifier.Core”: “2.2.306”, “Microsoft.ApplicationInsights.AspNetCore”: “1.0.2”, “Microsoft.AspNetCore.Diagnostics”: “1.1.0”, “Microsoft.AspNetCore.Mvc”: “1.1.0”, “Microsoft.AspNetCore.Routing”: “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.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”, “Microsoft.NETCore.App”: “1.1.0”, “Microsoft.VisualStudio.Web.BrowserLink.Loader”: “14.1.0”, “Microsoft.EntityFrameworkCore.SqlServer”: “1.1.0”, “Microsoft.EntityFrameworkCore.Tools”: “1.1.0-preview4-final”, “Microsoft.EntityFrameworkCore.Design”: “1.1.0” },

“tools”: { “Microsoft.EntityFrameworkCore.Tools.DotNet”: “1.0.0-preview3-final”, “Microsoft.AspNetCore.Razor.Tools”: “1.0.0-preview2-final”, “Microsoft.AspNetCore.Server.IISIntegration.Tools”: “1.0.0-preview2-final” },

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

“buildOptions”: { “emitEntryPoint”: true, “preserveCompilationContext”: true },

“runtimeOptions”: { “configProperties”: { “System.GC.Server”: true } },

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

“scripts”: { “prepublish”: [ “bower install”, “dotnet bundle” ], “postpublish”: [ “dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%” ] } }

Since this is a project.json issue and there is a workaround available I’m closing this issue.

As per this documentation

The type: platform property on that dependency means that at publish time, the tooling will skip publishing the assemblies for that dependency to the published output. You don’t need these since they will be installed with .NET Core on the targeted machine.

I am getting this error when trying to deploy for first time a web app with "version": "1.0.0-preview2-003131" in global.json and

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

and

"frameworks": {
    "netcoreapp1.0": {
    }
  },

in project.json

Am I to assume that this version 1.0.1 is not installed in Team Services host?