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

Control of the priority for MSBuild versions #14

Closed
3F opened this issue Jul 19, 2019 · 2 comments
Closed

Control of the priority for MSBuild versions #14

3F opened this issue Jul 19, 2019 · 2 comments

Comments

@3F
Copy link
Owner

3F commented Jul 19, 2019

Mentioned by @odalet from #13 (comment)

If I simply run hmsbuild, the returned version of MSBuild is 15.8 (btw I don't know why the more recent 16.0 one is not picked...)

So what's going on if we're talking about VS2017+

This is so, because of this:

hMSBuild/frontend.bat

Lines 469 to 471 in 4b368c9

if defined vspath if defined vsver (
call :vswmsb vspath vsver msbf
if defined msbf goto _vswbinReturn

But in general, it depends on installation order in your machine and current ISetupConfiguration2.EnumAllInstances / IEnumSetupInstances.Next implementation. Which may sort the available products by something.

vswhere will just enumerate it 'as is' (see installation API):

just installed 2017 & 2019 on clean VM:

:: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community "
:: "15.9.28307.770 "
:: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community "
:: "16.1.29102.190 "

that is:

instanceId: 2d0578b0
installDate: 7/19/2019 5:49:56 AM
installationName: VisualStudio/15.9.14+28307.770
installationPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
installationVersion: 15.9.28307.770
productId: Microsoft.VisualStudio.Product.Community
productPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe
state: 4294967295
isComplete: 1
isLaunchable: 1
isPrerelease: 0
isRebootRequired: 0
displayName: Visual Studio Community 2017
description: Free, fully-featured IDE for students, open-source and individual developers
channelId: VisualStudio.15.Release
channelUri: https://aka.ms/vs/15/release/channel
enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service
releaseNotes: https://go.microsoft.com/fwlink/?LinkId=660692#15.9.14
thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660708
updateDate: 2019-07-19T12:49:56.4989618Z
catalog_buildBranch: d15.9
catalog_buildVersion: 15.9.28307.770
catalog_id: VisualStudio/15.9.14+28307.770
catalog_localBuild: build-lab
catalog_manifestName: VisualStudio
catalog_manifestType: installer
catalog_productDisplayVersion: 15.9.14
catalog_productLine: Dev15
catalog_productLineVersion: 2017
catalog_productMilestone: RTW
catalog_productMilestoneIsPreRelease: False
catalog_productName: Visual Studio
catalog_productPatchVersion: 14
catalog_productPreReleaseMilestoneSuffix: 1.0
catalog_productRelease: RTW
catalog_productSemanticVersion: 15.9.14+28307.770
catalog_requiredEngineVersion: 1.18.1049.33485
properties_campaignId: 112003091.1563535912
properties_channelManifestId: VisualStudio.15.Release/15.9.14+28307.770
properties_nickname:
properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe

instanceId: bcc9b5bf
installDate: 7/19/2019 5:00:06 AM
installationName: VisualStudio/16.1.6+29102.190
installationPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
installationVersion: 16.1.29102.190
productId: Microsoft.VisualStudio.Product.Community
productPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
state: 4294967295
isComplete: 1
isLaunchable: 1
isPrerelease: 0
isRebootRequired: 0
displayName: Visual Studio Community 2019
description: Free, fully-featured IDE for students, open-source and individual developers
channelId: VisualStudio.16.Release
channelUri: https://aka.ms/vs/16/release/channel
enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service
releaseNotes: https://go.microsoft.com/fwlink/?LinkId=660893#16.1.6
thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660909
updateDate: 2019-07-19T12:00:06.2984029Z
catalog_buildBranch: d16.1
catalog_buildVersion: 16.1.29102.190
catalog_id: VisualStudio/16.1.6+29102.190
catalog_localBuild: build-lab
catalog_manifestName: VisualStudio
catalog_manifestType: installer
catalog_productDisplayVersion: 16.1.6
catalog_productLine: Dev16
catalog_productLineVersion: 2019
catalog_productMilestone: RTW
catalog_productMilestoneIsPreRelease: False
catalog_productName: Visual Studio
catalog_productPatchVersion: 6
catalog_productPreReleaseMilestoneSuffix: 1.0
catalog_productSemanticVersion: 16.1.6+29102.190
catalog_requiredEngineVersion: 2.1.3096.46871
properties_campaignId: 112003091.1563535912
properties_channelManifestId: VisualStudio.16.Release/16.1.6+29102.190
properties_nickname: 2
properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe

legacy products: 10, 11, 12, 14

Don't forget about legacy products. The part for this here:

(from newer to older versions:)

hMSBuild/frontend.bat

Lines 548 to 577 in 4b368c9

:msbvsold {out:toolset}
call :dbgprint "Searching from Visual Studio - 2015, 2013, ..."
for %%v in (14.0, 12.0) do (
call :rtools %%v Y & if defined Y (
set %1=!Y!
exit /B 0
)
)
call :dbgprint "-vs: not found"
set "%1="
exit /B 0
:: :msbvsold
:: - - -
:: Tools from .NET Framework - .net 4.0, ...
:msbnetf {out:toolset}
call :dbgprint "Searching from .NET Framework - .NET 4.0, ..."
for %%v in (4.0, 3.5, 2.0) do (
call :rtools %%v Y & if defined Y (
set %1=!Y!
exit /B 0
)
)
call :dbgprint "-netfx: not found"
set "%1="
exit /B 0
:: :msbnetf

The Question is

Some additional processing from our side is possible for both cases above. But I don't think that's important for hMSBuild project because of minimal filter etc.

However, please comment and/or open PR for relevant changes.

@odalet
Copy link

odalet commented Jul 20, 2019

You're right, by now, I know how to 'force' an msbuild version by using -vsw-priority. It's jujst that for newbie users (like I was a few weeks ago), it may not be obvious...

3F added a commit that referenced this issue Jul 20, 2019
* FIXED: Fixed searching from MS BuildTools products. Issue #12 (Thanks @odalet).

* CHANGED: [VS2017+] hMSBuild will search now in ANY available products. PR #13 (Thanks @odalet).

* NOTE: In addition to changes above, please use `-vsw-priority` and `-force` keys to use only what is needed.
        Issues: #8, #14.
3F added a commit that referenced this issue Jan 29, 2020
* NEW: Implemented `-vsw-as "args..."`
       Reassigns default commands to vswhere if used.

       For example:
       ```
       hMSBuild -only-path -vsw-as "-products Microsoft.VisualStudio.Product.BuildTools"
       ```
       Related Issues: #12, #14, #8,

* CHANGED: VS2017+. Using the most modern instance by default.
           You can also specify `-vsw-priority` and `-force` keys to use only what is needed.
           Related Issues: #14, #8.

* CHANGED: Updated wswhere to 2.8.4 by default.

* CHANGED: Updated GetNuTool 1.8
           https://github.com/3F/GetNuTool/releases/tag/1.8

           Most important fix for hMSBuild:
           "The remote server returned an error: (407) Proxy Authentication Required."
           Related issue: 3F/DllExport#133

* NOTE: An compiled.full version now will be distributed together with official hMSBuild releases.
           https://twitter.com/GitHub3F/status/1218224792970715136
           (zip packages) https://github.com/3F/hMSBuild/releases
@3F
Copy link
Owner Author

3F commented Feb 8, 2024

I don't see the point in complicating the logic since hMSBuild already provides keys to explicitly eliminate unnecessary instances. And this is its main behavior, i.e. everything is permitted that is not expressly prohibited. Wrong attempts can also be filtered using ||.

Closed.
Let me know if there's anything wrong with this.

@3F 3F closed this as completed Feb 8, 2024
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

2 participants