Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error MSB4226 MSBuild.Community.Tasks.Targets" was not found

New developer to a solution. I have the source code. When I try to compile I get the below error.

Previously, I worked around this on another computer by having another devloper on the project zip his folder and send it to me. But I would like to understand how I would fix this if I was net new to the project. Assume I don't have to rely on someone to send me their .target folder zipped up.

Error:

C:\Users\boyd\Source\Repos\insightstobehavior\Classroom_Package.proj(3,11):
 error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual S
tudio\2017\Community\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targ
ets" was not found. Also, tried to find "MSBuildCommunityTasks\MSBuild.Communit
y.Tasks.Targets" in the fallback search path(s) for $(MSBuildExtensionsPath) -
"C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Progra
m Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.e
xe.Config". Confirm that the path in the <Import> declaration is correct, and t
hat the file exists on disk in one of the search paths. 

From .project -

 <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
like image 548
Joshua Boyd Avatar asked Nov 01 '18 18:11

Joshua Boyd


2 Answers

error MSB4226 MSBuild.Community.Tasks.Targets" was not found

To resolve this issue, you should install the msbuildtasks msi installer:

https://github.com/loresoft/msbuildtasks/releases/download/1.5.0.235/MSBuild.Community.Tasks.v1.5.0.235.msi

You can check the readme.md of this MSBuild Community Tasks:

In order to use the tasks in this project, you need to import the MSBuild.Community.Tasks.Targets files.

If you installed the project with the msi installer, you can use the following.

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

After install that msi file, you will find the file MSBuild.Community.Tasks.Targets in the path C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks.

This will resolve this issue.

Hope this helps.

like image 92
Leo Liu-MSFT Avatar answered Nov 14 '22 23:11

Leo Liu-MSFT


I have got similar issue due to starting using VS 2019. All it says is that go to this file:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe.Config

open it and find what is in this node:

<projectImportSearchPaths>
      <searchPaths os="windows">

Change the value to navigate exactly where your MSBuild is right now. In my case, the change was:

<projectImportSearchPaths>
      <searchPaths os="windows">
        <property name="MSBuildExtensionsPath" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
        <property name="MSBuildExtensionsPath32" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
        <property name="MSBuildExtensionsPath64" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
        <property name="VSToolsPath" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)"/>
      </searchPaths>
    </projectImportSearchPaths>

value: Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio

Hope it helps.

like image 33
st35ly Avatar answered Nov 14 '22 23:11

st35ly