Skip to content

Dotnet Restore foo.sln -- fails when configurations in SLN cause duplicate (but diff config) projects in restore graph #4316

Closed

Description

@TheRealPiotrP

Moving from dotnet/cli#4857 on behalf of @twsouthwick

Steps to reproduce

This solution has an ASP.NET Core project (targeting .NET 4.6) with a new csproj file and a number of libraries all targeting .NET 4.6 that are still using the old csproj format.

Run dotnet restore

I can build and run in Visual Studio 2017 RC, but fails at command line.

Expected behavior

Restores correctly

Actual behavior

  Restoring packages for C:\Users\*USER*\AppData\Local\Temp\u5vck04v.wg2\u5vck04v.wg2.csproj...
  Writing lock file to disk. Path: C:\Users\*USER*\AppData\Local\Temp\u5vck04v.wg2\obj\project.assets.json
  Generating MSBuild file C:\Users\*USER*\AppData\Local\Temp\u5vck04v.wg2\obj\u5vck04v.wg2.csproj.nuget.g.targets.
  Generating MSBuild file C:\Users\*USER*\AppData\Local\Temp\u5vck04v.wg2\obj\u5vck04v.wg2.csproj.nuget.g.props.
  Restore completed in 2382.5973ms for C:\Users\*USER*\AppData\Local\Temp\u5vck04v.wg2\u5vck04v.wg2.csproj.

  NuGet Config files used:
      C:\Users\*USER*\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      C:\Users\*USER*\AppData\Local\Temp\0amxhhhs.f0v
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018: The "RestoreTask" task failed unexpectedly.\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018: System.InvalidOperationException: Sequence contains more than one matching element\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018:    at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018:    at NuGet.Commands.MSBuildRestoreUtility.GetPackageSpec(IEnumerable`1 items)\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018:    at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018:    at NuGet.Commands.MSBuildRestoreUtility.GetDependencySpec(IEnumerable`1 items)\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018:    at NuGet.Build.Tasks.RestoreTask.Execute()\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r [C:\Users\*USER*\Source\Repos\Project\Solution.sln]
c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130\NuGet.targets(70,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [C:\Users\*USER*\Source\Repos\Project\Solution.sln]

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview4-004130)

Product Information:
 Version:            1.0.0-preview4-004130
 Commit SHA-1 hash:  a0060ac321

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10240
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   c:\users\*USER*\Downloads\dotnet-dev-win-x64.latest\sdk\1.0.0-preview4-004130

Activity

  1. added this to the 4.0 RTM milestone on Jan 18, 2017
  2. rrelyea commented on Jan 18, 2017

    @rrelyea
    Contributor

    @twsouthwick - do you have a sample project that shows this problem?

  3. twsouthwick commented on Jan 18, 2017

    @twsouthwick

    I don't have one at the moment. If I remember, I ran dotnet restore against the .sln and got this error. When I ran it against the .csproj for the specific project, it restore correctly. If this description isn't enough to get a repro, I can try to put one together.

  4. emgarten commented on Jan 19, 2017

    @emgarten
    Member

    It looks like something is auto generating a project and referencing it, and that project doesn't contain valid properties for nuget.

    @twsouthwick a repro would be helpful

  5. rrelyea commented on Jan 25, 2017

    @rrelyea
    Contributor

    didn't repro the invalid operation exception at all, either.

    dotnet restore is not aware of Packages.config.
    @twsouthwick - Is that the scenario you ran into. If so, please use Nuget.exe restore instead.

  6. added
    Resolution:NotRepro
    on Jan 26, 2017
  7. rrelyea commented on Jan 26, 2017

    @rrelyea
    Contributor

    Closing as not repro. @twsouthwick - would love more data or validation when you can.

  8. emgarten commented on Jan 31, 2017

    @emgarten
    Member

    @swoog what version of dotnet CLI are you using?

  9. 26 remaining items

  10. changed the title [-]RestoreTask fails with InvalidOperationException [/-] [+]Dotnet Restore foo.sln -- fails when configurations in SLN cause duplicate (but diff config) projects in restore graph[/+] on Feb 8, 2017
  11. iskiselev commented on Feb 9, 2017

    @iskiselev

    @rrelyea, is nuget.exe 4.0 publicly accessible somewhere to workaround this problem?

  12. clairernovotny commented on Feb 9, 2017

    @clairernovotny

    I'm still hitting this in RC4...and it's blocking me with xUnit for Devices:
    https://github.com/xunit/devices.xunit/blob/master/xUnit.Devices.sln

    I'm trying to call msbuild /t:restore xunit.devices.sln and get:

    C:\dev\git\devices.xunit [master ≡]> msbuild /t:restore .\xUnit.Devices.sln
    Microsoft (R) Build Engine version 15.1.545.13942
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
    Build started 2/8/2017 4:18:22 PM.
    Project "C:\dev\git\devices.xunit\xUnit.Devices.sln" on node 1 (restore target(s)).
    ValidateSolutionConfiguration:
      Building solution configuration "Debug|Mixed Platforms".
    ValidateProjects:
      The project "integration.iOS" is not selected for building in solution configuration "Debug|Mixed Platforms".
      The project "integration.android" is not selected for building in solution configuration "Debug|Mixed Platforms".
      The project "integration.uwp" is not selected for building in solution configuration "Debug|Mixed Platforms".
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(97,5):
    error : Sequence contains more than one matching element [C:\dev\git\devices.xunit\xUnit.Devices.sln]
    Done Building Project "C:\dev\git\devices.xunit\xUnit.Devices.sln" (restore target(s)) -- FAILED.
    
    
    Build FAILED.
    
    "C:\dev\git\devices.xunit\xUnit.Devices.sln" (restore target) (1) ->
    (Restore target) ->
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(97,5)
    : error : Sequence contains more than one matching element [C:\dev\git\devices.xunit\xUnit.Devices.sln]
    
        0 Warning(s)
        1 Error(s)
    
    Time Elapsed 00:00:01.76
    
  13. iskiselev commented on Feb 9, 2017

    @iskiselev

    I have the same problem, if configuration of any project doesn't match Solution configuration. So, not only setting Platform=x64 to some project within AnyCpu solution platform, but also setting Release configuration to some projects in Debug solution configuration provokes it.

  14. emgarten commented on Feb 9, 2017

    @emgarten
    Member
  15. rrelyea commented on Feb 9, 2017

    @rrelyea
    Contributor

    Please finish PR review/feedback (if any).
    Then ensure you've tested it all it needs.
    Then merge into dev.

  16. twsouthwick commented on Feb 10, 2017

    @twsouthwick

    Can you post when this should end up in an available build? I've got a few projects hitting this and would like to test as soon as it's available.

  17. kzu commented on Feb 20, 2017

    @kzu

    I'm seeing this in the latest VS2017RC too. Any ideas when this will hit the stable channel?

    Repro: clone & run msbuild /t:restore in folder https://github.com/NuGet/NuGet.Build.Packaging/tree/9de80814eadc29d15b27c4a674139a53b71a2558/src/Build

    Version information:

    Microsoft Visual Studio Enterprise 2017 RC
    Version 15.0.26206.0 D15REL
    Microsoft .NET Framework
    Version 4.6.01586
    
    Installed Version: Enterprise
    ...
    NuGet Package Manager   4.0.0
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
    
  18. added a commit that references this issue on Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions