Digital-Clouds Digital-Clouds - 15 days ago 7
C# Question

C# console app for SVN hook not getting not getting command line arguments

I've written a C# console application to use as an SVN pre-commit hook. I'm using this to parse the launch parameters. It's running on VisualSVN, and according to the VisualSVN documentation:


Input parameter(s)

The command-line arguments passed to the hook program, in order, are:


  • Repository path

  • Commit transaction name




I don't seem to be picking up the arguments passed into the application when run via the hook. If I run the application from the console, passing in the arguments manually, it works correctly, but when called by the SVN, the
args
array is empty, and the command line parser doesn't pick up anything.

I've added this by specifying an absolute path to the exe in the pre-commit hook property in VisualSVN (
C:\Scripts\pre-commit.exe
). Is this correct/do I need to do anything special to get the arguments to pass to the application?

Answer

It seems that the pre-commit.exe file has to be placed inside the repo hooks directory. Once I moved it there, it got hit with the correct parameters. I think the Visual SVN pre-commit hook dialog actually creates a batch file, and it was losing the arguments when it called the executable.

I could probably also have tweaked the behaviour of that wrapper to make it work, but dropping the executable in there did the trick.