joelspadin / pyvswhere

Python interface to Microsoft's Visual Studio locator tool, vswhere
MIT License
10 stars 2 forks source link

Add support for -find parameter #2

Closed ytianxia6 closed 4 years ago

ytianxia6 commented 4 years ago

I cannot use this library to find msbuild

vsfind = vswhere.find(requires=['Microsoft.Component.MSBuild'], latest=True)
print(vsfind)

then I get the same result as no 'reguires'.

joelspadin commented 4 years ago

If you run

"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild

from a command prompt, does it also not find anything? If not, then you either have an issue with your Visual Studio installation, or you don't have a version of Visual Studio installed that matches those options.

I tried running that code locally and it does return a result for me.

ytianxia6 commented 4 years ago

I tried a replacement that can get the result:

def find(find_all=False, latest=False, legacy=False, prerelease=False, products=None, prop=None, requires=None, requires_any=False, version=None):
    args = []
    # ...
    # same as vswhere.find
    # simle add -find

    args.append('-find')
    args.append('MSBuild\\**\\Bin\\MSBuild.exe')

    return vswhere.execute(args)

then it can find msbuild by find(requires=['Microsoft.Component.MSBuild'], latest=True)

joelspadin commented 4 years ago

Ah. It looks like the -find parameter was added after I originally wrote this. I'll need to add support for it.

joelspadin commented 4 years ago

See https://github.com/microsoft/vswhere/commit/4b16c6302889506e2d49ff24cfa39234753412b2

joelspadin commented 4 years ago

I just published version 1.2.0 which adds support for -find, -path, and -sort. Let me know if that works for you.

joelspadin commented 4 years ago

Fixed in 0fb57343dd18daae56cb473ce9e8337c034ead86