fix: use AfterTargets="Restore" to support NuGet credential helpers for private feeds#162
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Husky’s generated MSBuild target hook point so NuGet authentication (including credential helpers for private feeds) completes during Restore before Husky runs dotnet tool restore / dotnet husky install.
Changes:
- Generate the Husky MSBuild target with
AfterTargets="Restore"instead ofBeforeTargets="Restore;CollectPackageReferences". - Update the automation guide XML snippets to match the new target ordering.
- Extend
AttachCommandunit tests to assertAfterTargets="Restore"and absence ofBeforeTargets.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Husky/Cli/AttachCommand.cs |
Switch generated target hook to AfterTargets="Restore" |
tests/HuskyTest/Cli/AttachCommandTests.cs |
Assert generated XML uses AfterTargets and not BeforeTargets |
docs/guide/automate.md |
Update manual XML snippets to AfterTargets="Restore" |
.husky/commit-msg |
Adds a commit-msg hook invoking Husky task runner (but currently breaks failure propagation) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
No conflicts. |
Description
Users relying on NuGet Credential Helpers for private feeds had
dotnet tool restorefail because auth (performed during MSBuild'sRestoretarget) hadn't happened yet when the Husky target ran underBeforeTargets="Restore".AttachCommand.cs— generated MSBuild target now usesAfterTargets="Restore"instead ofBeforeTargets="Restore;CollectPackageReferences"docs/guide/automate.md— updated both the primary and multi-framework XML snippets to matchdocs/guide/submodules.md— updated the submodule attach example snippet to matchAttachCommandTests.cs— added assertions that the generated target hasAfterTargets="Restore"set and noBeforeTargetsBefore / After
Running after
Restoreensures credential helpers have already performed the auth dance beforedotnet tool restoreis invoked. Husky hook installation has no dependency on running before package restore, so this is non-breaking.Type of change
Checklist
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.