Sandeep
Sandeep

Reputation: 5771

Copy task not working in MSBuild 4

<Copy SourceFiles="@(sourceFiles)" DestinationFolder="$(destinationFolder)\"/>

This used to work fine for me in MSBuild 3.5. But since I've been trying to migrate to 4.0, MSBuild throws me this error.

The "Microsoft.Sdc.Tasks.Folder.Copy" task could not be loaded from the assembly Microsoft.Sdc.Tasks.dll. Confirm that the <UsingTask> 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.

I've tried putting the UsingTask, but still in vain. Any ideas?

Upvotes: 2

Views: 470

Answers (1)

Lex Li
Lex Li

Reputation: 63163

The reason is simple,

  1. You install http://sdctasks.codeplex.com/ in .NET 2.0 GAC. So MSBuild 2.0 or 3.5 can load it successfully.
  2. .NET 4 uses a different GAC, so MSBuild 4 cannot find what you install in .NET 2 GAC.

Therefore, you see an error message.

My advice,

  1. Switch to MSBuild Community Pack as suggested by http://sdctasks.codeplex.com/.
  2. Instead of adding an MSBuild extension assembly into GAC, you should put it into your dependency folder (such as lib), and add it to source control.
  3. When modifying your project file (such as csproj), make sure that in <UsingTask> you use the assembly path to your dependency folder.

My open source project #SNMP uses Gendarme MSBuild extension, and I have been using the above trick for a long time,

https://github.com/lextm/sharpsnmplib/blob/master/SharpSnmpLib/SharpSnmpLib.csproj

Upvotes: 1

Related Questions