I am trying to migrate an Asp.Net Core RC1 project to RC2 and have been following this documentation and have also followed the instructions for DNX migration to .NET CLI.
In my case I had just updated all the nuget packages to their latest versions and nuget changed my 'Microsoft.NETCore.App' package reference to the following:
"Microsoft.NETCore.App": "1.1.0"
I changed it back to the following form and everything worked fine:
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
}
Good bye 3 hours of my life....
In Windows 7 with VS 2015, the soluiton after updating to netcore 1.1.2 was changing the project.json file as following:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": "1.1.2"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50" //This line must disappear
}
},
"runtimes": { //
"win7-x64": {} //Add this lines
} //
}
After changing this the dependencies will update and viola.
if you execute a dotnet new and look at the output project json, you will see that the monikers have changed.
Make the changes to your project.json as follows:
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
}
I found you need the following in project.json. Here is what was required to fix my error:
Dependencies
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
}
Frameworks
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
Runtime
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
You might want to add runtimes if you plan on publishing to IIS. Please see something as follows:
"runtimes": {
"win10-x64": {}
},
Here is a general tip that has worked well for me. When my stuff breaks, I sometimes create a default ASP.NET Core application either the website or empty web api to look at the dependencies in project.json and elsewhere. You can often catch a lot of things that way. The answers above are spot on, but I thought I would write this here in case someone wanted to separate the logic out more in the general template format that ASP.NET Core uses.
I should have done exactly what the error message said. When migrating from RC1, I did not realise that I had to specify a runtimes
section in my project.json
file.
In my project.json
I added the following section:
"runtimes": {
"win10-x64": { }
}
And I was good to go.
Update 27 February 2017
New project templates in Visual Studio 2017 RC no longer require run times to be specified (in project.json
or .csproj
) in advance if you choose to deploy your app as a Framework Dependent Deployment
(FDD).
If, however, you choose to deploy your app using Self-contained Deployment
(SCD), then you will need to specify all the run times you want your app to run on in advance in your .csproj
file.
Below is an example of a .csproj
file for an app that uses the SCD deployment method:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<VersionPrefix>1.0.0</VersionPrefix>
<DebugType>Portable</DebugType>
<RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>
Please see this link for more information, which includes a thorough description of both types of deployment options, as well as their benefits and disadvantages.
I received this error after updating VS2015 core template to 1.0.1. It was because I have a PCL that targets netstandard 1.4
if you don't want to have to specify each runtime, Just change the dependency markup for Microsoft.NETCore.App
to this:
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}