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

Embed NuGet files in the binary log after restore completes #5016

Closed
wants to merge 1 commit into from

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Jan 19, 2023

Bug

Fixes: NuGet/Home#12374

Regression? No Last working version:

Description

This updates the Restore task to embed NuGet files in the binlog after Restore is complete. Even if restore fails, any files that exist will be embedded:

image

In this case the package name is wrong and the .dgspec is still in the binlog.

For static graph-based restore, the output paths are logged back to the RestoreTaskEx so it can embed the files in the binlog at the end of the actual build. I could not find a way to embed them in the nuget.binlog that contains evaluation...

Related to dotnet/sdk#16840

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception - It would be hard to verify the contents of the binlog at the moment.
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A

@jeffkl jeffkl requested a review from a team as a code owner January 19, 2023 19:04
@jeffkl jeffkl self-assigned this Jan 19, 2023
@jeffkl
Copy link
Contributor Author

jeffkl commented Jan 19, 2023

FYI @KirillOsenkov!

Copy link
Contributor

@erdembayar erdembayar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. 👏

AfterTargets="Restore"
Condition="'$(EmbedNuGetFilesInBinLog)' != 'false'">
<ItemGroup>
<EmbedInBinlog Include="$(ProjectAssetsFile)" Condition="Exists('$(ProjectAssetsFile)') AND $(EmbedProjectAssetsFile) != false" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would swap the AND branches and check for EmbedProjectAssetsFile first, then check for Exists after AND. I can't remember why, but we broke someone by still hitting the disk for Exists when it was turned off.

See here:
https://github.com/dotnet/sdk/pull/20624/files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here was the issue where we were reading the file unnecessarily and this broke deterministic/distributed build:
dotnet/sdk#20556

@jeffkl
Copy link
Contributor Author

jeffkl commented Jan 21, 2023

I'm closing this for now because I'm not 100% happy with it. Currently, only the project.assets.json file of the entry project is captured since it runs after the Restore target. So if you restore 50 projects, you only get one, which I don't think is very useful. I'll spend some time coming up with a better solution...

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

Successfully merging this pull request may close these issues.

NuGet should include the files emitted during restore in the binary log
4 participants