gpt4 book ai didi

visual-studio-2015 - 在Visual Studio中还原时的“unknown keyword platform”

转载 作者:行者123 更新时间:2023-12-04 13:22:25 26 4
gpt4 key购买 nike

我正在将一个项目从.NET Core RC1转换为RC2。我已经安装了Visual Studio工具预览包,并将VS Nuget插件更新为最新版本。

这是一个测试项目,因此我需要根据library guideMicrosoft.NETCore.App添加到我的project.json中。看起来像这样:

{
"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",
}

该项目将在命令行( dotnet restore/build)上还原并生成。但是,当Visual Studio尝试还原软件包时,出现此错误:
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\

显然, "type": "platform"属性正在淘汰它,但是这不适用于最新的工具版本吗?

最佳答案

Tl; dr -用下面的global.json值更新或替换version

另外,请确保NuGet是updated。 (感谢小费,吉吉!)

此错误是由global.json中的旧工具版本引起的。如果未更新值(在移植项目时很容易错过),则即使安装了最新的工具也将莫名其妙地抛出此错误。

对于RC1时代的项目,您的global.json可能看起来像这样:

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

对于.NET Core 1.0 RTM,它应类似于:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}

棘手的部分是,即使 version: 1.0.0-rc2-20221 也无法使用!到目前为止, version: 1.0.0-preview2-003121是正确的值。上面的 global.json文件将同时与Visual Studio和 dotnet build/ dotnet run一起还原和编译。

关于visual-studio-2015 - 在Visual Studio中还原时的“unknown keyword platform”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37358046/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com