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

SetGitExe doesn't recognize VS Git locations #324

Closed
chrpai opened this issue Nov 30, 2023 · 4 comments · Fixed by #372
Closed

SetGitExe doesn't recognize VS Git locations #324

chrpai opened this issue Nov 30, 2023 · 4 comments · Fixed by #372
Labels

Comments

@chrpai
Copy link

chrpai commented Nov 30, 2023

Describe the Bug

I'm building a project that uses GitInfo. On a clean machine with only VS it fails to detect git. Upon reviewing GitInfo.targets I see:

    <PropertyGroup Condition="'$(GitExe)' == ''">
      <!-- We probe multiple places, with the first matching one winning -->
      <GitExe Condition="'$(GitExe)' == '' And Exists('C:\Program Files\Git\bin\git.exe')">"C:\Program Files\Git\bin\git.exe"</GitExe>
      <GitExe Condition="'$(GitExe)' == '' And Exists('C:\Program Files (x86)\Git\bin\git.exe')">"C:\Program Files (x86)\Git\bin\git.exe"</GitExe>
      <GitExe Condition="'$(GitExe)' == '' And Exists('C:\msysgit\bin\git.exe')">C:\msysgit\bin\git.exe</GitExe>
    </PropertyGroup>

VS 2022 by default installs Git to two locations. Would it be acceptable to update the targets to use these locations if found?

Directory of C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd

11/30/2023 01:48 PM 45,048 git.exe
1 File(s) 45,048 bytes

Directory of C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin

11/30/2023 01:48 PM 3,806,712 git.exe
1 File(s) 3,806,712 bytes

Back this issue
Back this issue

@chrpai chrpai added the bug label Nov 30, 2023
@kzu
Copy link
Member

kzu commented Feb 4, 2024

Yes, it would be totally ok! Feel free to send a PR and I'll merge and ship it (provided both work just like the others).

Thanks!

@kzu kzu added the help wanted label Feb 4, 2024
@gitfool
Copy link
Contributor

gitfool commented Feb 7, 2024

To do this properly you should use vswhere as there are many possible locations for visual studio; e.g. on my machine:

❯ "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -property installationPath
C:\Program Files\Microsoft Visual Studio\2022\Preview

(I only have the preview of 2022 installed so specifying -prerelease is important.)

Also, you should only need ...\Git\cmd\git.exe and not ...\Git\mingw64\bin\git.exe, unless I'm missing something.

@kzu
Copy link
Member

kzu commented Feb 14, 2024

Yep, likely just a matter of packaging the tool and invoking it from MSBuild.

@kzu kzu added enhancement and removed bug labels Feb 15, 2024
@kzu
Copy link
Member

kzu commented May 30, 2024

you're on a roll @gitfool, perhaps you can tackle this one too! 🙏

@kzu kzu added backed Backed via SponsorLink and removed backed Backed via SponsorLink labels Aug 31, 2024
@devlooped-bot devlooped-bot added the backed Backed via SponsorLink label Sep 27, 2024
kzu added a commit that referenced this issue Nov 2, 2024
@kzu kzu closed this as completed in #372 Nov 2, 2024
kzu added a commit that referenced this issue Nov 2, 2024
@devlooped devlooped locked and limited conversation to collaborators Dec 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants