'ClickOnce Publish error MSB3094: "DestinationFiles" refers to 2 item(s), and "SourceFiles" refers to 1 item(s)

I'm trying to publish a ClickOnce .NET 6 application that needs to have IBM DB2. From what I can tell, DB2 is causing an error related to the GenerateManifest, so as a work around for that I am setting GenerateManifest to false. With it disabled, though, I run into a new error. I created a very simple app to try to isolate what is causing this issue, but I'm still hitting the same problem. Everything builds fine, the issue is just with the publish step.

This is the command I'm running:

msbuild /t:publish /p:PublishProfile=ClickerTest\Properties\PublishProfiles\ClickOnceProfile.pubxml /property:Configuration=Release

This is the error that is being thrown:

Task "Copy" (TaskId:98)
  Task Parameter:UseHardlinksIfPossible=False (TaskId:98)
  Task Parameter:SkipUnchangedFiles=True (TaskId:98)
  Task Parameter:
      DestinationFiles=
          bin\Release\net6.0-windows\app.publish\Application Files\ClickerTest_1_0_0_10\ClickerTest.dll.manifest
          bin\Release\net6.0-windows\app.publish\Application Files\ClickerTest_1_0_0_10\ClickerTest.dll.deploy (TaskId:98)
  Task Parameter:
      SourceFiles=
          bin\Release\net6.0-windows\ClickerTest.dll.manifest (TaskId:98)
  Task Parameter:OverwriteReadOnlyFiles=False (TaskId:98)
  Task Parameter:UseSymboliclinksIfPossible=False (TaskId:98)

"C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj" (publish target) (1) ->
(_CopyFilesToPublishFolder target) ->
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5868,5): error MSB3094: 
"DestinationFiles" refers to 2 item(s), and "SourceFiles" refers to 1 item(s).
They must have the same number of items. [C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj]

This is the csproj file:

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Net.IBM.Data.Db2" Version="6.0.0.200" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
  </ItemGroup>
    


</Project>

And here is the ClickOnceProfile.pubxml

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <ApplicationRevision>10</ApplicationRevision>
    <ApplicationVersion>1.0.0.*</ApplicationVersion>
    <BootstrapperEnabled>True</BootstrapperEnabled>
    <Configuration>Release</Configuration>
    <CreateDesktopShortcut>True</CreateDesktopShortcut>
    <CreateWebPageOnPublish>True</CreateWebPageOnPublish>
    <GenerateManifests>False</GenerateManifests>
    <Install>True</Install>
    <InstallFrom>Web</InstallFrom>
    <InstallUrl>http://example.com/ClickerTest/</InstallUrl>
    <IsRevisionIncremented>True</IsRevisionIncremented>
    <IsWebBootstrapper>True</IsWebBootstrapper>
    <MapFileExtensions>True</MapFileExtensions>
    <OpenBrowserOnPublish>False</OpenBrowserOnPublish>
    <Platform>Any CPU</Platform>
    <ProductName>ClickerTest</ProductName>
    <PublishDir>bin\publish\</PublishDir>
    <PublishUrl>bin\publish\</PublishUrl>
    <PublisherName>Test</PublisherName>
    <PublishProtocol>ClickOnce</PublishProtocol>
    <PublishReadyToRun>False</PublishReadyToRun>
    <PublishSingleFile>False</PublishSingleFile>
    <SelfContained>False</SelfContained>
    <SignatureAlgorithm>(none)</SignatureAlgorithm>
    <SignManifests>False</SignManifests>
    <TargetFramework>net6.0-windows</TargetFramework>
    <UpdateEnabled>True</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateRequired>False</UpdateRequired>
    <WebPageFileName>Publish.html</WebPageFileName>
  </PropertyGroup>
</Project>

The entire output of the publish:

PS C:\Users\xxxxxx\source\repos\ClickerTest> msbuild ClickerTest\ClickerTest.csproj /t:publish /p:PublishProfile=ClickerTest\Properties\PublishProfiles\ClickOnceProfile.pubxml /property:Configuration=Release
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 4/25/2022 11:24:15 AM.
Project "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj" on node 1 (publish target(s)).
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2301,5): warning MSB3270: There was a mismatch between the processor architecture of the projec
t being built "MSIL" and the processor architecture of the reference "C:\Users\xxxxxx\.nuget\packages\net.ibm.data.db2\6.0.0.200\lib\net6.0\IBM.Data.Db2.dll", "AMD64". This mismatch may cause runtime failures. Please
consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references
 with a processor architecture that matches the targeted processor architecture of your project. [C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj]
CoreResGen:
  Processing resource file "Form1.resx" into "obj\Release\net6.0-windows\ClickerTest.Form1.resources".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreGenerateAssemblyInfo:
Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
CoreCompile:
  
  [Removed due to length requirements]
  
  CompilerServer: server - server processed compilation - 2e54e130-9bea-485d-aa85-ca3dcbb8622f
_CopyOutOfDateSourceItemsToOutputDirectory:
Building target "_CopyOutOfDateSourceItemsToOutputDirectory" partially, because some output files are out of date with respect to their input files.
  Copying file from "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\obj\Release\net6.0-windows\apphost.exe" to "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\ClickerTest.exe".
GenerateBuildRuntimeConfigurationFiles:
Skipping target "GenerateBuildRuntimeConfigurationFiles" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
  Copying file from "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\obj\Release\net6.0-windows\ClickerTest.dll" to "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\ClickerTest.dl
  l".
  ClickerTest -> C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\ClickerTest.dll
  Copying file from "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\obj\Release\net6.0-windows\ClickerTest.pdb" to "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\ClickerTest.pd
  b".
_CopyResolvedFilesToPublishPreserveNewest:
Building target "_CopyResolvedFilesToPublishPreserveNewest" partially, because some output files are out of date with respect to their input files.
  Copying file from "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\obj\Release\net6.0-windows\ClickerTest.dll" to "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\app.publish\Cl
  ickerTest.dll".
  Copying file from "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\ClickerTest.deps.json" to "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\app.publ
  ish\ClickerTest.deps.json".
  Copying file from "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\obj\Release\net6.0-windows\ClickerTest.pdb" to "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\app.publish\Cl
  ickerTest.pdb".
_CopyResolvedFilesToPublishAlways:
  Copying file from "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\obj\Release\net6.0-windows\apphost.exe" to "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\bin\Release\net6.0-windows\app.publish\Clicke
  rTest.exe".
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5868,5): error MSB3094: "DestinationFiles" refers to 2 item(s), and "SourceFiles" refers to 1 i
tem(s). They must have the same number of items. [C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj]
Done Building Project "C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj" (publish target(s)) -- FAILED.


Build FAILED.

"C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj" (publish target) (1) ->
(ResolveAssemblyReferences target) ->
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2301,5): warning MSB3270: There was a mismatch between the processor architecture of the proj
ect being built "MSIL" and the processor architecture of the reference "C:\Users\xxxxxx\.nuget\packages\net.ibm.data.db2\6.0.0.200\lib\net6.0\IBM.Data.Db2.dll", "AMD64". This mismatch may cause runtime failures. Pleas
e consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on referenc
es with a processor architecture that matches the targeted processor architecture of your project. [C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj]


"C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj" (publish target) (1) ->
(_CopyFilesToPublishFolder target) ->
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5868,5): error MSB3094: "DestinationFiles" refers to 2 item(s), and "SourceFiles" refers to 1
 item(s). They must have the same number of items. [C:\Users\xxxxxx\source\repos\ClickerTest\ClickerTest\ClickerTest.csproj]

    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.11


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source