NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 252 forks source link

VS 2022 - Unable to satisfy conflicting requests for the same version #12211

Closed kabua closed 1 year ago

kabua commented 1 year ago

NuGet Product Used

Visual Studio Package Management UI

Product Version

VS Pro 2022 version 17.3.4

Worked before?

It did work in an earlier version VS2022 but don't remember which one.

Impact

I'm unable to use this version

Repro Steps & Context

Back Ground We expose our internal frameworks as NuGet packages to our development teams. But debugging these frameworks as multiple NuGet packages is very challenging, therefore, we use ProjectReferences and conditional build settings to manage these challenges.

Issue We have a project called Empower.Common (which is part of a larger framework), which depends on Empower.Configuration. Both Empower.Common and Empower.Configuration depends on Smartwebs.System.

When building in debug mode, we want to reference these projects as ProjectReferences, but in release mode or during the package building step, we want to reference these packages using PackageReference. This arrangement worked in VS2019 and earlier versions of VS 2022.

Now, we get 410 Errors just from this one project. If we reload the other 6 projects, we are seeing 2,488 errors.

We are also seeing this error, The "GenerateDepsFile" task failed unexpectedly because An item with the same key has already been added. What key has already been added?

Here's the full error message:

3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018: System.ArgumentException: An item with the same key has already been added.
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.DependencyContextBuilder..ctor(SingleProjectInfo mainProjectInfo, Boolean includeRuntimeFileVersions, RuntimeGraph runtimeGraph, ProjectContext projectContext)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute()
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
3>    Done building target "GenerateBuildDependencyFile" in project "Empower.Common.csproj" -- FAILED.

Potential Cause We think the issue has to do with ProjectReference and PackageReference not playing nicely together. Here are the relationships: Empower.Common -> (ProjectReference) Empower.Configuration Empower.Common -> (ProjectReference) Smartwebs.System

Empower.Configuration -> (PackageReference) Smartwebs.System (v10.0.0-a003-debug)

Therefore, Empower.Common is getting majorly confused as to how to resolve all package references found in Smartwebs.System project and from Smartwebs.System package. Even though they both reference the same folder location and source code.

Here are the three project files (source file references excluded):

Empower.Common.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net48;net6.0-windows</TargetFrameworks>
    <LangVersion>latest</LangVersion>
    <Description>The common 'common' layer for Empower based applications.</Description>
    <NoWarn>1701;1702;NU1603</NoWarn>
  </PropertyGroup>
  <ItemGroup Condition="'$(Configuration)'=='Release' or '$(swPack)'=='1'">
    <PackageReference Include="Empower.Configuration" Version="10.0.0-a003-Debug" />
    <PackageReference Include="Smartwebs.System" Version="10.0.0-a005-Debug" />
  </ItemGroup>
  <ItemGroup Condition="'$(Configuration)'!='Release' and '$(swPack)'!='1'">
    <ProjectReference Include="..\..\Empower.Configuration\Empower.Configuration\Empower.Configuration.csproj" />
    <ProjectReference Include="..\..\Smartwebs\Smartwebs.System\Smartwebs.System.csproj" />
  </ItemGroup>
</Project>

Empower.Configuration.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net48;net6.0-windows</TargetFrameworks>
    <LangVersion>latest</LangVersion>
    <Nullable>enable</Nullable>
    <DebugType>embedded</DebugType>
    <IncludeSymbols>False</IncludeSymbols>
    <NoWarn>1701;1702;NU1603</NoWarn>
    <EnableNETAnalyzers>True</EnableNETAnalyzers>
    <AnalysisLevel>latest-recommended</AnalysisLevel>
    <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Smartwebs.System" Version="10.0.0-a005-Debug" />
    <PackageReference Include="EntityFramework">
      <Version>6.4.4</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
    <PackageReference Include="Newtonsoft.Json">
      <Version>13.0.1</Version>
    </PackageReference>
    <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
    <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
  </ItemGroup>
</Project>

Smartwebs.System.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net48;net6.0-windows</TargetFrameworks>
    <LangVersion>latest</LangVersion>
    <Nullable>enable</Nullable>
    <Description>The most common components that make up Smartwebs' core library.</Description>
    <EnableNETAnalyzers>True</EnableNETAnalyzers>
    <EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
    <DebugType>embedded</DebugType>
    <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
    <NoWarn>1701;1702;1591</NoWarn>
    <AnalysisLevel>latest-recommended</AnalysisLevel>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Fody" Version="4.2.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="IndexRange" Version="1.0.2" />
    <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
    <PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="1.1.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
    <PackageReference Include="ModuleInit.Fody" Version="1.9.0" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
    <PackageReference Include="NLog" Version="4.7.2" />
    <PackageReference Include="Nullable" Version="1.3.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Polly" Version="7.2.2" />
    <PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'net48'">
    <Reference Include="System.Net.Http" />
  </ItemGroup>
