错误NETSDK1004资产文件project.assets.json未找到,错误MSB4036 "GetReferenceNearestTargetFrameworkTask "任务未找到。

问题描述 投票:0回答:1

我在这台电脑上用同样的dotnet项目工作了2-3个月,直到安装了JetBrains Rider之后才有了惊喜。运行 dotnet restore 没有任何输出,而运行 dotnet build, dotnet watch build 或类似的东西输出了一个错误,说这。

error NETSDK1004: Assets file project.assets.json not found. Run a NuGet package restore to generate this file.

最糟糕的是... dotnet build 失误,但 msbuild 在同一个项目上运行,成功地构建了该项目(想出了尝试 msbuild 也花了不少时间)。) 这看起来很疯狂,并不能解释什么。

在通过重新安装所有累积的10多个.NET Core SDK版本进行摸索后,没有任何变化。但我认为卸载Rider后,我开始得到另一个错误。

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1655,5): error MSB4036: The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin" directory. 
c# .net-core msbuild rider
1个回答
0
投票

tl;dr:删除了这个环境变量。

MSBUILD_EXE_PATH
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe

而所有的... dotnet CLI命令又开始工作了.它是怎么到那里的--我不知道,可能是Rider把它加在那里的。但我打开了两个CMD窗口,直到你重新启动CMD,它有相同的环境变量。

那个有 MSBUILD_EXE_PATH 集有错误,没有的那个没有,工作正常。

希望能帮到大家,不要因为到处找不明白是怎么回事而浪费一天半的时间。

© www.soinside.com 2019 - 2024. All rights reserved.