I have a solution with many .NET Core projects. I did NuGet updates to all of the project and now when I try to build I get the following errors (for some of the projects - not all):
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. The project has not been restored or restore failed - run `dotnet restore`
2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.
3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.
What seemed to help was a post I found here Can not find runtime target for framework .NETCoreApp=v1 compatible with one of the target runtimes
I added the following to the failing projects:
"runtimes": {
"win10-x64": { }
}
That seemed to fix the issue. But my question is, why was this happening only on some projects? The projects that did not issue the error doesn't have such runtime definition in their project.json
file.
What exactly does this runtime definition means? how does it affect my ability to run on other os like linux or mac?
What exactly does this runtime definition means?
runtimes
lists the runtimes that our package supports. Listing runtimes is necessary for self-contained deployments. A deployment is self-contained when it brings its own runtime.
How do we know if our deployment is self-contained? dependencies
list the packages on which our package depends. These dependencies come in three types.
build
the package is for building only and is not part of the deploymentplatform
the package will depend on a pre-installed runtimedefault
neither of thoseIf our "Microsoft.NETCore.App"
dependency is of the default
type, then it is self-contained, and we will need to bring our own runtimes. If it is of the platform
type, then it is framework dependent.
why was this happening only on some projects?
It will only happen in projects that are self-contained deployments. If you look thru those projects that do not require a runtimes
property, you will find that they are either class libraries or framework dependent.
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0"
}
}
}
},
"runtimes": {
"win10-x64": {},
"osx.10.10-x64": {}
}
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
"frameworks": {
"netstandard1.6": {}
}
how does it affect my ability to run on other os like linux or mac?
It doesn't. Windows, Mac OS, and Linux can all either have a runtime pre-installed or have the application bring its own runtime.
See also