</Project>

Verbose Logs

Note: we replace the list of Deleted and Copied files with `...` to make the log more manageable to read.

Rebuild started...
1>------ Skipped Rebuild All: Project: Empower.Configuration, Configuration: Debug Any CPU ------
1>Project not selected to build for this solution configuration 
2>------ Skipped Rebuild All: Project: Smartwebs.System, Configuration: Debug Any CPU ------
2>Project not selected to build for this solution configuration 
Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\Empower.Configuration.csproj...
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.System\Smartwebs.System.csproj...
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs.Security.Core\Smartwebs.Security.Core\Smartwebs.Security.Core.csproj...
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.Web\Smartwebs.Web.csproj...
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.Security\Smartwebs.Security.csproj...
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.DataAccess\Smartwebs.DataAccess.csproj...
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.WebServices\Smartwebs.WebServices.csproj...
Restoring packages for C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\Empower.Common.csproj...
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs.Security.Core\Smartwebs.Security.Core\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.Security\obj\project.assets.json
Restored C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs.Security.Core\Smartwebs.Security.Core\Smartwebs.Security.Core.csproj (in 106 ms).
Restored C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.Security\Smartwebs.Security.csproj (in 106 ms).
  CACHE https://proget.smartwebs.com/nuget/Empower8/v3/flatcontainer/system.codedom/index.json
  CACHE https://proget.smartwebs.com/nuget/Empower10-beta/v3/flatcontainer/system.codedom/index.json
  CACHE https://proget.smartwebs.com/nuget/Empower8c/v3/flatcontainer/system.codedom/index.json
  CACHE https://proget.smartwebs.com/nuget/Empower8/v3/flatcontainer/system.configuration.configurationmanager/index.json
  CACHE https://proget.smartwebs.com/nuget/Empower10-beta/v3/flatcontainer/system.configuration.configurationmanager/index.json
  CACHE https://proget.smartwebs.com/nuget/Empower8c/v3/flatcontainer/system.configuration.configurationmanager/index.json
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.WebServices\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.DataAccess\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.System\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.Web\obj\project.assets.json
Restored C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.DataAccess\Smartwebs.DataAccess.csproj (in 696 ms).
Restored C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.System\Smartwebs.System.csproj (in 695 ms).
Restored C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\Empower.Configuration.csproj (in 695 ms).
Restored C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.WebServices\Smartwebs.WebServices.csproj (in 696 ms).
Restored C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.Web\Smartwebs.Web.csproj (in 695 ms).
3>------ Rebuild All started: Project: Empower.Common, Configuration: Debug Any CPU ------
Assets file has not changed. Skipping assets file writing. Path: C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\obj\project.assets.json
Failed to restore C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\Empower.Common.csproj (in 887 ms).
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
3>Build started 11/2/2022 10:28:08 AM.
3>Target Clean:
3>  Target CoreClean:
...
3>  Target _SplitProjectReferencesByFileExistence:
3>  Target _GetProjectReferenceTargetFrameworkProperties:
3>    Target CoreClean:
...
3>    Target ResolvePackageAssets:
3>      Target _GetProjectReferenceTargetFrameworkProperties:
3>        Target GetTargetFrameworksWithPlatformFromInnerBuilds:
3>Target DispatchToInnerBuilds:
3>  Target PrepareForBuild:
3>    Target ResolveProjectReferences:
3>      Target GetTargetPathWithTargetPlatformMoniker:
3>        Target GetTargetPathWithTargetPlatformMoniker:
3>      Target GetNativeManifest:
3>    Target FindReferenceAssembliesForReferences:
3>      Processing resource file "Properties\Resources.resx" into "obj\Debug\net48\Empower.Common.Properties.Resources.resources".
3>    Target GenerateTargetFrameworkMonikerAttribute:
3>      Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
3>    Processing resource file "Properties\Resources.resx" into "obj\Debug\net6.0-windows\Empower.Common.Properties.Resources.resources".
3>    Target GenerateTargetFrameworkMonikerAttribute:
3>      Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
3>    Target CoreGenerateAssemblyInfo:
3>      Could not infer the type of parameter "#1" because the attribute type is unknown. The value will be treated as a string.
3>      Could not infer the type of parameter "#1" because the attribute type is unknown. The value will be treated as a string.
3>    Target CoreCompile:
3>      CompilerServer: server - server processed compilation - 6bdaa139-0c43-46e6-8f0f-8e3f5797b66c
3>    Target _CopyFilesMarkedCopyLocal:
...
3>      CompilerServer: server - server processed compilation - 9ec49c5e-e568-495c-b4f0-7428ea80de82
3>    Target _CopyFilesMarkedCopyLocal:
...
3>      Creating "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\obj\Debug\net6.0-windows\Empower.Common.csproj.CopyComplete" because "AlwaysCreate" was specified.
3>    Target GetCopyToOutputDirectoryItems:
3>      Target _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences:
3>        Copying file from "C:\Users\kabua\.nuget\packages\system.servicemodel.syndication\6.0.0\lib\net461\System.ServiceModel.Syndication.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\System.ServiceModel.Syndication.dll".
3>        Copying file from "C:\Users\kabua\.nuget\packages\system.serviceprocess.servicecontroller\6.0.0\lib\net461\System.ServiceProcess.ServiceController.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\System.ServiceProcess.ServiceController.dll".
3>        Target _NormalizeTargetPlatformVersion:
3>          Target ApplyImplicitVersions:
3>            Copying file from "C:\Users\kabua\.nuget\packages\system.text.encoding.codepages\6.0.0\lib\net461\System.Text.Encoding.CodePages.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\System.Text.Encoding.CodePages.dll".
3>          Target ProcessFrameworkReferences:
3>            Copying file from "C:\Users\kabua\.nuget\packages\system.threading.accesscontrol\6.0.0\lib\net461\System.Threading.AccessControl.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\System.Threading.AccessControl.dll".
3>          Target ResolvePackageAssets:
3>            Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\net461\System.Web.Services.Description.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\System.Web.Services.Description.dll".
3>            Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\cs\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\cs\System.Web.Services.Description.resources.dll".
3>        Target _AddOutputPathToGlobalPropertiesToRemove:
3>          Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\de\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\de\System.Web.Services.Description.resources.dll".
3>        Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\es\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\es\System.Web.Services.Description.resources.dll".
3>        Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\fr\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\fr\System.Web.Services.Description.resources.dll".
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\it\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\it\System.Web.Services.Description.resources.dll".
3>    Target _CopyOutOfDateSourceItemsToOutputDirectory:
3>      Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\Empower.Configuration.UpdateDatabase.json" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net6.0-windows\Empower.Configuration.UpdateDatabase.json".
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\ja\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\ja\System.Web.Services.Description.resources.dll".
3>    Target _CheckForCompileOutputs:
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\ko\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\ko\System.Web.Services.Description.resources.dll".
3>    Target GenerateBuildDependencyFile:
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\pl\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\pl\System.Web.Services.Description.resources.dll".
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\pt-BR\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\pt-BR\System.Web.Services.Description.resources.dll".
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\ru\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\ru\System.Web.Services.Description.resources.dll".
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\tr\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\tr\System.Web.Services.Description.resources.dll".
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\zh-Hans\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\zh-Hans\System.Web.Services.Description.resources.dll".
3>      Copying file from "C:\Users\kabua\.nuget\packages\system.web.services.description\4.9.0\lib\netstandard2.0\zh-Hant\System.Web.Services.Description.resources.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\zh-Hant\System.Web.Services.Description.resources.dll".
3>      Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\bin\Debug\net48\Empower.Configuration.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Configuration.dll".
3>      Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.System\bin\Debug\net48\Smartwebs.System.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Smartwebs.System.dll".
3>      Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\bin\Debug\net48\Empower.Configuration.xml" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Configuration.xml".
3>      Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\bin\Debug\net48\Empower.Configuration.dll.config" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Configuration.dll.config".
3>      Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Smartwebs\Smartwebs.System\bin\Debug\net48\Smartwebs.System.xml" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Smartwebs.System.xml".
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018: System.ArgumentException: An item with the same key has already been added.
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.DependencyContextBuilder..ctor(SingleProjectInfo mainProjectInfo, Boolean includeRuntimeFileVersions, RuntimeGraph runtimeGraph, ProjectContext projectContext)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute()
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
3>      C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
3>    Done building target "GenerateBuildDependencyFile" in project "Empower.Common.csproj" -- FAILED.
3>
3>    Done building project "Empower.Common.csproj" -- FAILED.
3>    Creating "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\obj\Debug\net48\Empower.Common.csproj.CopyComplete" because "AlwaysCreate" was specified.
3>  Target GetCopyToOutputDirectoryItems:
3>    Target _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences:
3>  Target _CopyOutOfDateSourceItemsToOutputDirectory:
3>    Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower.Configuration\Empower.Configuration\Empower.Configuration.UpdateDatabase.json" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Configuration.UpdateDatabase.json".
3>  Target CopyFilesToOutputDirectory:
3>    Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\obj\Debug\net48\Empower.Common.dll" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Common.dll".
3>    Empower.Common -> C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Common.dll
3>    Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\obj\Debug\net48\Empower.Common.pdb" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Common.pdb".
3>    Copying file from "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\obj\Debug\net48\Empower.Common.xml" to "C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\bin\Debug\net48\Empower.Common.xml".
3>
3>Build FAILED.
3>
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018: System.ArgumentException: An item with the same key has already been added.
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.DependencyContextBuilder..ctor(SingleProjectInfo mainProjectInfo, Boolean includeRuntimeFileVersions, RuntimeGraph runtimeGraph, ProjectContext projectContext)
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute()
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
3>C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
3>    0 Warning(s)
3>    1 Error(s)
3>
3>Time Elapsed 00:00:01.02
========== Rebuild All: 0 succeeded, 1 failed, 2 skipped ==========
kabua commented 1 year ago

