Skip to content

Microsoft.CodeAnalysis.Workspaces.MSBuild package causes RAR unification warnings for a .NET Framework consumer #76942

Open
@baronfel

Description

@baronfel

Version Used: 4.12.0

Steps to Reproduce:

Given a project of the form

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net48</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis" Version="4.12.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0" />
  </ItemGroup>

</Project>
  1. Run dotnet build -bl
  2. Observe that a large, gross assembly unification error from ResolveAssemblyReferences is written:
Very long MSBuild error spew
dotnet build -bl
Restore succeeded with 1 warning(s) in 0.2s
    E:\Code\Scratch\freds-msbuildworkspace-issue\thing.csproj : warning NU1903: Package 'System.Text.Json' 8.0.4 has a known high severity vulnerability, https://github.com/advisories/GHSA-8g4q-xg66-9fp4
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  thing failed with 1 error(s) and 3 warning(s) (0.8s)
    E:\Code\Scratch\freds-msbuildworkspace-issue\thing.csproj : warning NU1903: Package 'System.Text.Json' 8.0.4 has a known high severity vulnerability, https://github.com/advisories/GHSA-8g4q-xg66-9fp4
    C:\Program Files\dotnet\sdk\9.0.200-preview.0.24575.35\Microsoft.Common.CurrentVersion.targets(2413,5): warning MSB3277:
      Found conflicts between different versions of "System.Memory" that could not be resolved.
      There was a conflict between "System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "System.Memory, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b
      13ffcd2ddd51".
          "System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "System.Memory, Version=6.0.0.0, Culture=neutral, PublicKeyT
      oken=cc7b13ffcd2ddd51" was not.
          References which depend on "System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [E:\code\nuget-packages\system.memory\4.5.5\lib\net461\System.Memory.dl
      l].
              E:\code\nuget-packages\system.memory\4.5.5\lib\net461\System.Memory.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.memory\4.5.5\lib\net461\System.Memory.dll".
                  E:\code\nuget-packages\system.memory\4.5.5\lib\net461\System.Memory.dll
          References which depend on or have been unified to "System.Memory, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [].
              E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll".
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.build.framework\17.10.4\ref\net472\Microsoft.Build.Framework.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.build.framework\17.10.4\ref\net472\Microsoft.Build.Framework.dll".
                  E:\code\nuget-packages\microsoft.build.framework\17.10.4\ref\net472\Microsoft.Build.Framework.dll
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.build.tasks.core\17.10.4\ref\net472\Microsoft.Build.Tasks.Core.dll
                  E:\code\nuget-packages\microsoft.build.utilities.core\17.10.4\ref\net472\Microsoft.Build.Utilities.Core.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.build.tasks.core\17.10.4\ref\net472\Microsoft.Build.Tasks.Core.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.build.tasks.core\17.10.4\ref\net472\Microsoft.Build.Tasks.Core.dll".
                  E:\code\nuget-packages\microsoft.build.tasks.core\17.10.4\ref\net472\Microsoft.Build.Tasks.Core.dll
              E:\code\nuget-packages\microsoft.build.utilities.core\17.10.4\ref\net472\Microsoft.Build.Utilities.Core.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.build.utilities.core\17.10.4\ref\net472\Microsoft.Build.Utilities.Core.dll".
                  E:\code\nuget-packages\microsoft.build.utilities.core\17.10.4\ref\net472\Microsoft.Build.Utilities.Core.dll
                  E:\code\nuget-packages\microsoft.build.tasks.core\17.10.4\ref\net472\Microsoft.Build.Tasks.Core.dll
              E:\code\nuget-packages\microsoft.codeanalysis.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.codeanalysis.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll".
                  E:\code\nuget-packages\microsoft.codeanalysis.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.codeanalysis.csharp\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.codeanalysis.csharp\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll".
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
              E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Work
      spaces.dll".
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
              E:\code\nuget-packages\microsoft.codeanalysis.visualbasic\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.codeanalysis.visualbasic\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll".
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
              E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.
      dll".
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild
      .dll".
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.extensions.logging\8.0.0\lib\net462\Microsoft.Extensions.Logging.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.extensions.logging\8.0.0\lib\net462\Microsoft.Extensions.Logging.dll".
                  E:\code\nuget-packages\microsoft.extensions.logging\8.0.0\lib\net462\Microsoft.Extensions.Logging.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.extensions.logging.abstractions\8.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.extensions.logging.abstractions\8.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.
      dll".
                  E:\code\nuget-packages\microsoft.extensions.logging.abstractions\8.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
                  E:\code\nuget-packages\microsoft.extensions.logging\8.0.0\lib\net462\Microsoft.Extensions.Logging.dll
              E:\code\nuget-packages\microsoft.extensions.primitives\8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.extensions.primitives\8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll".
                  E:\code\nuget-packages\microsoft.extensions.primitives\8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll
                  E:\code\nuget-packages\microsoft.extensions.options\8.0.0\lib\net462\Microsoft.Extensions.Options.dll
                  E:\code\nuget-packages\microsoft.extensions.logging\8.0.0\lib\net462\Microsoft.Extensions.Logging.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.io.redist\6.0.1\lib\net472\Microsoft.IO.Redist.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.io.redist\6.0.1\lib\net472\Microsoft.IO.Redist.dll".
                  E:\code\nuget-packages\microsoft.io.redist\6.0.1\lib\net472\Microsoft.IO.Redist.dll
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.build.tasks.core\17.10.4\ref\net472\Microsoft.Build.Tasks.Core.dll
                  E:\code\nuget-packages\microsoft.build.utilities.core\17.10.4\ref\net472\Microsoft.Build.Utilities.Core.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\microsoft.net.stringtools\17.10.4\ref\net472\Microsoft.NET.StringTools.dll
                Project file item includes which caused reference "E:\code\nuget-packages\microsoft.net.stringtools\17.10.4\ref\net472\Microsoft.NET.StringTools.dll".
                  E:\code\nuget-packages\microsoft.net.stringtools\17.10.4\ref\net472\Microsoft.NET.StringTools.dll
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\system.collections.immutable\8.0.0\lib\net462\System.Collections.Immutable.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.collections.immutable\8.0.0\lib\net462\System.Collections.Immutable.dll".
                  E:\code\nuget-packages\system.collections.immutable\8.0.0\lib\net462\System.Collections.Immutable.dll
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.build.framework\17.10.4\ref\net472\Microsoft.Build.Framework.dll
                  E:\code\nuget-packages\microsoft.build.tasks.core\17.10.4\ref\net472\Microsoft.Build.Tasks.Core.dll
                  E:\code\nuget-packages\microsoft.build.utilities.core\17.10.4\ref\net472\Microsoft.Build.Utilities.Core.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
                  E:\code\nuget-packages\system.reflection.metadata\8.0.0\lib\net462\System.Reflection.Metadata.dll
                  E:\code\nuget-packages\system.reflection.metadataloadcontext\8.0.0\lib\net462\System.Reflection.MetadataLoadContext.dll
              E:\code\nuget-packages\system.diagnostics.diagnosticsource\8.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.diagnostics.diagnosticsource\8.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll".
                  E:\code\nuget-packages\system.diagnostics.diagnosticsource\8.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll
                  E:\code\nuget-packages\microsoft.extensions.logging\8.0.0\lib\net462\Microsoft.Extensions.Logging.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\system.io.pipelines\8.0.0\lib\net462\System.IO.Pipelines.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.io.pipelines\8.0.0\lib\net462\System.IO.Pipelines.dll".
                  E:\code\nuget-packages\system.io.pipelines\8.0.0\lib\net462\System.IO.Pipelines.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\system.reflection.metadata\8.0.0\lib\net462\System.Reflection.Metadata.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.reflection.metadata\8.0.0\lib\net462\System.Reflection.Metadata.dll".
                  E:\code\nuget-packages\system.reflection.metadata\8.0.0\lib\net462\System.Reflection.Metadata.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
                  E:\code\nuget-packages\system.reflection.metadataloadcontext\8.0.0\lib\net462\System.Reflection.MetadataLoadContext.dll
              E:\code\nuget-packages\system.reflection.metadataloadcontext\8.0.0\lib\net462\System.Reflection.MetadataLoadContext.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.reflection.metadataloadcontext\8.0.0\lib\net462\System.Reflection.MetadataLoadContext.dll".
                  E:\code\nuget-packages\system.reflection.metadataloadcontext\8.0.0\lib\net462\System.Reflection.MetadataLoadContext.dll
              E:\code\nuget-packages\system.resources.extensions\8.0.0\lib\net462\System.Resources.Extensions.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.resources.extensions\8.0.0\lib\net462\System.Resources.Extensions.dll".
                  E:\code\nuget-packages\system.resources.extensions\8.0.0\lib\net462\System.Resources.Extensions.dll
              E:\code\nuget-packages\system.text.encoding.codepages\7.0.0\lib\net462\System.Text.Encoding.CodePages.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.text.encoding.codepages\7.0.0\lib\net462\System.Text.Encoding.CodePages.dll".
                  E:\code\nuget-packages\system.text.encoding.codepages\7.0.0\lib\net462\System.Text.Encoding.CodePages.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.csharp.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.visualbasic.workspaces\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.common\4.12.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\system.text.encodings.web\8.0.0\lib\net462\System.Text.Encodings.Web.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.text.encodings.web\8.0.0\lib\net462\System.Text.Encodings.Web.dll".
                  E:\code\nuget-packages\system.text.encodings.web\8.0.0\lib\net462\System.Text.Encodings.Web.dll
                  E:\code\nuget-packages\system.text.json\8.0.4\lib\net462\System.Text.Json.dll
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
              E:\code\nuget-packages\system.text.json\8.0.4\lib\net462\System.Text.Json.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.text.json\8.0.4\lib\net462\System.Text.Json.dll".
                  E:\code\nuget-packages\system.text.json\8.0.4\lib\net462\System.Text.Json.dll
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
    C:\Program Files\dotnet\sdk\9.0.200-preview.0.24575.35\Microsoft.Common.CurrentVersion.targets(2413,5): warning MSB3277:
      Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved.
      There was a conflict between "System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Numerics.Vectors, Version=6.0.0.0, Culture=neutral,
       PublicKeyToken=b03f5f7f11d50a3a".
          "System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Numerics.Vectors, Version=6.0.0.0, Culture
      =neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
          References which depend on "System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [E:\code\nuget-packages\system.numerics.vectors\4.5.0\ref\net
      46\System.Numerics.Vectors.dll].
              E:\code\nuget-packages\system.numerics.vectors\4.5.0\ref\net46\System.Numerics.Vectors.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.numerics.vectors\4.5.0\ref\net46\System.Numerics.Vectors.dll".
                  E:\code\nuget-packages\system.numerics.vectors\4.5.0\ref\net46\System.Numerics.Vectors.dll
          References which depend on or have been unified to "System.Numerics.Vectors, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
              E:\code\nuget-packages\system.memory\4.5.5\lib\net461\System.Memory.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.memory\4.5.5\lib\net461\System.Memory.dll".
                  E:\code\nuget-packages\system.memory\4.5.5\lib\net461\System.Memory.dll
              E:\code\nuget-packages\system.text.json\8.0.4\lib\net462\System.Text.Json.dll
                Project file item includes which caused reference "E:\code\nuget-packages\system.text.json\8.0.4\lib\net462\System.Text.Json.dll".
                  E:\code\nuget-packages\system.text.json\8.0.4\lib\net462\System.Text.Json.dll
                  E:\code\nuget-packages\microsoft.build\17.10.4\ref\net472\Microsoft.Build.dll
                  E:\code\nuget-packages\microsoft.codeanalysis.workspaces.msbuild\4.12.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll

