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

这在 MSBuild 3.5 中对我来说很好用。但是由于我一直在尝试迁移到 4.0,MSBuild 向我抛出了这个错误。

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.

我试过把UsingTask, 但仍然是徒劳的。有任何想法吗?

4

1 回答 1

1

原因很简单,

  1. 您在 .NET 2.0 GAC 中安装http://sdctasks.codeplex.com/ 。所以 MSBuild 2.0 或 3.5 可以成功加载它。
  2. .NET 4 使用不同的 GAC,因此 MSBuild 4 无法找到您在 .NET 2 GAC 中安装的内容。

因此,您会看到一条错误消息。

我的建议,

  1. 按照http://sdctasks.codeplex.com/的建议切换到 MSBuild 社区包。
  2. 与其将 MSBuild 扩展程序集添加到 GAC 中,不如将其放入依赖文件夹(例如 lib)中,并将其添加到源代码管理中。
  3. 修改项目文件(例如 csproj)时,请确保在<UsingTask>您使用依赖项文件夹的程序集路径。

我的开源项目#SNMP 使用 Gendarme MSBuild 扩展,并且我已经使用上述技巧很长时间了,

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

于 2012-10-11T12:17:57.333 回答