One point of interest. In the newer versions of VS 2022, we have noticed that if a project contains a ProjectReference element, then the solution must include that project as well. Therefore, we have had to add all the projects from both the Empower.Configuration framework and the Smartwebs framework to the Empower framework solution.

We are guessing, to fix this issue, we may have to add the conditional ProjectReference logic to the Empower.Configuration project as well.

But the real frustration is that the errors are complaining, not that we are referencing the same project both as a ProjectReference and as a PackageReference but that nuget can't resolve the 3rd party packages that this project references.

IOWs, Smartwebs.System is referencing several 3rd party packages; it's these packages that nuget is failing to resolve correctly. Thus we have 410 errors which all look like this:

NU1106  Unable to satisfy conflicting requests for 'Microsoft.Windows.Compatibility': 
Microsoft.Windows.Compatibility (>= 6.0.0) (via project/Empower.Configuration 10.0.0-a003-Debug), 
Microsoft.Windows.Compatibility (>= 6.0.0) (via project/Smartwebs.System 10.0.0-a005-Debug) 
Framework: (.NETFramework,Version=v4.8)
Empower.Common  C:\Sw\V9\EmpowerCore\Src\Frameworks\Empower\Empower.Common\Empower.Common.csproj    1   

Notice, from the csproj files stated above, that both frameworks are referencing exactly the same package: Microsoft.Windows.Compatibility.6.0.0 and this is true for all the other reference packages.

