Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Add .git directory check to MSBuild Git targets Updated the conditions for the `SetSourceRevisionId` and `SetRepositoryBranch` targets in `Grand.Common.props` to include a check for the existence of the `.git` directory. This ensures that Git commands are only executed if the project is under Git version control, preventing errors when the project is not managed by Git.

support3e6cce07e687
diff --git a/src/Build/Grand.Common.props b/src/Build/Grand.Common.props
index 0af467499..3e292e8ab 100644
--- a/src/Build/Grand.Common.props
+++ b/src/Build/Grand.Common.props
@@ -25,14 +25,14 @@
<Using Include="System.Threading.Tasks" />
</ItemGroup>
<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation"
- Condition="'$(SourceRevisionId)'==''">
+ Condition="'$(SourceRevisionId)'=='' And Exists('$(MSBuildProjectDirectory)\.git')">
<Exec Command="git describe --long --always --exclude=* --abbrev=8" ConsoleToMSBuild="True"
IgnoreExitCode="True">
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput" />
</Exec>
</Target>
<Target Name="SetRepositoryBranch" BeforeTargets="InitializeSourceControlInformation"
- Condition="'$(GitBranch)'==''">
+ Condition="'$(GitBranch)'=='' And Exists('$(MSBuildProjectDirectory)\.git')">
<Exec Command="git rev-parse --abbrev-ref HEAD" ConsoleToMSBuild="True" IgnoreExitCode="True">
<Output PropertyName="branch" TaskParameter="ConsoleOutput" />
</Exec>