graalvm / setup-graalvm

GitHub Action for setting up GraalVM distributions.
https://www.graalvm.org
Universal Permissive License v1.0
192 stars 27 forks source link

Add vs2022 build tools path to KNOWN_VISUAL_STUDIO_INSTALLATIONS for self-hosted runner #29

Closed acktsap closed 1 year ago

acktsap commented 1 year ago

Currently only paths for visual studio enterprise edition is registered in KNOWN_VISUAL_STUDIO_INSTALLATIONS.

https://github.com/graalvm/setup-graalvm/blob/cb74ef5a33ed1dff1f7661c5a2ed0fc097dba5d5/src/msvc.ts#L6-L10

I'm using self-hosted runner for windows. But doesn't have Visual Studio Enterprise license. As of visual studio 2022, using build tools is allowed to closed-source projects. So i've installed but failed to run graalvm action since path is fixed.

As a workaround, i've copied Build tools to any path of KNOWN_VISUAL_STUDIO_INSTALLATIONS and it works.

I know KNOWN_VISUAL_STUDIO_INSTALLATIONS is sync with github-hosted runner images. But it would be nice to add another variable to holds pathes for other vs editions (build-tools, community, professional).

fniephaus commented 1 year ago

Hi @acktsap, thanks for bringing this to our attention. How would you suggest should we add support for your use case? Is there a canonical way to specify the installation directory for Visual Studio? Or would it be enough to check for Enterprise and Community sub-directories?

fniephaus commented 1 year ago

Mh, maybe we should use vswhere.exe?

acktsap commented 1 year ago

Thanks for reply!

How would you suggest should we add support for your use case?

At first i thought it's enough to search Community, Professional, Build Tools directory.

But it's nice to search special environment variable like GRAALVM_ACTION_VS_PATH (eg. GRAALVM_ACTION_VS_PATH='C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools')\

Maybe logic would be

  1. If no GRAALVM_ACTION_VS_PATH, then search KNOWN_VISUAL_STUDIO_INSTALLATIONS. KNOWN_VISUAL_STUDIO_INSTALLATIONS includes all Visual Studio editions like Enterprise, Community, BuildTools, Professional, ...)
  2. If GRAALVM_ACTION_VS_PATH is set, search with it.

Mh, maybe we should use vswhere.exe?

It looks nice but i think it's a little bit complicated then just setting environment variable.

theotherp commented 1 year ago

I have only community and just added a symbolic link to the community folder, so in my case I made c:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\ link to c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\.

fniephaus commented 1 year ago

I've adjusted the search so that it checks the VSINSTALLDIR environment variable, which is apparently usually used to reference the Visual Studio installation directory. This should be enough for your use case.

If anyone thinks we should expand the search so that it also checks \Community and other directories by default, please let us know!

acktsap commented 1 year ago

Hi i registered VSINSTALLDIR as BuildTools path (C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools) and it finds vcvarsall.bat correctly. But it fails to run nativeCompile task (gradle task) printing it cannot find cl.exe in a path.

Screen Shot 2022-12-26 at 5 12 28 PM

But it works correctly when coping C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools to C:\Program Files\Microsoft Visual Studio\2022\Enterprise.

So i looked around the parameter and found graalvm pathes are different.

VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools

Path:

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildToolsMSBuild\Current\bin\Roslyn
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\

Make a copy of C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools to C:\Program Files\Microsoft Visual Studio\2022\Enterprise

Path:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\VCPackages
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\Roslyn
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\\MSBuild\Current\Bin\amd64
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe

So i got back to the workaround :(