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

Add option to serialize global properties when running static graph-based restore #5413

Merged

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Sep 13, 2023

Bug

Fixes: NuGet/Home#11968

Regression? Last working version:

Description

Adds an option to allow a user to specify that global properties should be serialized over STDIN instead of passed as command-line arguments. If the process fails to start, an error is logged so users can find information about how to enable the property. In future versions, we can explore enabling this option by default.

  • Added an MSBuild property, RestoreSerializeGlobalProperties that the user can set to true if they want to opt-in to the functionality
  • The code sets the Console.InputEncoding to avoid the original problem where a preamble is written to the stream
  • Added a bunch of unit tests
  • Added better logging in the condition where an error occurs reading arguments. Previously all data was sent back over STDOUT as JSON but if an unexpected problem occurs nothing is sent back. Now NuGet.Build.Tasks.Console writes errors to STDERR as strings and RestoreTaskEx logs them.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

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

@jeffkl jeffkl requested a review from a team as a code owner September 13, 2023 23:55
@jeffkl jeffkl self-assigned this Sep 13, 2023
@jeffkl jeffkl requested a review from zivkan September 15, 2023 23:07
@aortiz-msft aortiz-msft added the Merge next release PRs that should not be merged until the dev branch targets the next release label Sep 20, 2023
@ghost ghost added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Sep 27, 2023
@ghost
Copy link

ghost commented Sep 27, 2023

This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch.

@jeffkl jeffkl removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Sep 28, 2023
@jeffkl jeffkl force-pushed the dev-jeffkl-static-graph-restore-serialize-global-properties branch from 507a9f7 to fe39645 Compare September 29, 2023 18:04
@jeffkl jeffkl requested review from zivkan and removed request for zivkan September 29, 2023 18:04
@ghost ghost added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Oct 7, 2023
@ghost
Copy link

ghost commented Oct 7, 2023

This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch.

@jeffkl jeffkl removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Oct 9, 2023
@jeffkl jeffkl force-pushed the dev-jeffkl-static-graph-restore-serialize-global-properties branch from df24c15 to 164d30b Compare October 9, 2023 19:43
@jeffkl
Copy link
Contributor Author

jeffkl commented Oct 9, 2023

This implementation no longer attempts to enable the setting and instead logs a useful error message that users can use to find the solution of enabling the option.

@jeffkl jeffkl requested a review from dtivel October 9, 2023 19:45
@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Oct 10, 2023

I am sure you may have already explored this option, but I am curious to know the possibility of using response files as suggested by Chet and Jared in NuGet/Home#11968 (comment).

@jeffkl
Copy link
Contributor Author

jeffkl commented Oct 10, 2023

I am sure you may have already explored this option, but I am curious to know the possibility of using response files as suggested by Chet and Jared in NuGet/Home#11968 (comment).

The problem with response files is NuGet would need to write it to disk, then it would be read by the new process, then it would need to be deleted. Writing to the current directory seems bad since the data in this response is only ever meant to be read by our process. Writing to TEMP has been problematic in the past on other platforms so I avoided that. If this was a process meant to be launched by users, it would absolutely make sense to use a response file that the user could author. But in this case its just one process launching another process and sending data to it. STDIN made sense to use so we don't have to deal with a location to write to disk and it should technically be more performant.

@jeffkl jeffkl removed the Merge next release PRs that should not be merged until the dev branch targets the next release label Oct 10, 2023
@jeffkl jeffkl force-pushed the dev-jeffkl-static-graph-restore-serialize-global-properties branch from 1623a92 to 15c9aff Compare October 10, 2023 20:01
@jeffkl jeffkl merged commit 6bbfede into dev Oct 13, 2023
16 checks passed
@jeffkl jeffkl deleted the dev-jeffkl-static-graph-restore-serialize-global-properties branch October 13, 2023 18:52
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.

[Bug]: Process argument string is too long when publishing in Visual Studio with static graph enabled
5 participants