简体   繁体   中英

Why nuget from VSTS nuget feed wants to install the same package multiple times and throwing error?

I have a REST Api implemented using Durable Function App in Azure, which uses netstandard2.0 , and I have other class libraries in this solution also using netstandard2.0 . One of them is contracts projects.

There is another solution where the UAT tests placed for this solution. The reason for this is that Specflow is still not available for .Net Core , it is available for .Net Framework only. Being able to test the Api I need the contracts for the Api. That is the reason I need to include the REST Api solution Contracts project (this one is netstandard2.0 ). This dependency is managed by nuget.

When I would like to install the Contracts package (using netstandard2.0 ) in Specflow project (which uses .Net Framework 4.7.1 ) I get the error below.

What I tried:

  • I restarted Visual Studio a few times because I experienced that sometimes it gets crazy when .Net Core or .Net Standard projects are in use. Restarting did not help.
  • I opened the project from JetBrains Rider, but it did not see the netstandard2.0 nuget package in the repository. I believe it is due to that the project uses .Net Framework 4.7.1 and not Net Standard 2.0
  • I saw the error Cannot create "C:\\...\\REST.Api.dll" because a file or directory with the same name already exists. . So, I deleted all packages under the solution packages directory. I also deleted cache in Visual Studio. But, the next time I started Visual Studio and tried to install package the same error occurred again.
  • I also tried to install package using console on my machine (nuget.exe install ...). The error is the same.

How it is possible to resolve this issue? I read that from .Net Framework 4.6 and above and .Net Core it is possible to reference .Net Standard libraries.

Attempting to gather dependency information for package 'REST.Api.1.0.0-20180305-154726' with respect to project 'MasterData.Features.HttpClient', targeting '.NETFramework,Version=v4.7.1'

Gathering dependency information took 861.8 ms

Attempting to resolve dependencies for package 'REST.Api.1.0.0-20180305-154726' with DependencyBehavior 'Lowest'

Resolving dependency information took 0 ms

Resolving actions to install package 'REST.Api.1.0.0-20180305-154726'

Resolved actions to install package 'REST.Api.1.0.0-20180305-154726'
  GET https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg

Retrieving package 'REST.Api 1.0.0-20180305-154726' from 'Sayusi Ando's Digital Library Packages'.
  OK https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg 2343ms

Installing REST.Api 1.0.0-20180305-154726.

Error downloading 'REST.Api.1.0.0-20180305-154726' from 'https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg'.

Cannot create "C:\Users\username\.nuget\packages\REST.api\1.0.0-20180305-154726\lib\netstandard2.0\REST.Api.dll" because a file or directory with the same name already exists.
  GET https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg
  OK https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg 462ms

Installing REST.Api 1.0.0-20180305-154726.

Error downloading 'REST.Api.1.0.0-20180305-154726' from 'https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg'.

Cannot create "C:\Users\username\.nuget\packages\REST.api\1.0.0-20180305-154726\lib\netstandard2.0\REST.Api.dll" because a file or directory with the same name already exists.
  GET https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg
  OK https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg 464ms

Installing REST.Api 1.0.0-20180305-154726.

Install failed. Rolling back...

Package 'REST.Api.1.0.0-20180305-154726' does not exist in project 'MasterData.Features.HttpClient'

Package 'REST.Api.1.0.0-20180305-154726' does not exist in folder 'C:\VSTS\REST.QA.Features\src\packages'

Executing nuget actions took 3.51 sec

Error downloading 'REST.Api.1.0.0-20180305-154726' from 'https://xyzrepository.visualstudio.com/_packaging/689a2aa0-1e6a-4f39-8389-250b4ad44db8/nuget/v3/flat2/REST.api/1.0.0-20180305-154726/REST.api.1.0.0-20180305-154726.nupkg'.
  Cannot create "C:\Users\username\.nuget\packages\REST.api\1.0.0-20180305-154726\lib\netstandard2.0\REST.Api.dll" because a file or directory with the same name already exists.

Time Elapsed: 00:00:05.5462783

The root of the problem is that the target properties conflicted with another filename. (names are shortened)

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
      <!-- package stuff -->
    <dependencies>
      <group targetFramework=".NETStandard2.0" />
    </dependencies>
  </metadata>
  <files>
    <file src="..." target="lib\netstandard2.0\Contracts.dll" />
    <file src="..." target="lib\netstandard2.0\Contracts.dll" />
    <file src="..." target="lib\netstandard2.0\Contracts.dll" />
  </files>
</package>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM