"unknown keyword platform" during recovery in Visual Studio

I am converting a project from .NET Core RC1 to RC2. I installed the Visual Studio Tools preview package and updated the VS Nuget plugin to the latest version.

This is a test project, so I need to add Microsoft.NETCore.App to my project.json for the library guide . It looks like this:

 { "dependencies": { "dotnet-test-xunit": "1.0.0-rc2-build10015", "FluentAssertions": "4.2.1", "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-final", "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-3002702" }, "xunit": "2.1.0" }, "frameworks": { "netcoreapp1.0": { "imports": [ "dotnet", "portable-net45+win8" ] } }, "testRunner": "xunit", } 

The project is restored and built on the command line ( dotnet restore/build ). However, when Visual Studio tries to recover the packages, I get this error:

 PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git C:\Users\Nate\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc2-20221\bin\dnx.exe "C:\Users\Nate\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc2-20221\bin\lib\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" restore "C:\Users\Nate\Documents\stormpath-dotnet-config\test\Stormpath.Configuration.Test" Microsoft .NET Development Utility Clr-x86-1.0.0-rc2-20221 CACHE https://api.nuget.org/v3/index.json Restoring packages for C:\Users\Nate\Documents\stormpath-dotnet-config\test\Stormpath.Configuration.Test\project.json ---------- C:\Users\Nate\Documents\stormpath-dotnet-config\test\Stormpath.Configuration.Test\project.json(0,0): Error: Microsoft.Dnx.Runtime.FileFormatException: unknown keyword platform ---> System.InvalidOperationException: unknown keyword platform at Microsoft.Dnx.Runtime.LibraryDependencyType.Parse(String keyword) at Microsoft.Dnx.Runtime.ProjectReader.PopulateDependencies(String projectPath, IList`1 results, JsonObject settings, String propertyName, Boolean isGacOrFrameworkReference) at Microsoft.Dnx.Runtime.ProjectReader.ReadProject(Stream stream, String projectName, String projectPath, ICollection`1 diagnostics) at Microsoft.Dnx.Runtime.Project.TryGetProject(String path, Project& project, ICollection`1 diagnostics) --- End of inner exception stack trace --- at Microsoft.Dnx.Runtime.Project.TryGetProject(String path, Project& project, ICollection`1 diagnostics) at Microsoft.Dnx.Tooling.RestoreCommand.<RestoreForProject>d__69.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dnx.Tooling.RestoreCommand.<>c__DisplayClass68_0.<<Execute>b__2>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Dnx.Tooling.RestoreCommand.<Execute>d__68.MoveNext() ---------- Restore failed unknown keyword platform NuGet Config files used: C:\ProgramData\NuGet\Config\Microsoft.VisualStudio.Offline.config C:\Users\Nate\AppData\Roaming\NuGet\nuget.config Feeds used: https://api.nuget.org/v3-flatcontainer/ C:\Users\Nate\Documents\LocalNuget C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ 

Obviously, the "type": "platform" property discards it, but should this not work with the latest release of the toolkit?

+6
source share
3 answers

Tl; dr - update or replace global.json version value below.

Also, make sure that NuGet is updated . (Thanks for the tip, gigi!)

This error is caused by the old toolkit in global.json . If the value has not been updated (it is easy to skip when transferring projects), this error will inexplicably be triggered even when installing the latest snap-in.

Your global.json might look like this for an RC1-era project:

 { "projects": [ "src", "test" ], "sdk": { "version": "1.0.0-rc1-update1" } } 

For RTM.NET Core 1.0, it should look like this:

 { "projects": [ "src", "test" ], "sdk": { "version": "1.0.0-preview2-003121" } } 

The hard part is that even version: 1.0.0-rc2-20221 will not work! version: 1.0.0-preview2-003121 - the correct value at the moment. The global.json file above will restore and compile with both Visual Studio and dotnet build / dotnet run .

+15
source

Adding the code below defines your problem. I went through this error and reached this question, but the answer above is suitable for my scenario, so I am adding another answer that helped me -

See In my case, we need to add EntityFrameworkCore.Tools and EntityFrameworkCore.Designin project.json The code that needed to be added to the .json project

 { "dependencies": { "Microsoft.EntityFrameworkCore.Design": { "version": "1.0.0-*", "type": "build" } }, "tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-*" } } 

Below is the second change that may help you

 "frameworks": { "netcoreapp1.0": { "imports": [ "dnx451", "portable-net45+win8" ] } }, 
0
source

After completing the above steps, the problem will not be resolved. Then I found that manually installing the .NET Framework-.NET Core and the framework ( https://github.com/dotnet/cli ).

After installation, the problem will be solved and be sure to map the path node.js to tools->option->projects and solutions->External web tools

enter image description here

0
source

All Articles