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. |
Updated [husky](https://github.com/alirezanet/husky.net) from 0.8.0 to 0.9.0. <details> <summary>Release notes</summary> _Sourced from [husky's releases](https://github.com/alirezanet/husky.net/releases)._ ## 0.9.0 ## What's Changed * remove net6.0/net7.0 since out of support by @WeihanLi in alirezanet/Husky.Net#135 * fix: update regex pattern to allow breaking commits by @joaoopereira in alirezanet/Husky.Net#153 * Fix parallel install mutex bug and support incremental build by @MattKotsenas in alirezanet/Husky.Net#159 * fix: handle file paths with spaces in git commands in alirezanet/Husky.Net#156 * feat: add `staged` property to custom variables for re-staging support in alirezanet/Husky.Net#163 * feat: support variables in include/exclude glob patterns in alirezanet/Husky.Net#161 * fix: use AfterTargets="Restore" to support NuGet credential helpers for private feeds in alirezanet/Husky.Net#162 ## New Contributors * @joaoopereira made their first contribution in alirezanet/Husky.Net#153 * @MattKotsenas made their first contribution in alirezanet/Husky.Net#159 **Full Changelog**: alirezanet/Husky.Net@v0.8.0...v0.9.0 Commits viewable in [compare view](alirezanet/Husky.Net@v0.8.0...v0.9.0). </details> Updated [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/dotnet) from 10.0.4 to 10.0.5. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Logging.Abstractions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.SourceLink.GitHub](https://github.com/dotnet/dotnet) from 10.0.200 to 10.0.201. <details> <summary>Release notes</summary> _Sourced from [Microsoft.SourceLink.GitHub's releases](https://github.com/dotnet/dotnet/releases)._ ## 10.0.201 You can build .NET 10.0 from the repository by cloning the release tag `v10.0.201` and following the build instructions in the [main README.md](https://github.com/dotnet/dotnet/blob/v10.0.201/README.md#building). Alternatively, you can build from the sources attached to this release directly. More information on this process can be found in the [dotnet/dotnet repository](https://github.com/dotnet/dotnet/blob/v10.0.201/README.md#building-from-released-sources). Attached are PGP signatures for the GitHub generated tarball and zipball. You can find the public key at https://dot.net/release-key-2023 Commits viewable in [compare view](dotnet/dotnet@v10.0.200...v10.0.201). </details> Updated [System.CommandLine](https://github.com/dotnet/dotnet) from 2.0.4 to 2.0.5. <details> <summary>Release notes</summary> _Sourced from [System.CommandLine's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.