Core: How to reference COM in Net Core 3.0

Created on 5 Dec 2018  ·  14Comments  ·  Source: dotnet/core

Issue Title

How to reference COM in Net Core 3.0

General

Below code can not work:

  <ItemGroup>
    <COMReference Include="IWshRuntimeLibrary">
      <Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
      <VersionMajor>1</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>tlbimp</WrapperTool>
      <Isolated>False</Isolated>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </COMReference>
  </ItemGroup>

dotnet build return error:

C:\Program Files\dotnet\sdk\3.0.100-preview-009812\Microsoft.Common.CurrentVersion.targets(2734,5): error MSB4062: 未能从程序集 Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 加载任务“Microsoft.Build.Tasks.ResolveComReference”。 请确
认 <UsingTask> 声明正确,该程序集及其所有依赖项都可用,并且该任务包含实现 Microsoft.Build.Framework.ITask 的公共类。 [D:\HLST\更新程序\UpDateClient\UpDateClient.csproj]
question

Most helpful comment

I think most of the work for supporting COMReference would be in MSBuild so I'd file at https://github.com/Microsoft/msbuild/issues.

All 14 comments

Resolving COM references isn't (yet?) supported on core msbuild. In the meantime, does it work when you use msbuild from the developer command prompt?

e.g.

msbuild -r
dotnet run --no-build

cc @rainersigwald @dsplaisted @nguerrera is there a plan for resolving COM references from core msbuild?

@dasMulli I run msbuild -r, but seems not use netcore3.0 sdk to build:

D:\HLST\更新程序\UpDateClient>dotnet --version
3.0.100-preview-009812

D:\HLST\更新程序\UpDateClient>msbuild -r
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.20+g88f5fadfbe
版权所有(C) Microsoft Corporation。保留所有权利。

生成启动时间为 2018/12/5 18:25:53。
D:\HLST\更新程序\UpDateClient\UpDateClient.csproj : error : C:\Program Files\dotnet\sdk\2.1.500\Sdks\Microsoft.NET.Sdk.Wind
owsDesktop\Sdk not found. Check that a recent enough .NET Core SDK is installed and/or increase the version specified i
n global.json.
D:\HLST\更新程序\UpDateClient\UpDateClient.csproj : error : C:\Program Files\dotnet\sdk\2.1.500\Sdks\Microsoft.NET.Sdk.Wind
owsDesktop\Sdk not found. Check that a recent enough .NET Core SDK is installed and/or increase the version specified i
n global.json.
节点 1 上的项目“D:\HLST\更新程序\UpDateClient\UpDateClient.csproj”(默认目标)。
D:\HLST\更新程序\UpDateClient\UpDateClient.csproj : error MSB4236: 找不到指定的 SDK“Microsoft.NET.Sdk.WindowsDesktop” 。
已完成生成项目“D:\HLST\更新程序\UpDateClient\UpDateClient.csproj”(默认目标)的操作 - 失败。


生成失败。

  D:\HLST\更新程序\UpDateClient\UpDateClient.csproj : error : C:\Program Files\dotnet\sdk\2.1.500\Sdks\Microsoft.NET.Sdk.Wi
ndowsDesktop\Sdk not found. Check that a recent enough .NET Core SDK is installed and/or increase the version specified
 in global.json.


  D:\HLST\更新程序\UpDateClient\UpDateClient.csproj : error : C:\Program Files\dotnet\sdk\2.1.500\Sdks\Microsoft.NET.Sdk.Wi
ndowsDesktop\Sdk not found. Check that a recent enough .NET Core SDK is installed and/or increase the version specified
 in global.json.


“D:\HLST\更新程序\UpDateClient\UpDateClient.csproj”(默认目标) (1:2) ->
  D:\HLST\更新程序\UpDateClient\UpDateClient.csproj : error MSB4236: 找不到指定的 SDK“Microsoft.NET.Sdk.WindowsDesktop ”。

    0 个警告
    3 个错误

已用时间 00:00:00.10

@AaronRobinsonMSFT is driving referencing-COM-from-Core. No full plan yet, but we're meeting today to talk about one.

I run msbuild -r, but seems not use netcore3.0 sdk to build:

This is due to https://blogs.msdn.microsoft.com/dotnet/2018/11/13/net-core-tooling-update-for-visual-studio-2017-version-15-9/

It is recommended to use Visual Studio 2019 Preview 1 with .NET Core 3.0 Preview 1.

@MiyamuraMiyako Thanks for trying out this feature! You can find a sample with some details here.

@jeffschwMSFT Anything special you want to do with this issue?

Let's mark this issue as a 3.0 scenario. As we get further in the design, we may be able to implement it as suggested, but we also may need to enable the scenario in a slightly different way.

@AaronRobinsonMSFT we should move this issue to coreclr, or link it to an existing issue.

@rainersigwald Is this the correct repo to add an issue about making a COMReference in dotnet-sdk?

I think most of the work for supporting COMReference would be in MSBuild so I'd file at https://github.com/Microsoft/msbuild/issues.

It seems that my issue has caused a lot of discussion.
@AaronRobinsonMSFT Thanks, I will try it and keep track of this feature.

Is there anything still to track / route out of here? Or can we close this issue @AaronRobinsonMSFT?

I think at this point, we can close this issue.

Was this page helpful?
0 / 5 - 0 ratings