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

Roslyn has introduced many source-built prebuilts #69847

Closed
mthalman opened this issue Sep 7, 2023 · 12 comments · Fixed by #69854
Closed

Roslyn has introduced many source-built prebuilts #69847

mthalman opened this issue Sep 7, 2023 · 12 comments · Fixed by #69854
Assignees
Labels
Milestone

Comments

@mthalman
Copy link
Member

mthalman commented Sep 7, 2023

The following source-build prebuilts have been introduced by Roslyn in the dependency flow into installer: dotnet/installer#17319:

/vmr/repo-projects/Directory.Build.targets(688,5): warning : MessagePack.2.5.108 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : MessagePack.Annotations.2.5.108 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.AspNetCore.App.Runtime.osx-arm64.8.0.0-rc.1.23401.1 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.AspNetCore.App.Runtime.osx-x64.8.0.0-rc.1.23401.1 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.AspNetCore.App.Runtime.win-arm64.8.0.0-rc.1.23401.1 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.AspNetCore.App.Runtime.win-x64.8.0.0-rc.1.23401.1 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.AspNetCore.App.Runtime.win-x86.8.0.0-rc.1.23401.1 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.Build.Locator.1.6.1 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Host.osx-arm64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Host.osx-x64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Host.win-arm64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Host.win-x64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Host.win-x86.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Runtime.osx-arm64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Runtime.osx-x64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Runtime.win-arm64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Runtime.win-x64.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.NETCore.App.Runtime.win-x86.8.0.0-rc.1.23381.3 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.VisualStudio.Threading.17.6.40 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.VisualStudio.Threading.Analyzers.17.6.40 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Microsoft.VisualStudio.Validation.17.6.11 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : Nerdbank.Streams.2.10.66 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : runtime.placeholder-rid.System.Collections.4.0.11 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : runtime.placeholder-rid.System.Globalization.4.0.11 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : runtime.placeholder-rid.System.IO.4.1.0 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : runtime.placeholder-rid.System.Reflection.4.1.0 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : runtime.placeholder-rid.System.Reflection.Primitives.4.0.1 [/vmr/repo-projects/dotnet.proj]
/vmr/repo-projects/Directory.Build.targets(688,5): warning : runtime.placeholder-rid.System.Resources.ResourceManager.4.0.1 [/vmr/repo-projects/dotnet.proj]

These stem from the following packages:

These prebuilts were not caught by roslyn CI because of #69846.

Here is the attached prebuilt report for more details:
prebuilt-usage.zip

One of the more concerning of these prebuilts is the dependency on StreamJsonRpc. This is produced outside of .NET and would need to be included in source-build-externals.

One thing we need to determine first is whether Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost needs to be source-built at all. We need to understand its purpose and whether its relevant to a source-built SDK. @jasonmalinowski - Can you provide more info here?

cc @MichaelSimons

@jasonmalinowski
Copy link
Member

Background first: Microsoft.CodeAnalysis.Workspaces.MSBuild is a Roslyn package which a tool author can use to take a solution/projects on disk and load them into Roslyn so you can look at the syntax trees, semantics, etc. For example, dotnet format uses it to load the syntax trees to then start formatting them. One consistent problem we've had with MSBuildWorkspace is since it's using MSBuild in-process, it can only support projects that match your runtime type and/or version; for example a tool compiled against .NET Framework may choke on .NET Core projects and vice-versa. Because of needs for the C# extension we're generally enhancing it so it can launch a separate process (the BuildHost binary) and do out-of-proc builds and then pass the stuff back in process.

Now a few questions I have:

the following packages...Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost

@mthalman: There shouldn't be a BuildHost package, since at the moment we're still shipping the BuildHost binary as a "regular binary" to be loaded in-process as before since we're doing this work one step at a time. There was a bug that was fixed in this PR last night that removed an accidental reference to a non-existent package. So if you are still seeing a package with a reference to a that non-existent package, then something is up and I need to dig further.

One thing we need to determine first is whether Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost needs to be source-built at all.

At the moment, the code behavior is the same before for the package and this was supposed to be an under-the-hood change. We have other code outside the SDK consuming the BuildHost and the StreamJsonRpc portion of it, so for purposes of unblocking at the moment we absolutely can restrict those references to non-source-build only if that's the easiest solution. Although we will need to revisit this at some point; if there's a different RPC library that's also already sourcebuild friendly I can switch to that too...StreamJsonRpc was just chosen as we use it in other parts of our stack, not because of any specific feature in it.

@mthalman
Copy link
Member Author

mthalman commented Sep 7, 2023

There shouldn't be a BuildHost package

No issue here. I should have referred to them as projects instead of packages.

At the moment, the code behavior is the same before for the package and this was supposed to be an under-the-hood change.

That doesn't seem to be the case. Or maybe I'm misinterpreting what you're saying. There was never a dependency on StreamJsonRpc from Microsoft.CodeAnalysis.Workspaces.MSBuild prior to the addition of the BuildHost.

We have other code outside the SDK consuming the BuildHost and the StreamJsonRpc portion of it, so for purposes of unblocking at the moment we absolutely can restrict those references to non-source-build only if that's the easiest solution.

It's not the code that's referencing BuildHost that's the issue. It's BuildHost itself, which has the dependency on StreamJsonRpc, that's the issue.

If the implementation which uses StreamJsonRpc is not relevant for the SDK itself, can it be factored out into a separate project that we then don't include with source-build?

@jasonmalinowski
Copy link
Member

There was never a dependency on StreamJsonRpc from Microsoft.CodeAnalysis.Workspaces.MSBuild prior to the addition of the BuildHost.

I might have not explained well: yes, the dependency is new, but at the moment for purposes of the SDK we're not actually using the process-launching part of it. We're using that in other places for now. That'll change in a month or so though, so longer term we still need a plan.

Stepping back for a moment, what should this look like? Either we have to make StreamJsonRpc be part of source-build-externals, or we move to a different RPC library?

@jasonmalinowski jasonmalinowski self-assigned this Sep 7, 2023
@mthalman
Copy link
Member Author

mthalman commented Sep 7, 2023

That'll change in a month or so though, so longer term we still need a plan.

Got it. So any workaround to remove the dependency now won't be relevant once the SDK requires the use of the BuildHost.

Stepping back for a moment, what should this look like? Either we have to make StreamJsonRpc be part of source-build-externals, or we move to a different RPC library?

Our only options are to depend on code which 1) ships with the .NET SDK or 2) is a package external to the SDK which would then need to be configured in source-build-externals. The issue with StreamJsonRpc is that it includes other dependencies as well which would need to be source-built: MessagePack and Nerdbank.Streams. If there are other vetted libraries available that have no dependencies on non-.NET-owned packages, that would be ideal.

@jasonmalinowski
Copy link
Member

Got it. So any workaround to remove the dependency now won't be relevant once the SDK requires the use of the BuildHost.

Or at least, I don't want to spend more effort on a workaround than necessary, or at least limit stuff we'd have to undo later. I know we have projects now that condition things on DotNetBuildFromSource in MSBuild; I can trivially add some condition checks to the particular source files to unblock this if that's an easy short term solution.

@mthalman
Copy link
Member Author

mthalman commented Sep 7, 2023

Or at least, I don't want to spend more effort on a workaround than necessary, or at least limit stuff we'd have to undo later. I know we have projects now that condition things on DotNetBuildFromSource in MSBuild; I can trivially add some condition checks to the particular source files to unblock this if that's an easy short term solution.

If that's easy, that would buy some time and unblock things. Are the changes to eventually include the dependency from the SDK intended for .NET 8?

@jasonmalinowski
Copy link
Member

Are the changes to eventually include the dependency from the SDK intended for .NET 8?

The schedule for that isn't tied to 8.0; this is a bit of funky fallout of the fact that Roslyn repository ships things in different vehicles -- I'm honestly quite surprised that Roslyn main was even shipping in 8.0 given it's in RC. So we can delay after whenever that snap is, but I have no idea what that date is.

@jasonmalinowski
Copy link
Member

@mthalman Is gRPC already within source build or not?

@genlu genlu removed the untriaged Issues and PRs which have not yet been triaged by a lead label Sep 8, 2023
@mthalman
Copy link
Member Author

mthalman commented Sep 8, 2023

The schedule for that isn't tied to 8.0; this is a bit of funky fallout of the fact that Roslyn repository ships things in different vehicles -- I'm honestly quite surprised that Roslyn main was even shipping in 8.0 given it's in RC. So we can delay after whenever that snap is, but I have no idea what that date is.

Perfect. Glad to hear this isn't a .NET 8 thing. This gives us a lot of time then.

Is gRPC already within source build or not?

No. That's part of https://github.com/grpc/grpc-dotnet. Nothing which ships as part of the SDK has a dependency on that.

@jasonmalinowski, can you log an issue for this that describes the need for RPC and the fact that it will have have source-build implications? It'd be good to have something to track this and we can discuss what our options are.

@jasonmalinowski
Copy link
Member

I think rather than try (re)inventing an RPC approach we're just going to restructure our code a bit. What we were doing was spinning up an external process which is running MSBuild APIs; we can probably restructure things where we just launch the process and pass all the projects we want to analyze in command line switches, just have it output a single JSON blob and then exit. That might work fine and just avoid the RPC need entirely.

@mthalman
Copy link
Member Author

I'm reopening since there are still many prebuilts remaining:

Microsoft.AspNetCore.App.Ref.7.0.9
Microsoft.AspNetCore.App.Runtime.linux-arm64.7.0.9
Microsoft.AspNetCore.App.Runtime.linux-arm64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.linux-musl-arm64.7.0.9
Microsoft.AspNetCore.App.Runtime.linux-musl-arm64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.linux-musl-x64.7.0.9
Microsoft.AspNetCore.App.Runtime.linux-musl-x64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.linux-x64.7.0.9
Microsoft.AspNetCore.App.Runtime.linux-x64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.osx-arm64.7.0.9
Microsoft.AspNetCore.App.Runtime.osx-arm64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.osx-x64.7.0.9
Microsoft.AspNetCore.App.Runtime.osx-x64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.win-arm64.7.0.9
Microsoft.AspNetCore.App.Runtime.win-arm64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.win-x64.7.0.9
Microsoft.AspNetCore.App.Runtime.win-x64.8.0.0-preview.7.23375.9
Microsoft.AspNetCore.App.Runtime.win-x86.7.0.9
Microsoft.AspNetCore.App.Runtime.win-x86.8.0.0-preview.7.23375.9
Microsoft.Build.Locator.1.6.1
Microsoft.DiaSymReader.2.0.0
Microsoft.NETCore.App.Host.linux-arm64.7.0.9
Microsoft.NETCore.App.Host.linux-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Host.linux-musl-arm64.7.0.9
Microsoft.NETCore.App.Host.linux-musl-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Host.linux-musl-x64.7.0.9
Microsoft.NETCore.App.Host.linux-musl-x64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Host.linux-x64.7.0.9
Microsoft.NETCore.App.Host.osx-arm64.7.0.9
Microsoft.NETCore.App.Host.osx-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Host.osx-x64.7.0.9
Microsoft.NETCore.App.Host.osx-x64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Host.win-arm64.7.0.9
Microsoft.NETCore.App.Host.win-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Host.win-x64.7.0.9
Microsoft.NETCore.App.Host.win-x64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Host.win-x86.7.0.9
Microsoft.NETCore.App.Host.win-x86.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Ref.7.0.9
Microsoft.NETCore.App.Runtime.linux-arm64.7.0.9
Microsoft.NETCore.App.Runtime.linux-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.linux-musl-arm64.7.0.9
Microsoft.NETCore.App.Runtime.linux-musl-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.linux-musl-x64.7.0.9
Microsoft.NETCore.App.Runtime.linux-musl-x64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.linux-x64.7.0.9
Microsoft.NETCore.App.Runtime.linux-x64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.osx-arm64.7.0.9
Microsoft.NETCore.App.Runtime.osx-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.osx-x64.7.0.9
Microsoft.NETCore.App.Runtime.osx-x64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.win-arm64.7.0.9
Microsoft.NETCore.App.Runtime.win-arm64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.win-x64.7.0.9
Microsoft.NETCore.App.Runtime.win-x64.8.0.0-preview.7.23375.6
Microsoft.NETCore.App.Runtime.win-x86.7.0.9
Microsoft.NETCore.App.Runtime.win-x86.8.0.0-preview.7.23375.6
runtime.any.System.Collections.4.3.0
runtime.any.System.Globalization.4.3.0
runtime.any.System.IO.4.3.0
runtime.any.System.Reflection.4.3.0
runtime.any.System.Reflection.Primitives.4.3.0
runtime.any.System.Resources.ResourceManager.4.3.0
runtime.any.System.Runtime.4.3.0
runtime.any.System.Runtime.Handles.4.3.0
runtime.any.System.Runtime.InteropServices.4.3.0
runtime.any.System.Text.Encoding.4.3.0
runtime.any.System.Threading.Tasks.4.3.0
runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.native.System.4.3.0
runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.0
runtime.unix.System.Private.Uri.4.3.0
runtime.unix.System.Runtime.Extensions.4.3.0
runtime.win.System.Runtime.Extensions.4.3.0
System.CommandLine.2.0.0-beta4.23307.1
System.Private.Uri.4.3.0
System.Text.Json.7.0.3

These can be verified by looking at the source-build within roslyn CI. The prebuilts are listed at the bottom of the build log.

@mthalman
Copy link
Member Author

mthalman commented Sep 12, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants