.NET Core生成错误:错误MSB4062 Microsoft.Build.Tasks.ResolveComReference [英] .NET Core error on build: error MSB4062 Microsoft.Build.Tasks.ResolveComReference

查看:782
本文介绍了.NET Core生成错误:错误MSB4062 Microsoft.Build.Tasks.ResolveComReference的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发.net核心网络应用(定位为net461)。
该应用程序需要引用COM dll。

I'm working on a .net core web app (targeting net461). The app needs to reference a COM dll.

我添加了COM引用,但该应用程序仍在我的开发机上构建。
但是,在生成服务器上它无法生成此错误:

I added the COM reference and the app still builds on my dev machine. However, on the build server it fails to build with this error:

C:\Program Files(x86)\dotnet\ sdk\2.0.0\Microsoft.Common.CurrentVersion.targets(2604,5):错误MSB4062:无法从程序集Microsoft.Build.Tasks.Core <中加载 Microsoft.Build.Tasks.ResolveComReference任务/ em>

C:\Program Files (x86)\dotnet\sdk\2.0.0\Microsoft.Common.CurrentVersion.targets(2604,5): error MSB4062: The "Microsoft.Build.Tasks.ResolveComReference" task could not be loaded from the assembly Microsoft.Build.Tasks.Core

经过一些搜索,这似乎是一个非常罕见的错误。
任何人都知道错误是什么和/或如何解决该错误吗?

After searching a bit, it seems like it's a pretty uncommon error. Anyone know what the error is and/or how to fix it?

更新:似乎像dotnet CLI不支持COM引用。 Visual Studio在后台直接使用msbuild,但是在生成服务器上,我使用的是dotnet CLI命令。

UPDATE: Seems like the dotnet CLI does not support COM references. Visual Studio uses msbuild directly behind the scenes, but on the build server, I was using the dotnet CLI commands.

WORKAROUND:

WORKAROUND:


  1. 引用COM dll并重建。 Visual Studio将生成一个互操作的
    dll。它将被命名为Interop.MyComDLL.dll之类的名称。可以在生成输出目录中找到它。

  2. 将生成的Interop dll复制到应用程序中的某个位置(我只是
    在根应用程序级别使用了/ dlls文件夹)。 / li>
  3. 删除COM dll参考。

  4. 向Interop dll添加直接引用(Dependencies> Add Reference ...>在Visual Studio中浏览)


推荐答案

如果您尝试使用与构建服务器上相同的命令来构建它,那么它也应该在开发人员机器上失败,例如

It should also fail on developer machine if you try to build it using the same command as on build server, e.g.

dotnet.exe build Solution.sln --configuration Release --no-incremental

VS使用msbuild构建解决方案,这是另一种方式。

VS building solution using msbuild, it's a different way.

这篇关于.NET Core生成错误:错误MSB4062 Microsoft.Build.Tasks.ResolveComReference的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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