alirezanet / Husky.Net

Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
https://alirezanet.github.io/Husky.Net/
MIT License
632 stars 29 forks source link

dotnet husky install fails if .git folder is in the parent folder of the #C project #55

Closed MichaelCharles closed 1 year ago

MichaelCharles commented 1 year ago

Version

v0.5.2

Details

In my project we have a parent folder, project and then a child folder Project.Api that houses the actual C# project files.

I can install the tool as described in the documentation but when I run dotnet husky install from the Project.Api folder I get the following output.

.git can't be found (see https://alirezanet.github.io/Husky.Net/guide/getting-started)
Git hooks installation failed

The .git folder is in the parent project folder, so I guess that makes sense. If I change directories to the parent folder and try running it again, I get,

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-husky does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

I attempted to install Husky globally and see if that eliminates this problem, but the output was the same afterwards.

I realize this might not be a bug and it might just be me using it in a way that was not intended. Any direction in how I could resolve this would be helpful.

Steps to reproduce

alirezanet commented 1 year ago

Hi @mcaubrey, I think You have checked out the Csharper library documentation and it might not be up-to-date, try Husky.Net documentation.

you missed the first important step in installation which is cd <Your project/solution root directory>. also for attaching husky to your project the recommended way is use the attach command, more info here.

Husky will install in your repository, not your project, so you must install it from your parent folder.

alirezanet commented 1 year ago

I think you forgot to remove or update the dotnet format task.

{
   "tasks": [
      {
         "name": "dotnet-format-example",
         "command": "dotnet",
         "args": [ "dotnet-format", "--include", "${staged}" ],
         "include": [ "**/*.cs", "**/*.vb" ]
      }, ....