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

Composite ReadyToRun fails when RelativePath has a path component #79902

Closed
rolfbjarne opened this issue Dec 22, 2022 · 9 comments
Closed

Composite ReadyToRun fails when RelativePath has a path component #79902

rolfbjarne opened this issue Dec 22, 2022 · 9 comments
Assignees
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented Dec 22, 2022

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: xamarin/xamarin-macios#13873

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 22, 2022
@rolfbjarne
Copy link
Member Author

@agocke are you the person to ask about how to get this prioritized and fixed?

@agocke
Copy link
Member

agocke commented Mar 23, 2023

@mangod9 is probably the right person for this

@mangod9
Copy link
Member

mangod9 commented Mar 23, 2023

@trylek @ivdiazsa as fyi.

@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label Mar 23, 2023
@mangod9 mangod9 added this to the 8.0.0 milestone Mar 23, 2023
@trylek
Copy link
Member

trylek commented Mar 23, 2023

This looks like an SDK bug, /cc @marcpopMSFT for visibility. I might be able to fix this but I'm not all that familiar with the overall scripting so a more knowledgeable expert would be useful to make sure we're making meaningful fixes here. In particular, it somewhat looks like you're relying on internal behavior of the SDK build scripts and I suspect that is generally unsupported; having said that I'm certainly all for fixing erroneous or unusable behavior.

@marcpopMSFT
Copy link
Member

Add @dsplaisted to see if there's a way to maybe override the intermediate location that those files are going to. You're basically telling it to copy from a folder that's not where the files are built to. This isn't a bug but more of tips on managing msbuild logic.

@ivdiazsa
Copy link
Contributor

ivdiazsa commented Mar 23, 2023

I tried overriding the R2R output path in an additional Target prior to generating the R2R images (i.e. with a BeforeTargets), but to no avail. Still got the errors.

@trylek trylek mentioned this issue May 3, 2023
46 tasks
@ivdiazsa
Copy link
Contributor

Should we pass this on to the SDK folks considering the potential bug lies there?

@mangod9
Copy link
Member

mangod9 commented Aug 4, 2023

yeah probably something on the SDK side, assume this is not high priority for 8?

@mangod9 mangod9 modified the milestones: 8.0.0, 9.0.0 Aug 4, 2023
@rolfbjarne
Copy link
Member Author

Add @dsplaisted to see if there's a way to maybe override the intermediate location that those files are going to. You're basically telling it to copy from a folder that's not where the files are built to. This isn't a bug but more of tips on managing msbuild logic.

Not sure I understand this comment. I'm trying to put/publish the assemblies into a subdirectory of the publish directory. I don't care where the files are in the mean time (the intermediate location).

So if the publish directory is "bin/Debug/publish", I need the build to put all the assemblies into "bin/Debug/publish/subdir"

Thus I'm updating RelativePath to contain the "subdir" part, and ReadyToRun doesn't like that.

yeah probably something on the SDK side, assume this is not high priority for 8?

While not entirely blocking (we could implement some ugly MSBuild logic that works around what's not working for ReadyToRun), I'd really like to avoid that (the other alternative is to not ship support for ReadyToRun for our scenario).

@github-actions github-actions bot locked and limited conversation to collaborators Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants