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

Need to modify UTILS.PSM1 to allow for VS 2022 builds. #29

Open
kpff-sanderson opened this issue Dec 1, 2023 · 2 comments
Open

Need to modify UTILS.PSM1 to allow for VS 2022 builds. #29

kpff-sanderson opened this issue Dec 1, 2023 · 2 comments

Comments

@kpff-sanderson
Copy link

kpff-sanderson commented Dec 1, 2023

I modified the file 'utils.psm1' in the 'ps_modules' folder to allow for builds on VS2022. See comments in code below:

#Get-VSPath new code
function Get-VSPath {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$Version)
    BEGIN { Import-Module -Name $PSScriptRoot\VSSetup\Microsoft.VisualStudio.Setup.PowerShell.dll }
    PROCESS {
        Trace-VstsEnteringInvocation $MyInvocation
        try {
	     ##Added this section to cover VS2022
	    if ($Version -eq "17.0" -and
                ($instance = Get-VSSetupInstance | Select-VSSetupInstance -Version '[17.0,)') -and
                $instance.installationPath) {
				Write-Verbose "Using v17.0 path: $instance.installationPath"
                return $instance.installationPath
            }
            ##Added above section to cover VS2022

            if ($Version -eq "16.0" -and
                ($instance = Get-VSSetupInstance | Select-VSSetupInstance -Version '[16.0,)') -and
                $instance.installationPath) {
				Write-Verbose "Using v16.0 path: $instance.installationPath"
                return $instance.installationPath
            }
            
            # Search for a 15.0 Willow instance.
            #Modified the '-Version' argument from '[15.0,16.0,)' to '[15.0,)' to prevent duplicates.
            if ($Version -eq "15.0" -and
                ($instance = Get-VSSetupInstance | Select-VSSetupInstance -Version '[15.0,)') -and
                $instance.installationPath) {
				Write-Verbose "Using v15.0 path: $instance.installationPath"
                return $instance.installationPath
            }

            # Fallback to searching for an older install.
            if ($path = (Get-ItemProperty -LiteralPath "HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\$Version" -Name 'ShellFolder' -ErrorAction Ignore).ShellFolder) {
				Write-Verbose "Using fallback path: $path"
                return $path
            }
        }
        finally {
            Trace-VstsLeavingInvocation $MyInvocation
        }
    }
    END { }
}
@mmajcica
Copy link
Owner

mmajcica commented Dec 2, 2023

Can you make a PR out of it so that I can package it and redeploy?

@kpff-sanderson
Copy link
Author

kpff-sanderson commented Dec 4, 2023

I've created it here: #33

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