Expected Behavior:

The library shouldn't impact RAR for consuming projects.

Actual Behavior:

The library bundles a .NET (Fx and Core) application into the user's project output via Content due to the use of the NuGet contentFiles mechanism. This application's dependencies include .NET Core-versioned copies of System.Memory and System.Numberics.Vectors. The ResolveAssemblyReferences Task takes in MSBuild Content and None items as values of its CandidateAssemblyFiles logic, and because of the ordering of the files in the package, the .NET Core versions of the assemblies are considered as candidates.

Note

This does not impact the dependencies used by the user for their application at runtime, it just produces an MSBuild warning.

There is no built-in way to remove Content files from consideration for RAR, so this will need to be solved another way.

I've attached a zipped binlog with my diagnosis:

rar-for-roslyn-workspace.zip

Prospective fix

I think the contentFiles mechanism is mostly being used to ensure that the binaries end up in the user's project output? If that is the case, then we can look at other ways of doing that same thing that do not rely on Content.

The cleanest way I can think of is to use the BuildAction capability of nuget packages to have NuGet actually assign the files from the package to a different MSBuild Item than Content. If you set BuildAction to ResolvedFileToPublish, you should just automatically work for publishing purposes, for example. There are probably a number of ways to get there that we could help figure out. The main thing would be to remove these files from Content.

This option would involve setting the BuildAction metadata to ResolvedFileToPublish for every piece of Content that is in the package today.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions