2
votes

I am trying to compile some C++/CLI using MSBuild. I am getting an error:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppClean. targets(74,5): error MSB4062: The "CppClean" task could not be loaded from the assembly Microsoft.Build.CppTasks.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not load file or assembly 'Microsoft.Build.CppTasks.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

A colleague of mine has fixed this error by installing Visual Studio 2010 SP1 on his machine, but I already have that installed (as well as Visual Studio 2012 with Update 1) yet am getting this error. I have checked the path from the error message, and both the Microsoft.CppClean.targets and Microsoft.Build.CPPTasks.Common.dll files exist.

The CPPClean task appears to be part of the MSBuild tasks specific to Visual C++. Is there any way to get this as a separate installer so that I can repair it, or as part an installer for another set of tools? Failing that, is there another way of fixing this error?

1
Does Microsoft.Build.CPPTasks.Common.dll contain CppClean class? You can check it with dotpeek / reflector. I.e. idea is to understand is it issue with a build, or with DLL?Lanorkin
@Lanorkin: Yes, the CppClean task is in the assembly.adrianbanks
Do you have it in GAC? Looks like it is requested by assembly name, not by file name: UsingTask TaskName="CppClean" AssemblyName="Microsoft.Build.CppTasks.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" You can use gacutil /l to checkLanorkin
Try adding /p:VisualStudioVersion=11.0 to MSBuildKMoraz

1 Answers

2
votes

Prompted by Lanorkin's comment, I checked the GAC and the Microsoft.Build.CppTasks.Common.dll assembly was not in there. I added it manually, and it now builds.