惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - Franky
MyScale Blog
MyScale Blog
A
About on SuperTechFans
博客园_首页
B
Blog RSS Feed
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
C
Check Point Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 【当耐特】
M
MIT News - Artificial intelligence
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
I
InfoQ
罗磊的独立博客

博客园 - SZW

微信 SDK + Senparc.AI + MCP 打造微信 AI 开发助手(二):在 Cursor、VS Code 等 IDE 中自动编写 微信 SDK + Senparc.AI + MCP 打造微信 AI 开发助手(一):网页版 Senparc.AI 系列教程(二):配置大模型,开始开发应用 Senparc.AI 系列教程(一):概要 Senparc 基础库全面适配 .NET 8.0 Senparc.Weixin SDK 微信平台开发教程(二十四):顺应 GenAI 应用,自动“续航”回复超长文本消息 微信新菜单类型 article_id 设置教程 微信 CLI 工具正式发布 v1.0 微信支付 V3 开发教程(一):初识 Senparc.Weixin.TenPayV3 [备忘]如何备份 VPN 文件 - SZW 动态 WebApi 引擎使用教程(3行代码完成动态 WebApi 构建) [备忘] 解决 rzc discover exited with code -2147450730 问题 “此 Url 可用于服务器 token 签名校验”提示 在开发环境内网穿透测试微信公众号 1个类,2个方法,3句代码,完成微信公众号开发的极简流程 [重要更新]微信小程序登录、用户信息相关接口调整:使用 wx.getUserProfile 取代 wx.getUserInfo [备忘]使用 .NET Core 模板生成时,在 .csproj 文件中使用条件编译的注意点 WeChatSampleBuilder V2.0 使用教程(网页版+桌面版) SCF(SenparcCoreFramework) 系列教程(一):项目介绍及快速搭建
[备忘]处理错误:Your project does not reference ".NE...
SZW · 2021-02-08 · via 博客园 - SZW

错误信息:

Your project does not reference ".NETFramework,Version=v4.5" framework. Add a reference to ".NETFramework,Version=v4.5" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.

其中一种可能是同一个项目目录,被 .NET Framework 和 .NET Core 两个不同的解决方案引用,导致 obj 内的信息混乱。

解决方案一: 不要同时打开两个具有共享项目文件夹的解决方案,并且注意切换的时候删除 obj 和 bin 文件夹。

解决方案二:添加以下代码到 .NET Framework 的项目文件(.csproj)中:

<Project>
  ...
  <PropertyGroup>
    <BaseOutputPath>$(MSBuildProjectDirectory)/out/$(MSBuildProjectName)/bin</BaseOutputPath>
    <BaseIntermediateOutputPath>$(MSBuildProjectDirectory)/out/$(MSBuildProjectName)/obj</BaseIntermediateOutputPath>
  </PropertyGroup>
  ...
</Project>

更多讨论参考:https://stackoverflow.com/questions/52833741/your-project-does-not-reference-netframework-version-v4-6-2-framework-add-a

I experienced similar issue, but with v4.7.2. Namely, I kept getting build log message like this:

error : Your project does not reference ".NETFramework,Version=v4.7.2" framework. Add a reference to ".NETFramework,Version=v4.7.2" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.

Despite the fact that it looked similar, none of the above proposed steps worked for me. I kept seeing this message after each build. Nothing seemed to be able to help.

In fact, the problem was related to that, due to migration, I had to put two projects in one folder of code. One of them was targeted at .Net Core, another at .Net Framework, both referenced same .Net Standard libraries. Apparently, they share the same obj folder where Core projects put project.assets.json file. Actually, exactly this file interferres with the Framework project preventing its normal build. Seems even if you performed Migrate from packages.config to PackageReference... which was recommended as one of possible solution.

You can try to fix the issue by putting the following snippet into your Framework project file:

<Project>
  ...
  <PropertyGroup>
    <BaseOutputPath>$(MSBuildProjectDirectory)/out/$(MSBuildProjectName)/bin</BaseOutputPath>
    <BaseIntermediateOutputPath>$(MSBuildProjectDirectory)/out/$(MSBuildProjectName)/obj</BaseIntermediateOutputPath>
  </PropertyGroup>
  ...
</Project>

It immediately worked for me, it was only later when I attentively read why we need it and why it works. I unexpectedly found it in part 2 of Migrating a Sample WPF App to .NET Core 3 under Making sure the .NET Framework project still builds section. BaseOutputPath and BaseIntermediateOutputPath msbuild variables can be found there, not sure if they are documented well anywhere.