© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
11 replies
Nacio

❔ Saving current commit information to a file

I'm trying to save the current commit's information using this in the .csproj
    <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
        <Exec Command="git log -1 --pretty=%&lt;25&gt;H%&lt;25&gt;n%&lt;25&gt;an%&lt;25&gt;n%&lt;25&gt;ae%&lt;25&gt;n%&lt;25&gt;cn%&lt;25&gt;n%&lt;25&gt;ce%&lt;25&gt;n%&lt;25&gt;cI%&lt;25&gt;n%&lt;25&gt;s &gt; &quot;$(ProjectDir)\CurrentCommit&quot;"/>
    </Target>
    <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
        <Exec Command="git log -1 --pretty=%&lt;25&gt;H%&lt;25&gt;n%&lt;25&gt;an%&lt;25&gt;n%&lt;25&gt;ae%&lt;25&gt;n%&lt;25&gt;cn%&lt;25&gt;n%&lt;25&gt;ce%&lt;25&gt;n%&lt;25&gt;cI%&lt;25&gt;n%&lt;25&gt;s &gt; &quot;$(ProjectDir)\CurrentCommit&quot;"/>
    </Target>

but it just keeps saying
The system cannot find the file specified.
The system cannot find the file specified.
, does that mean it can't find the
git
git
command or actually the file,
or maybe there's a better way to get the commit info?

git log -1 --pretty=%H%n%an%n%ae%n%cn%n%ce%n%cI%n%s > ".\CurrentCommit"
git log -1 --pretty=%H%n%an%n%ae%n%cn%n%ce%n%cI%n%s > ".\CurrentCommit"
works just fine when run in a regular terminal
Build log: https://pastebin.com/raw/2dpKPdq5
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Looking for a way to Extract information from a txt File
C#CC# / help
2y ago
✅ Sourcetree reverse to a certain commit
C#CC# / help
12mo ago