Skip to content

Composite ReadyToRun fails when RelativePath has a path component #79902

@rolfbjarne

Description

@rolfbjarne

Description

As title says.

Reproduction Steps

Zipped repro: readytorun-f020a25.zip

But it's very simple, here's the csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <PublishReadyToRun>true</PublishReadyToRun>
    <PublishReadyToRunComposite>true</PublishReadyToRunComposite>
    <RuntimeIdentifier>osx-x64</RuntimeIdentifier>
  </PropertyGroup>
  <Target Name="PublishAssembliesToSubdirectory" BeforeTargets="CreateReadyToRunImages" AfterTargets="ComputeResolvedFilesToPublishList">
    <ItemGroup>
      <ResolvedFileToPublish Update="@(ResolvedFileToPublish)" RelativePath="subdir/%(RelativePath)" Condition="'%(Extension)' == '.dll'" />
    </ItemGroup>
  </Target>
</Project>

and the C# file:

System.Console.WriteLine("Hello, World!");

Then publish:

$ dotnet publish /bl

Expected behavior

Successful build/publish.

Actual behavior

Many errors like:

error MSB3030: Could not copy the file "obj/Debug/net7.0/osx-x64/R2R/subdir/readytorun.dll" because it was not found.

$ dotnet publish /bl
MSBuild version 17.4.0+18d5aef85 for .NET
/usr/local/share/dotnet/sdk/7.0.102/MSBuild.dll --property:_IsPublishing=true -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/7.0.102/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/7.0.102/dotnet.dll -maxcpucount -restore -target:Publish -verbosity:m /bl ./readytorun.csproj
  Determining projects to restore...
  Restored /Users/rolf/test/readytorun/readytorun.csproj (in 121 ms).
  readytorun -> /Users/rolf/test/readytorun/bin/Debug/net7.0/osx-x64/readytorun.dll
/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(254,5): error MSB3030: Could not copy the file "obj/Debug/net7.0/osx-x64/R2R/subdir/readytorun.dll" because it was not found. [/Users/rolf/test/readytorun/readytorun.csproj]
/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(254,5): error MSB3030: Could not copy the file "obj/Debug/net7.0/osx-x64/R2R/subdir/Microsoft.VisualBasic.dll" because it was not found. [/Users/rolf/test/readytorun/readytorun.csproj]
/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(254,5): error MSB3030: Could not copy the file "obj/Debug/net7.0/osx-x64/R2R/subdir/Microsoft.CSharp.dll" because it was not found. [/Users/rolf/test/readytorun/readytorun.csproj]
[...]
/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(254,5): error MSB3030: Could not copy the file "obj/Debug/net7.0/osx-x64/R2R/subdir/WindowsBase.dll" because it was not found. [/Users/rolf/test/readytorun/readytorun.csproj]
/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(254,5): error MSB3030: Could not copy the file "obj/Debug/net7.0/osx-x64/R2R/subdir/netstandard.dll" because it was not found. [/Users/rolf/test/readytorun/readytorun.csproj]
/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(254,5): error MSB3030: Could not copy the file "obj/Debug/net7.0/osx-x64/R2R/subdir/mscorlib.dll" because it was not found. [/Users/rolf/test/readytorun/readytorun.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

$ dotnet --info
.NET SDK:
 Version:   7.0.102
 Commit:    3c4322d8e5

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.6
 OS Platform: Darwin
 RID:         osx.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.102/

Host:
  Version:      7.0.0
  Architecture: x64
  Commit:       d099f075e4

.NET SDKs installed:
  6.0.403 [/usr/local/share/dotnet/sdk]
  6.0.404 [/usr/local/share/dotnet/sdk]
  7.0.100 [/usr/local/share/dotnet/sdk]
  7.0.101 [/usr/local/share/dotnet/sdk]
  7.0.102 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Other information

When building for the net7.0-macos TFM, we're creating an app bundle, in which case we need to publish assemblies into a directory inside the app bundle, which is why we're adding a (relative) directory component to the RelativePath metadata.

Ref: dotnet/macios#13873

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions