9

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" />
Joshua Boyd
  • 315
  • 1
  • 3
  • 10
  • You probably need to install the MSBuildTasks in your computer. A better way to get rid of this issue is to install and use the MSBuildTasks nuget package – Rui Jarimba Nov 01 '18 at 18:20
  • See if this helps: https://stackoverflow.com/questions/11627304/msbuild-community-tasks-not-found – Rui Jarimba Nov 01 '18 at 18:22
  • @RuiJarimba Thanks Rui. I did run the following and it was already installed PM> Install-Package MSBuildTasks Package 'MSBuildTasks.1.5.0.235' already exists in project 'VirtualExpertClinics.AutismPro.Resource' Time Elapsed: 00:00:00.6184192 PM> I'll check out the link – Joshua Boyd Nov 01 '18 at 19:09

2 Answers2

9

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.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
1

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.

st35ly
  • 1,215
  • 18
  • 24
  • `MSBuild.exe.config` file doesn't seem to be editable. Is anything missing? – PineCone Oct 26 '20 at 14:18
  • @shaz copy file over into (some) temp folder outside of "program files" first, edit it as described upon, save it and copy back (with override option) to the VS root folder – st35ly Oct 26 '20 at 21:42