无法加载 ResolveComReference 任务 [英] ResolveComReference task could not be loaded

查看:39
本文介绍了无法加载 ResolveComReference 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Win7,VS2017,ASP Net core app,目标框架为4.6.

Win7, VS2017, ASP Net core app, target framework is 4.6.

当我尝试使用 CLI 构建我的项目时(在 dotnet 命令调用之前需要它),发生错误:

When I try to build my project with CLI (it is needed before dotnet commands calling) the error occurs:

C:...\Microsoft.Common.CurrentVersion.targets(2547,5): 错误 MSB4062:Microsoft.Build.T asks.ResolveComReference"任务不能从程序集 Microsoft.Build.Tasks.Core 加载,版本 = 15.1.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a.确认声明是正确的,即大会及其所有依赖项可用,并且该任务包含一个公共类实现 Microsoft.Build.Framework .ITask.[C:\project.csproj]

C:...\Microsoft.Common.CurrentVersion.targets(2547,5): error MSB4062: The "Microsoft.Build.T asks.ResolveComReference" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. 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. [C:\project.csproj]

我一直在寻找与我的问题相关的问题,并做了以下几件事:

I have been looking for questions related with my issue and have done the following things:

  • 重启VS
  • 使用 VS 工具清理并构建项目(成功)
  • 加载 Microsoft.Build 包
  • 删除packages文件夹的内容并重新加载

但没有什么能帮到我.

它可以是什么?

推荐答案

.NET CLI 使用的 MSBuild 的 .net 核心版本不支持 COM 引用.为了使这些引用起作用,您必须直接使用 msbuild 构建您的项目.使用 Visual Studio 2017 的开发人员命令提示符,您应该能够使用以下命令执行构建:

COM references are not supported by the .net core version of MSBuild which is what the .NET CLI uses. For those references to work, you have to build your project using msbuild directly. Using the Developer Command Prompt for Visual Studio 2017 you should be able to perform the build using commands like:

msbuild /t:Restore
msbuild /t:Build /p:Configuration=Release
msbuild /t:Publish /p:Configuration=Release

(您也可以添加 /m 以启用并行构建).

(you can also add /m to enable parallel builds).

运行使用这些项目文件的 CLI 工具时也不支持此引用,因为它们也依赖于 MSBuild 的 .NET Core 版本.

This reference is also unsupported when running CLI tools that use these project files since they also rely on the .NET Core version of MSBuild.

但是,有一种变通方法可以使 CLI 工具能够使用该项目,但不允许它们使用 .NET Cli 完全构建.将以下 Condition 属性添加到您的 ComReference 项以在使用 .NET Core 版本的 MSBuild 构建时隐藏"COM 引用:

However, there is a workaround that will enable CLI tools to be able to use the project, but it will not allow them to fully build using the .NET Cli. Add the following Condition attribute to your ComReference items to "hide" the COM reference when building with the .NET Core version of MSBuild:

<COMReference Include="FooBar" Condition="'$(MSBuildRuntimeType)' != 'Core'">
  <Guid>{some-guid}</Guid>
  <!-- a lot more metadata elements -->
</COMReference>

这篇关于无法加载 ResolveComReference 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