Issue while building SharePoint workflow project with Team Build 2010 with duplicate call to Workflow.targets

Following comes from Senior Support Engineer Deepak Mittal.

 

Issue description:
You may notice an error while building SharePoint workflow project with Team Build 2010.

 

Detailed error message:
Default Configuration and Platform
0 error(s), 1 warning(s)

$/ABC/Build/abc.csproj - 0 error(s), 1 warning(s)

C:\Builds\1\ABC\abc.csproj(589): "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Workflow.Targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets (37,3)". This is most likely a build authoring error. This subsequent import will be ignored.

1 projects/solutions compiled
No Test Results
No Code Coverage Results
Debug | Mixed Platforms
2 error(s), 4 warning(s)
$/ABC/Build/ABC.sln - 2 error(s), 4 warning(s)
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Workflow.Targets (121): Compilation failed. Unable to load one or more of the requested types.
Retrieve the LoaderExceptions property for more information.

 

Resolution:

Recently working on a case found an issue while building SharePoint project with Team Build 2010. Error message was as mentioned above. As per
the error message, there are some tasks which are defined in both workflow.targets and Microsoft.VisualStudio.SharePoint.targets and getting called during build. And as
the Microsoft.VisualStudio.SharePoint.targets is called first during build, it was throwing error on Workflow.targets. However, it was tough to found from where the Workflow.targets is getting called. We finally found that it was called from inside project's .csproj file. To resolve the issue, open the .csproj file in notepad and comment out the section where workflow.targets file is called.