【问题标题】:Confirm that the <UsingTask> declaration is correct?确认 <UsingTask> 声明是否正确?
【发布时间】:2023-03-16 18:25:01
【问题描述】:

我在我的项目中使用 postsharp。当我尝试构建解决方案时,出现以下错误。 "The "PostSharp.MSBuild.PostSharp30DetectNativeFrameworkVersion" task could not be loaded from the assembly C:\ProgramData\PostSharp\3.1.49\bin.Release\PostSharp.MSBuild.v3.1.49.Release.dll. Confirm that the &lt;UsingTask&gt; 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."

如何解决?

谢谢

【问题讨论】:

  • PostSharp 可能没有正确添加到项目中。您可以尝试重新安装 PostSharp NuGet 包。还要在 *.csproj 文件中检查程序集引用和“import”元素是否引用相同版本的 PostSharp。

标签: postsharp


【解决方案1】:

我刚才遇到了那个确切的问题。我更改的最后一件事是添加构建后事件(将 .dll 和 .pdb 复制到另一个目录)。

我一开始并没有“连接”这两个事件,我仍然不确定是否存在连接,而是检查了 PostSharp.MSBuild.v{version}.Release.dll 是否存在 - 在我的情况下它没有。我从所有项目中删除了 PostSharp NuGet 包,删除了包目录并重新安装了包。之后,PostSharp.MSBuild.v{version}.Release.dll 确实存在,但这并没有解决问题。

我记得我添加了一个构建后复制事件并删除了并且我重新启动了我的 IDE。只有在做了这两件事之后,我才尝试再次构建解决方案 - 这很有效。

我再次添加了 postbuild 事件并点击了重建,它也很有效。所以我不完全确定是否可以通过重新安装 NuGet 包并重新启动 Visual Studio 来解决问题,或者 postbuild copy 命令是否存在问题。

【讨论】:

  • 对我来说,重新启动我的 IDE 作为关键。
猜你喜欢
  • 2018-04-12
  • 2019-08-25
  • 2012-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多