Skip to content
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

Duplicate items in _ResolvedCopyLocalPublishAssets #3007

Closed
sbomer opened this Issue Mar 4, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@sbomer
Copy link
Member

sbomer commented Mar 4, 2019

  • When ResolveCopyLocalAssets runs during self-contained publish (_UseBuildDependencyFile is false), it outputs _ResolvedCopyLocalPublishAssets.
  • When _ComputeResolvedCopyLocalPublishAssets runs, it adds to _ResolvedCopyLocalPublishAssets the contents of (ReferenceCopyLocalPaths \ _ResolvedCopyLocalBuildAssets):
    <_ResolvedCopyLocalPublishAssets Include="@(ReferenceCopyLocalPaths)"
    Exclude="@(_ResolvedCopyLocalBuildAssets)"

_ResolvedCopyLocalBuildAssets is empty, so it gets a duplicate copy of items in ReferenceCopyLocalPaths (which comes from RuntimePackAsset), for example System.Private.CoreLib.dll.

Before #2646, ResolvedAssembliesToPublish only had one Item for System.Private.CoreLib.dll. I noticed this while trying to update https://github.com/mono/linker/blob/master/src/ILLink.Tasks/ILLink.Tasks.targets#L451 to work with the newest SDK. _ManagedAssembliesToLink was computed from ResolvedAssembliesToPublish, but that line breaks when there are multiple files with the same Filename in the input:

C:\Users\svbomer\.nuget\packages\illink.tasks\0.1.6\build\ILLink.Tasks.targets(451,34): error MSB4094: "C:\Users\svbomer\.nuget\packages\runtime.win-x64.microsoft.netcore.app\3.0.0-preview-27324-5\runtimes\win-x64\native\System.Private.CoreLib.dll;C:\Users\svbomer\.nuget\packages\runtime.win-x64.microsoft.netcore.app\3.0.0-preview-27324-5\runtimes\win-x64\native\System.Private.CoreLib.dll" is an invalid value for the "AssemblyPath" parameter of the "CheckEmbeddedRootDescriptor" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem". [D:\linker\test\ILLink.Tasks.Tests\bin\debug\netcoreapp3.0\helloworld\helloworld.csproj]

#2666 may be relevant.

/cc @peterhuene @nguerrera

@peterhuene peterhuene self-assigned this Mar 5, 2019

@peterhuene peterhuene added this to the 3.0.1xx milestone Mar 5, 2019

sbomer added a commit to sbomer/linker that referenced this issue Mar 5, 2019

sbomer added a commit to sbomer/linker that referenced this issue Mar 8, 2019

@peterhuene

This comment has been minimized.

Copy link
Member

peterhuene commented Mar 8, 2019

The simple fix would be to just filter out RuntimePackAsset when adding items from ReferenceCopyLocalPaths.

Unfortunately it also seems that the runtime pack changes also introduced package references that are publish=false by default (i.e. the implicitly defined packages that are from the runtime packs which have their assets available in the RuntimePackAsset items).

As the set of packages now differs from the build, this causes the publish targets to fallback to resolving (non-platform) assets and generating a different deps file, which you can see just by diffing the deps file from build vs. publish; the former has entries for the packages excluded from publish and the latter does not.

This logic is getting difficult to reason because data is coming from many different places into the _ResolvedCopyLocalPublishAssets items. I'm working on a better solution than simply filtering out RuntimePackAsset from ReferenceCopyLocalPaths when adding to _ResolvedCopyLocalPublishAssets.

marek-safar added a commit to mono/linker that referenced this issue Mar 8, 2019

Build and link using 3.0 SDK (#478)
* Use 3.0 preview SDK to build illink

* Respond to SDK changes in conflict resolution targets

* Respond to SDK changes to publish assembly resolution

* Work around duplicate items introduced by an sdk change

See dotnet/sdk#3007

* Remove dependency on GetRuntimeLibraries

Instead, use RuntimePackAssets resolved by the SDK

peterhuene added a commit to peterhuene/sdk that referenced this issue Mar 14, 2019

Remove duplicates items from resolved publish assets.
When `CopyLocalLockFileAssemblies` was true, `ReferenceCopyLocalPaths`
contained the set of `RuntimePackAsset` items.

When resolving assets to copy local for publish, the `RuntimePackAsset` items
were added twice: once explicitly and again via `ReferenceCopyLocalPaths`.

This commit fixes this by only adding to the resolved copy local assets for
publish when `CopyLocalLockFileAssemblies` is false.

Fixes dotnet#3007.

peterhuene added a commit to peterhuene/sdk that referenced this issue Mar 14, 2019

Remove duplicates items from resolved publish assets.
When `CopyLocalLockFileAssemblies` was true, `ReferenceCopyLocalPaths`
contained the set of `RuntimePackAsset` items.

When resolving assets to copy local for publish, the `RuntimePackAsset` items
were added twice: once explicitly and again via `ReferenceCopyLocalPaths`.

This commit fixes this by only adding to the resolved copy local assets for
publish when `CopyLocalLockFileAssemblies` is false.

Fixes dotnet#3007.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.