The “GetReferenceNearestTargetFrameworkTask” task

2019-01-23 22:44发布

I have problem with autocompletion in VS 2017 Community.

Previously I had VS 2017 Enterprise from school, but key expired. So I moved to community.

Before, everything works great, but now it doesnt work at all.

I was here: enter link description here

but doesnt work, so found another solution here: enter link description here

And I got this:

Build FAILED.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1601,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 in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin" directory. 0 Warning(s) 1 Error(s)

Time Elapsed 00:00:00.11

Do you know what to do next?

Thank you

4条回答
做个烂人
2楼-- · 2019-01-23 23:05

I was seeing this issue with msbuild 15.6.82 on a build environment that does not have VisualStudio 2017, only VS Build Tools.

Here's a PowerShell script that resolves this issue, it pretty much does the equivalent of previous answers in the VS Installer, but silently and waiting for completion.

Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" --quiet --add Microsoft.VisualStudio.Component.NuGet.BuildTools --add Microsoft.Net.Component.4.5.TargetingPack --norestart --force' -Wait -PassThru

查看更多
对你真心纯属浪费
3楼-- · 2019-01-23 23:19

I had the same error message but for a different problem.

So, I'm using MSBuild to automate build/deploy process for Azure Functions. Everything was working fine until I updated both Visual Studio 2017 and Visual Studio Build Tools 2017 at which point I started getting this error. To be precise I got this error only when using MSBuild, building project manually from VS was working fine.

In my case I already had everything set as per @Programmer's answer. But as I was using MSBuild it turned out that I also had to install NuGet targets and build tasks which are part of Visual Studio Build Tools.

Screenshot of Visual Studio Installer

查看更多
手持菜刀,她持情操
4楼-- · 2019-01-23 23:19

I'm working with a headless build server on server core, resolved by installing chocolatey package choco install visualstudio2017-workload-webbuildtools from here:

https://chocolatey.org/packages?q=msbuild

查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-23 23:26

Follow these to fix that error. This applies to VS 2017:

Fix 1:

1.Install Nuget PackageManager from here.

2.Restart Visual Studio.


If the problem is still there, continue below

Fix 2:

1.Download and start/run the Visual Studio Installer again.

2.While the Visual Studio Installer is still running, go to the "Individual Components" tab

3.Tick the "NuGet package manager" check-box that is under "Code tools" option.

4.Click Install to install it.

Screenshot of where this is located:

enter image description here

That should fix the error you see in this question. Restart Visual Studio and test the auto-completion function. If it's not working, see the answers from this question as that is a whole different issue.

查看更多
登录 后发表回答