question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

COM Wrappers are not copied correctly to publish directory when there is more than one COM reference

See original GitHub issue

Repro

With the following project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <COMReference Include="Microsoft.Office.Access.dll">
      <Guid>4affc9a0-5f99-101b-af4e-00aa003f0f07</Guid>
      <VersionMajor>9</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <WrapperTool>tlbimp</WrapperTool>
      <Lcid>0</Lcid>
      <Isolated>false</Isolated>
      <Private>true</Private>
    </COMReference>
  </ItemGroup>
  <ItemGroup>
    <COMReference Include="Microsoft.Office.Access.Dao.dll">
      <Guid>4ac9e1da-5bad-4ac7-86e3-24f4cdceca28</Guid>
      <VersionMajor>12</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <WrapperTool>tlbimp</WrapperTool>
      <Lcid>0</Lcid>
      <Isolated>false</Isolated>
    </COMReference>
  </ItemGroup>

</Project>

Publish the project (with full MSBuild because that is needed for COMReference support): msbuild /restore /t:publish

Expected

Microsoft.Office.Access.dll and Microsoft.Office.Access.Dao.dll are both present in the publish folder

Actual

Neither is in the output folder, but a file with the names mashed together is: Interop.Microsoft.Office.Interop.Access.dll;Interop.Microsoft.Office.Interop.Access.Dao.dll

Analysis

It appears that the @ needs to be replaced by % here: https://github.com/dotnet/sdk/blob/ac7fd98a7b6f8e625aab8977029813bec6088e70/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L528

Original issue description

With release 16.5 and SDK 3.1.200 the problem still exists !!! Now the dll name will corrupted

Why you don’t fix this with the new release ???

Interop.Microsoft.Office.Interop.Access.dll;Interop.Microsoft.Office.Interop.Access.Dao.dll;Interop.Microsoft.Office.Core.dll

only one file is copyed with all names inside !!!

Severity Code Description Project File Line Suppression State Error MSB3094 “DestinationFiles” refers to 3 item(s), and “SourceFiles” refers to 1 item(s). They must have the same number of items. Esi.Bootstrap.Package C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets 692

  <Target Name="_CopyPackageFiles" DependsOnTargets="_ConvertItems">
    <Copy SourceFiles="%(File.FullPath)" DestinationFiles="%(File.CopyToTargetPath)" Condition="%(File.CopyToTargetPath) != ''"/>

    <ItemGroup>
      <FileWrites Include="%(File.CopyToTargetPath)" Condition="%(File.CopyToTargetPath) != ''" />
    </ItemGroup>
  </Target>

I created a new .net core wpf application and add a com dependency.

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <COMReference Include="Microsoft.Office.Access.dll">
      <Guid>4affc9a0-5f99-101b-af4e-00aa003f0f07</Guid>
      <VersionMajor>9</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <WrapperTool>tlbimp</WrapperTool>
      <Lcid>0</Lcid>
      <Isolated>false</Isolated>
      <Private>true</Private>
    </COMReference>
  </ItemGroup>

</Project>

On publishing to folder the COM+ reference dll will not copyed to the publishing folder.

WpfApp1.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
sidatacomcommented, Apr 2, 2020

Sounds good I’m excited !

1reaction
dsplaistedcommented, Apr 2, 2020

@sidatacom This will be fixed in Visual Studio 16.6. It should likely make its way into preview versions of the 3.1.300 .NET Core SDK in the next few days. You can download the preview from the links in the table here: https://github.com/dotnet/installer/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Found multiple publish output files with the same relative ...
There's a new feature that blocks multiple files from being copied to the same target directory with the same file name.
Read more >
Common MSBuild Project Items
In MSBuild, an item is a named reference to one or more files. Items contain metadata such as file names, paths, and version...
Read more >
Docker COPY issue - "no such file or directory"
For me the directory was in the correct context, only it was included in the (hidden) .dockerignore file in the root of the...
Read more >
Msbuild get directory name. props imported, or something ...
Then, I want it to build project B and others which are in C:\SomeFolder\Sub. ... The dotnet publish command accepts MSBuild options, such...
Read more >
Keeping Content Out of the Publish Folder for WebDeploy
I've run into issues with keeping files from publishing with WebDeploy on numerous occasions. When working with large projects it's not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found