mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-11 03:56:46 +00:00
Merge helpers function from node, boost, python. (#2)
* setup boost helpers * add ci for pull requests * pester for ci * resolving issue with pester 5 * remove Output flag * check tests with 4 version * try common tests variant * added requires * move to 5 version * try to add assert module * fix scope * use new regex for python * fix regex in tests * Pester 4.10.1 * EnableExit * fix synopsys * fix creating tar archive Co-authored-by: Dmitry Shibanov <v-dmshib@microsoft.com> Co-authored-by: Maxim Lobanov <v-malob@microsoft.com>
This commit is contained in:
48
win-vs-env.psm1
Normal file
48
win-vs-env.psm1
Normal file
@@ -0,0 +1,48 @@
|
||||
###
|
||||
# Visual Studio helper functions
|
||||
###
|
||||
|
||||
function Get-VSWhere {
|
||||
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe";
|
||||
|
||||
if (-not (Test-Path $vswhere )) {
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
||||
$vswhere = ".\vswhere.exe"
|
||||
$vswhereApiUri = "https://api.github.com/repos/Microsoft/vswhere/releases/latest"
|
||||
$tag = (Invoke-RestMethod -Uri $vswhereApiUri)[0].tag_name
|
||||
$vswhereUri = "https://github.com/Microsoft/vswhere/releases/download/$tag/vswhere.exe"
|
||||
Invoke-WebRequest -Uri $vswhereUri -OutFile $vswhere | Out-Null
|
||||
}
|
||||
|
||||
return $vswhere
|
||||
}
|
||||
|
||||
function Invoke-Environment
|
||||
{
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[string]
|
||||
$Command
|
||||
)
|
||||
|
||||
& "${env:COMSPEC}" /s /c "`"$Command`" -no_logo && set" | Foreach-Object {
|
||||
if ($_ -match '^([^=]+)=(.*)') {
|
||||
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-VSInstallationPath {
|
||||
$vswhere = Get-VSWhere
|
||||
$installationPath = & $vswhere -prerelease -legacy -latest -property installationPath
|
||||
|
||||
return $installationPath
|
||||
}
|
||||
|
||||
function Invoke-VSDevEnvironment {
|
||||
Write-Host "Invoke-VSDevEnvironment had been invoked"
|
||||
$installationPath = Get-VSInstallationPath
|
||||
$envFilepath = Join-Path $installationPath "Common7\Tools\vsdevcmd.bat"
|
||||
Invoke-Environment -Command $envFilepath
|
||||
}
|
||||
Reference in New Issue
Block a user