Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when defining LocalGitPath #31

Open
dcbroad3 opened this issue Jan 12, 2016 · 0 comments
Open

Issue when defining LocalGitPath #31

dcbroad3 opened this issue Jan 12, 2016 · 0 comments

Comments

@dcbroad3
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant