Giter Site home page Giter Site logo

Comments (6)

jeffkl avatar jeffkl commented on August 19, 2024 2

Can static graph restore pass the list of ProjectReferences from the metaproj to the restore task?

Yes, its technically possible to pass all of the necessary information along. I'm hesitant to implement it that way because we already have issues streaming global properties to the other process. I'd feel a lot more comfortable just passing the full path to the SLNF to the process instead.

from home.

nkolev92 avatar nkolev92 commented on August 19, 2024

Team Triage: @jeffkl what would be the cost of fixing this?

from home.

jeffkl avatar jeffkl commented on August 19, 2024

Unfortunately, MSBuild does not expose the path to the solution filter during the build (dotnet/msbuild#6162). The way it currently works for regular restore is that MSBuild generates an in-memory .metaproj that contains a <ProjectReference /> to just the projects to build. Regular restore then walks those projects.

For static graph-based restore, MSBuild only passes along the path to the solution file and the path to the in-memory .metaproj:

Image

For regular restore, since its running in the same process it has access to the in-memory .metaproj. Since static graph-based restore runs out-of-proc, it would need to either write the .metaproj to disk or pass along the path to the solution filter instead. It could also use reflection to get the path to the solution filter:

object buildRequest = BuildEngine.GetType().GetField("_requestEntry", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(BuildEngine);
object buildRequestConfiguration = buildRequest.GetType().GetProperty("RequestConfiguration", BindingFlags.Public | BindingFlags.Instance).GetValue(buildRequest);
string solutionFilterFileFullPath = buildRequestConfiguration.GetType().GetProperty("ProjectFullPath", BindingFlags.Public | BindingFlags.Instance).GetValue(buildRequestConfiguration) as string;

So we need to either:

  1. Update MSBuild to indicate the path to the solution filter being restored
  2. Use reflection to get the path to the solution filter being restored

from home.

nkolev92 avatar nkolev92 commented on August 19, 2024

We use reflection in nuget.exe, but the bar is arguably lower there: https://github.com/NuGet/NuGet.Client/blob/d7607e2f08721498801ace7fe47933d4e6dfeffd/src/NuGet.Clients/NuGet.CommandLine/Common/Solution.cs#L120.

from home.

zivkan avatar zivkan commented on August 19, 2024

Can static graph restore pass the list of ProjectReferences from the metaproj to the restore task?

It's not perfect, because:

  • sln based restore will pass the full list of projects, and then waste CPU time filtering the list to what ends up being the full list of projects
  • slnf based restore will have MSBuild evaluate the full solution, but then NuGet will ignore all the projects not part of the filter

but at least there will be fewer projects that need to resolve the package graph, hopefully fewer packages to download, etc.

from home.

zivkan avatar zivkan commented on August 19, 2024

I agree getting the slnf path is the ideal solution.

I'm just a bit worried about using reflection to get a non-public property. If MSBuild makes a change that breaks static restore, it might take us a while to notice. After all, our dev branch will be inserted into the 8.0.3xx SDK, but our build scripts are still testing against a pre-release 8.0.1xx SDK build. Therefore, our own CI pipeline wouldn't even detect the break.

Sending the long list of projects feels like a lower risk temporary solution, while we wait for MSBuild to make the request, and slnf path, a public API.

from home.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.