As explained in this previous question, I would like to add the commit hash of my sources to my executable or DLL.
In order to do this, I would like to work with the following command:
dotnet-gitversion "ShortSha" /updateassemblyinfo
I have already created a FixedAssemblyInfo.cs in order to protect the rest of my [assembly] tags, but now when I try to run the mentioned command, I get the error message:
Cannot find the .git directory
I have launched the command in different ways:
- In the main directory of my Visual Studio solution, where the
.gitdirectory is present. - In the subdirectory of my Visual Studio project, some subdirectory levels under the directory where the
.gitdirectory is present. - Generally the
.gitdirectory is hidden. I have unchecked theHiddencheckbox in that directory's details, but no luck. - I have launched
dotnet-gitversionfrom a command prompt, a command prompt, run as administrator, and from the "Developer Command Prompt for VS 2017".
Now, you can guess, it's my idea to add the dotnet-gitversion "ShortSha" /updateassemblyinfo command as a pre-build event, but if I can't even run it as a simple command, how can I launch it as a pre-build event?
For your information, the full pre-build event looks as follows:
cd $(ProjectDir)
dotnet-gitversion "ShortSha" /updateassemblyinfo
Does anybody have an idea?
O, before I forget: what I'm trying to achieve, is simply the creation of the AssemblyInfo.cs file, containing (at least) the "ShortSha" of my source code. In top of this I would like to have it as a pre-build event, in order to have this information, every time I compile my project.
Thanks a lot in advance