kabua commented 1 year ago

Yep.

Changing the Empower.Configuration.csproj from:

  <ItemGroup>
    <PackageReference Include="Smartwebs.System" Version="10.0.0-a005-Debug" />
  </ItemGroup>

to:

  <ItemGroup Condition="'$(Configuration)'=='Release' or '$(swPack)'=='1'">
    <PackageReference Include="Smartwebs.System" Version="10.0.0-a005-Debug" />
  </ItemGroup>
  <ItemGroup Condition="'$(Configuration)'!='Release' and '$(swPack)'!='1'">
    <ProjectReference Include="..\..\Smartwebs\Smartwebs.System\Smartwebs.System.csproj" />
  </ItemGroup>

Solved this issue for this one project but we are still seeing NU1106 Unable to satisfy conflicting requests in other projects.

kartheekp-ms commented 1 year ago

Thank for the detailed issue description. May be a duplicate of https://github.com/dotnet/sdk/issues/12473 one and the root cause mentioned here appears to be same as https://github.com/dotnet/sdk/issues/12473#issuecomment-669515050.

How about publishing symbol packages (.snupkg) https://learn.microsoft.com/nuget/create-packages/symbol-packages-snupkg?

Will the restore succeed if we delete obj\* (mainly project.assets.json) files for all projects after changing the configuration from debug to release or vice versa?

zivkan commented 1 year ago

@kabua slightly orthogonal, but when a project is packed, all ProjectReferences get converted into dependencies, just as PackageReferences do. Is there some other reason you're switching between package & project references? Many customers I've helped didn't know about this, and were able to simplify their project file, removing the conditions and always using the project references.

Also for what it's worth, we have documented: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#adding-a-packagereference-condition

You can use a condition to control whether a package is included, where conditions can use any MSBuild variable or a variable defined in the targets or props file. However, at presently, only the TargetFramework variable is supported.

However, that's no excuse for restore to crash with a stack trace. Error scenarios should be reported with an NU* code and a clean exit.

kabua commented 1 year ago

@kartheekp-ms We are using the new symbol packages. I haven't tried deleting obj\* between debug and release, I will see if I can try that sometime next week.

@zivkan

when a project is packed, all ProjectReferences get converted into dependencies, just as PackageReferences do

Oh my! I did not know that. Thanks for the heads-up, I will try it out.

ghost commented 1 year ago

This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment.

kabua commented 1 year ago

Currently working on implementing these ideas into our code.

jeffkl commented 1 year ago

Team Triage: Closing for now, let us know if this needs to be reopened if the suggested solutions don't work.

faburaya commented 1 year ago

I have now this issue taking place in a build of Azure DevOps: https://dev.azure.com/faburaya/Reusable.NET/_build/results?buildId=116&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=86dd5fa6-f51e-57a1-6dd4-575fd75fc7ef

gabriel-vanca commented 1 week ago

Having this issue too.