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:
.git
directory is present..git
directory is present..git
directory is hidden. I have unchecked the Hidden
checkbox in that directory's details, but no luck.dotnet-gitversion
from 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
If I read the doc correctly : dotnet-gitversion
interprets its first argument as the path to the root of the project. ShortSha
doesn't fit the bill.
You probably want to use the /showvariable
option, which indicates to also set /output json
.