您的项目未引用“.NETFramework,Version=v4.5”框架。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36190601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Your project is not referencing the ".NETFramework,Version=v4.5" framework.
提问by S. Loveland ECY
I am using VS 2015.
我正在使用 VS 2015。
Your project is not referencing the ".NETFramework,Version=4.5" framework. Add a reference to ".NETFramework,Version=4.5" in the "frameworks" section of your project.json, and then re-run NuGet restore.
您的项目未引用“.NETFramework,Version=4.5”框架。在 project.json 的“frameworks”部分中添加对“.NETFramework,Version=4.5”的引用,然后重新运行 NuGet 还原。
I am getting this error on my Data Access and Business Logic layers, shortly after adding to my MVC Layer. Things were building fine until then, but I don't know what triggered this error. Here is my project.json:
在添加到我的 MVC 层后不久,我在我的数据访问和业务逻辑层上收到此错误。在那之前一切都很好,但我不知道是什么触发了这个错误。这是我的 project.json:
{
"version": "1.0.0-*",
"description": "foo bar Class Library",
"authors": [ "foo bar" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": { },
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
Here's what I have tried:
这是我尝试过的:
- Replacing "dotnet5.4" with "net451" (and deleting it) as found in this answer.
- 将“dotnet5.4”替换为“net451”(并删除它),如本答案所示。
Result is the same error.
结果是同样的错误。
- Replacing "dotnet5.4" with "net45" and leaving the "net451". This results in a new error:
- 用“net45”替换“dotnet5.4”并留下“net451”。这会导致一个新的错误:
Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win":{} }' to your project.json and then re-run NuGet restore.
您的 project.json 没有 runtimes 部分。您应该将 '"runtimes": { "win":{} }' 添加到您的 project.json,然后重新运行 NuGet 还原。
I tried doing as this error suggested and adding
我尝试按照此错误建议进行操作并添加
"runtimes": {
"win": {}
},
This got me this error, which I can't seem to move past:
这给了我这个错误,我似乎无法过去:
Your project.json doesn't list 'win' as a targeted runtime. You should add '"win": {}' inside your "runtimes" section in your project.json, and then re-run NuGet restore.
您的 project.json 没有将“win”列为目标运行时。您应该在 project.json 的“运行时”部分中添加 '"win": {}',然后重新运行 NuGet 还原。
I've already added "win", and this is beginning to feel like a red herring. What am I doing altering the project.json directly, isn't NuGet handling this?
我已经添加了“胜利”,这开始让人感觉像是在骗人。我在做什么直接改变 project.json,NuGet 不是在处理这个吗?
采纳答案by Thierry
I actually just figured out the problem. I ended up clicking on Restore Nuget Packagesat the solution level and I managed to compile my PCLfile, and then the rest of my solution.
我实际上只是想出了问题。我最终点击Restore Nuget Packages了解决方案级别,我设法编译了我的PCL文件,然后是我的解决方案的其余部分。
Hope this helps.
希望这可以帮助。
回答by Chris R. Donnelly
I had this same problem, and I ended up having to not only delete the contents of binand objfolders, but also the .vsdirectory for the solution.
我遇到了同样的问题,我最终不仅要删除bin和obj文件夹的内容,还要删除.vs解决方案的目录。
回答by crimbo
I had the same problem - this occurs still using Visual Studio 2017.3, which uses .csproj files instead of project.json. Interestingly, the error message still contains the text "project.json".
我遇到了同样的问题 - 这仍然使用 Visual Studio 2017.3,它使用 .csproj 文件而不是 project.json。有趣的是,错误消息仍然包含文本“project.json”。
It appears the cause of this issue is a lock file or obj\project.assets.jsonfile (depending on your version of VS) from a previous build, which is not removed during a clean, as described here.
此问题的原因似乎是obj\project.assets.json先前构建中的锁定文件或文件(取决于您的 VS 版本),如此处所述,在清理期间未将其删除。
Manually deleting the /objdirectory is a quick workaround.
手动删除/obj目录是一种快速的解决方法。
If you have a "new" project (eg .NET Core or netstandard project created in VS 2017) and an "old" project in the same directory (eg .NET 4.6 project created in VS 2015), it appears they will continually fight because they both use the ./objdir in different ways. More info here..
如果您有一个“新”项目(例如在 VS 2017 中创建的 .NET Core 或 netstandard 项目)和同一目录中的“旧”项目(例如在 VS 2015 中创建的 .NET 4.6 项目),它们似乎会持续战斗,因为他们都./obj以不同的方式使用目录。更多信息在这里。.
The msbuild workaround is to make one of your projects use a different objdir. I added this to my "old" csproj:
msbuild 解决方法是让您的项目之一使用不同的obj目录。我将此添加到我的“旧”csproj:
<PropertyGroup>
<!-- Needed due to old project and new project in same directory: https://github.com/NuGet/Home/issues/5126 -->
<BaseIntermediateOutputPath>obj_netfx\</BaseIntermediateOutputPath>
</PropertyGroup>
回答by Melbourne Developer
I found that a rogue project.lock.json was causing this issue for me. Once I deleted the file, the problem went away.
我发现一个流氓 project.lock.json 给我造成了这个问题。一旦我删除了文件,问题就消失了。
Hereis some documentation on project.lock.json.
这是关于 project.lock.json 的一些文档。
Some further advice would be to ensure that project.lock.json is ignored in your git ignore file, and to try a full git clean. Make sure you understand the implications of a Git clean before you do that though.
一些进一步的建议是确保在您的 git ignore 文件中忽略 project.lock.json,并尝试完整的 git clean。不过,在执行此操作之前,请确保您了解 Git 清理的含义。
回答by Waescher
I had the same issue after updating to Visual Studio for Mac 7.4 (build 1033):
更新到 Visual Studio for Mac 7.4(内部版本 1033)后,我遇到了同样的问题:
Error: Your project is not referencing the "MonoAndroid,Version=v7.1" framework. Add a reference to "MonoAndroid,Version=v7.1" in the "frameworks" section of your project.json, and then re-run NuGet restore.
I don't have any json project files. The tips in here did not help either, so I had to find out the hard way that I had to install the lastest Android SDK (Oreo 8.1) in addition to my target SDK (Nougat 7.1).
我没有任何 json 项目文件。这里的提示也没有帮助,所以我不得不找出除了我的目标 SDK (Nougat 7.1) 之外我必须安装最新的 Android SDK (Oreo 8.1) 的艰难方法。


