Skip to content

Code quality: build fails when no Git availableΒ #1163

@Jay-o-Way

Description

@Jay-o-Way

I recently installed VS 2026 (clean) and now I encountered an issue. Looks like on my computer Git can't be found now, and therefore the AutoDarkModeLib can't be built and then AutoDarkModeApp also fails. Copilot has a solution/workaround for this.

Snippet

<Target Name="GetGitDescribe" BeforeTargets="BeforeBuild">
  <!-- Run git describe but do not make the build fail if git is not available -->
  <Exec Command="git describe --all --long" ConsoleToMSBuild="true" ContinueOnError="true">
    <Output TaskParameter="ConsoleOutput" PropertyName="GitDescribe" />
  </Exec>

  <!-- Provide a stable fallback when git produced no output -->
  <PropertyGroup>
    <GitDescribe Condition="'$(GitDescribe)' == ''">v0.0.0-unknown</GitDescribe>
  </PropertyGroup>
</Target>

Screenshot

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-internalInternal issue, created for transparency, could be a code task

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions