You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running C# scripts that include NuGet package references (using the #r "nuget: ..." directive) via Husky.NET hooks, the script fails to execute properly. However, when the same script is executed directly using dotnet script, it works as expected.
Actual Behavior:
The script fails with an error indicating that the metadata file for the NuGet package (e.g., "nuget: Framework.Common.GitHook, 1.0.0") was not found, causing script compilation to fail.
Additional Information:
Running the script directly with dotnet script works without issues.
It appears that Husky.NET’s execution environment might not be resolving NuGet package references correctly.
Please let me know if additional information (e.g., Husky.NET version, .NET SDK version, OS details) would be helpful.
Steps to reproduce
Create a C# script (e.g., commit-lint.csx) with a NuGet package reference, for example:
#!/usr/bin/env dotnet-script
#r "nuget: Framework.Common.GitHook, 1.0.0"usingSystem;usingSystem.IO;usingFramework.Common.GitHook;varmsg=File.ReadAllLines(Args[0])[0];varresult=ConventionalCommitValidator.Validate(msg);Console.WriteLine(result);if(result){return0;}Console.ForegroundColor=ConsoleColor.Red;Console.WriteLine("Invalid commit message");Console.ResetColor();Console.WriteLine("e.g.: 'feat(scope): subject' or 'fix: subject'");Console.WriteLine("or a valid merge commit message, e.g.: \"Merge branch 'master' into 'develop'\"");Console.ForegroundColor=ConsoleColor.Gray;Console.WriteLine("more info: https://www.conventionalcommits.org/en/v1.0.0/");return1;
Configure Husky.NET to run this script as a commit hook, for example:
Commit changes so that the Husky hook is triggered.
Expected Behavior:
The script should execute the NuGet package reference successfully (as it does when using dotnet script directly) and perform its validation without error.
The text was updated successfully, but these errors were encountered:
Hi @kechf,
This package (Framework.Common.GitHook) doesn't exist in nuget
Are you sure it works with dotnet script!?
dotnet script .husky\csx\commit-lint.csx
Unable to restore packages from 'C:\Users\AliReza\AppData\Local\Temp\dotnet-script\C\Users\AliReza\source\Husky.Net\.husky\csx\net9.0\script.csproj'
Make sure that all script files contains valid NuGet references
Version
0.7.2
Details
When running C# scripts that include NuGet package references (using the
#r "nuget: ..."
directive) via Husky.NET hooks, the script fails to execute properly. However, when the same script is executed directly usingdotnet script
, it works as expected.Actual Behavior:
The script fails with an error indicating that the metadata file for the NuGet package (e.g.,
"nuget: Framework.Common.GitHook, 1.0.0"
) was not found, causing script compilation to fail.Additional Information:
dotnet script
works without issues.Steps to reproduce
commit-lint.csx
) with a NuGet package reference, for example:Expected Behavior:
The script should execute the NuGet package reference successfully (as it does when using
dotnet script
directly) and perform its validation without error.The text was updated successfully, but these errors were encountered: