Skip to content

Fix Publish failing when an app targets netcoreapp1.1 and a P2P to a project that targets netcoreapp1.1 #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2017

Conversation

eerhardt
Copy link
Member

@eerhardt eerhardt commented Jan 4, 2017

The issue is that NETCore.App 1.1.0 now references DiaSymReader.Native nuget package and DiaSymReader.Native includes a "Content" item for the native assemblies. So the app gets duplicate "Content" items, one from the app project and one from the P2P project. When you have 2 duplicate Content items publish fails with:

"error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items."

Attached is a project that repros the issue with dotnet restore and dotnet publish the App project.

DiaSymTest.zip

…project that references NETCore.App 1.1.0.

The issue is that NETCore.App 1.1.0 now references DiaSymReader.Native nuget package and DiaSymReader.Native includes a "Content" item for the native assemblies.  So the app gets duplicate "Content" items, one from the app project and one from the P2P project.  When you have 2 duplicate Content items publish fails with:

"error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items."
@eerhardt
Copy link
Member Author

eerhardt commented Jan 4, 2017

/cc @srivatsn @nguerrera @dsplaisted

This bug is blocking the CLI from moving from netcoreapp1.0 to netcoreapp1.1.

Copy link
Contributor

@nguerrera nguerrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Could you add a test?

@eerhardt
Copy link
Member Author

eerhardt commented Jan 4, 2017

Looks good. Could you add a test?

Doh! Looks like I've been out of the game for a while...

@eerhardt
Copy link
Member Author

eerhardt commented Jan 4, 2017

@nguerrera - added a test

@nguerrera
Copy link
Contributor

👍

@natemcmaster
Copy link
Contributor

Just ran into this. Glad it's fixed now.

FYI for anyone else stuck on this error and trying to use RC.2 bits can workaround this by adding this:

<PackageReference Include="Microsoft.DiaSymReader.Native" Version="1.4.0" ExcludeAssets="Build" />

@rave1502
Copy link

rave1502 commented Jan 15, 2017

@nguerrera @natemcmaster

Hello, Get stuck over here.
IDE: VS2017 RC.
All is started with #543, but ended up here. After doing the fix suggested in #543 I get "MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items." error.

The two files whic I have modified to resolve the issue are attached.
gitsupport.zip

My project is "ASP .Net Core Web Application (.Net Framework)" and referring Windows Class Library .Net Framework 4.6.2

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup Label="Configuration">
    <DocumentationFile>xxxxxxx</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net462</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Data" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.0" />
    <PackageReference Include="Microsoft.Azure.DocumentDB" Version="1.11.1" />
    <PackageReference Include="Microsoft.DiaSymReader.Native" Version="1.4.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.0" />
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.0.0" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0-rc1" />
    <PackageReference Include="WindowsAzure.Storage" Version="8.0.1" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="xxxxxxxx.csproj" />
    ....
	<ProjectReference Include="xxxx.csproj" />
  </ItemGroup>
</Project>

The Error I get is

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Publish.targets(100,5): Error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items.

As suggested, Microsoft.NET.Publish.targets has the following entry

<Copy SourceFiles = "@(_ResolvedFileToPublishPreserveNewest)"
          DestinationFiles="@(_ResolvedFileToPublishPreserveNewest->'$(PublishDir)%(RelativePath)')"
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
          Retries="$(CopyRetryCount)"
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
          UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">

Please tell me if I am missing anything.

@rave1502
Copy link

Somehow, rebooting a machine has worked. I am good with the fix

@eerhardt eerhardt mentioned this pull request Jan 18, 2017
@jpozo20
Copy link

jpozo20 commented Jan 25, 2017

In my case I still have problems publishing the web app, with the "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items." error.

I tried the changes suggested by @nguerrera but it's still failing. Is there a way to get a build with the latest changes?

mmitche pushed a commit to mmitche/sdk that referenced this pull request Jun 5, 2020
…0190413.1 (dotnet#581)

- Microsoft.AspNetCore.Mvc.Analyzers - 3.0.0-preview5-19213-01
- Microsoft.AspNetCore.Mvc.Api.Analyzers - 3.0.0-preview5-19213-01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants