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

Support nuget pack targets in static graph with isolation #6197

Open
cdmihai opened this issue Feb 25, 2021 · 1 comment
Open

Support nuget pack targets in static graph with isolation #6197

cdmihai opened this issue Feb 25, 2021 · 1 comment
Labels
Area: Static Graph Issues with -graph, -isolate, and the related APIs. needs-design Requires discussion with the dev team before attempting a fix. triaged
Milestone

Comments

@cdmihai
Copy link
Contributor

cdmihai commented Feb 25, 2021

Building a graph containing packable (which triggers the nuget pack targets to run) projects that are not terminal leaves triggers the isolation constraints.

The pack logic is run on the outer build nodes. The nuget pack targets use the MSBuild task to call into various nodes not predicted by the static graph, and thus fails isolation constraints:

  • outer build pack computes its transitive closure and only MSBuild calls into closure nodes that are outer builds themselves (via Pack -> GenerateNuspec -> _GetProjectReferenceVersions).
  • outer build pack calls into its inner builds nodes multiple times. Some of the calls match the inner build nodes predicted by static graph, but some do not, as they add extra global properties (via Pack -> GenerateNuspec -> _WalkEachTargetPerFramework).

We need to enhance the static graph declaration expressivity (probably the ProjectReferenceTargets protocol) to allow the nuget team to express the funky calling patterns that nuget pack is doing, such that static graph can predict and create nodes that capture those calls.

Generalizing what pack is doing:

  • a project can express that it depends on its closure. This is already implemented via AddTransitiveProjectReferencesInStaticGraph
    • enhance this ability to also filter the closure by global properties. In nuget's particular case, filter the closure to only include outer builds (that is, filter by ignoring nodes that have the TargetFramework global property set).
  • a project can express that it further decorates some of the nodes predicted by the graph with extra global properties. In nuget's particular case, this is the outer build calling into the the inner build nodes with additional global properties.
@cdmihai cdmihai added needs-triage Have yet to determine what bucket this goes in. Area: Static Graph Issues with -graph, -isolate, and the related APIs. needs-design Requires discussion with the dev team before attempting a fix. labels Feb 25, 2021
@rainersigwald rainersigwald added this to the Backlog milestone Jun 9, 2021
@rainersigwald rainersigwald added needs-design Requires discussion with the dev team before attempting a fix. and removed needs-design Requires discussion with the dev team before attempting a fix. needs-triage Have yet to determine what bucket this goes in. labels Jun 9, 2021
@Starkie
Copy link

Starkie commented Jul 1, 2021

I think we may have encountered this issue. We added the -graphBuild flag to our Azure DevOps pipelines, but it did not generate all the expected NuGet packages.

We have a basic repro project and steps to reproduce it, if needed:
Repro.zip

  • It's just a basic solution with two netstandard projects: Enumerations and Exceptions.
  • Exceptions references the Eumerations project.
  • When building the project with GeneratePackageOnBuild set to true and the Static Graph disabled, both packages are generated as expected.
dotnet build .\Contracts.sln -c Release -graphBuild:False /p:GeneratePackageOnBuild=True
Microsoft (R) Build Engine version 16.10.1+2fd48ab73 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored D:\W\Test\Exceptions\Exceptions.csproj (in 161 ms).
  Restored D:\W\Test\Enumerations\Enumerations.csproj (in 161 ms).
  Enumerations -> D:\W\Test\Enumerations\bin\Release\netstandard2.0\Contracts.Enumerations.dll
  Successfully created package 'D:\W\Test\Enumerations\bin\Release\Contracts.Enumerations.1.0.0.nupkg'.
  Exceptions -> D:\W\Test\Exceptions\bin\Release\netstandard2.0\Contracts.Exceptions.dll
  Successfully created package 'D:\W\Test\Exceptions\bin\Release\Contracts.Exceptions.1.0.0.nupkg'.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.58
  • If the -graphBuild variable is enabled, then only the outer project's NuGet package (Contracts.Exceptions.nupkg) is generated. Contracts.Enumerations.nupkg is not generated.
dotnet build .\Contracts.sln -c Release -graphBuild:True /p:GeneratePackageOnBuild=True
Microsoft (R) Build Engine version 16.10.1+2fd48ab73 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored D:\W\Test\Exceptions\Exceptions.csproj (in 160 ms).
  Restored D:\W\Test\Enumerations\Enumerations.csproj (in 160 ms).
Static graph loaded in 0,137 seconds: 4 nodes, 3 edges
  Enumerations -> D:\W\Test\Enumerations\bin\Release\netstandard2.0\Contracts.Enumerations.dll
  Exceptions -> D:\W\Test\Exceptions\bin\Release\netstandard2.0\Contracts.Exceptions.dll
  Successfully created package 'D:\W\Test\Exceptions\bin\Release\Contracts.Exceptions.1.0.0.nupkg'.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Static Graph Issues with -graph, -isolate, and the related APIs. needs-design Requires discussion with the dev team before attempting a fix. triaged
Projects
None yet
Development

No branches or pull requests

4 participants