Skip to content

Issue when defining LocalGitPath #31

Description

@dcbroad3

When we define the LocalGitPath, the GitPath is set in MSBuild.Bower.targets.

    <PropertyGroup Condition=" '$(LocalGitPath)' != '' ">
        <GitPath>$(LocalGitPath)</GitPath>
        <EnsureGitInPathCmd>SETLOCAL &amp; SET PATH=$(LocalGitPath);%PATH% &amp;</EnsureGitInPathCmd>
    </PropertyGroup>

Then, GitPath is not empty, so we skip the Exec that follows:

    <Exec Command="$(WINDIR)\system32\where.exe git"
        ContinueOnError="true"
        IgnoreExitCode="true"
        ConsoleToMsBuild="true"
        Condition=" '$(GitPath)' == '' ">
        <Output TaskParameter="ExitCode" PropertyName="WhereExitCode"/>
        <Output TaskParameter="ConsoleOutput" PropertyName="GitExecutable" />
    </Exec>

However, when we get to the PropertyGroup that follows the Exec, the Condition is met because $(WhereExitCode) is 0 (from a previous target, presumably), but $(GitExecutable) is empty, so an error is thrown when GetDirectoryName is called:

    <PropertyGroup Condition=" '$(WhereExitCode)' == '0' ">
        <GitPath>$([System.IO.Path]::GetDirectoryName('$(GitExecutable)'))</GitPath>
    </PropertyGroup>

I propose adding another condition; the below seems to work for me:

    <PropertyGroup Condition=" '$(GitPath)' == '' AND '$(WhereExitCode)' == '0' ">
        <GitPath>$([System.IO.Path]::GetDirectoryName('$(GitExecutable)'))</GitPath>
    </PropertyGroup>

Of course, WhereExitCode could also be renamed to something unique.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions