Skip to content

Commit f585de7

Browse files
committed
Bump version. Minor fixes.
* Clarify where values for the Product argument can be obtained from. * Fix `ExcludePrerelease` is ignored by `Get-VisualStudio` * Fix whitespace * Add help annotations for `Start-VisualStudio` * Bump version to 0.4.0
1 parent 49567e9 commit f585de7

File tree

5 files changed

+44
-13
lines changed

5 files changed

+44
-13
lines changed

Modules/VisualStudioShell/Enter-VisualStudioShell.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ using module VSSetup
4545
Suppress printing of the developer command prompt banner.
4646
4747
.Parameter Product
48-
One or more products to select. Wildcards are supported.
48+
One or more products to select. Wildcards are supported. (Passed through to Select-VSSetupInstance)
49+
50+
Run `Get-VSSetupInstance | Select-Object Product` to obtain a list of available valid values albeit with a version number.
4951
5052
.Parameter StartDirectoryMode
5153
The startup directory mode.

Modules/VisualStudioShell/Get-VisualStudio.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ using module VSSetup
88
Do not allow selection of Preview versions of Visual Studio. (Passed through negated to Get-VSSetupInstance)
99
1010
.Parameter Product
11-
One or more products to select. Wildcards are supported.
11+
One or more products to select. Wildcards are supported. (Passed through to Select-VSSetupInstance)
12+
13+
Run `Get-VSSetupInstance | Select-Object Product` to obtain a list of available valid values albeit with a version number.
1214
#>
1315
function Get-VisualStudio {
1416
[CmdLetBinding()]
@@ -21,13 +23,13 @@ function Get-VisualStudio {
2123
$VS = $null
2224
if ($null -eq $Product) {
2325
$VS =
24-
Get-VSSetupInstance -Prerelease:$(-not $Prerelease.IsPresent) |
26+
Get-VSSetupInstance -Prerelease:$(-not $ExcludePrerelease.IsPresent) |
2527
Select-VSSetupInstance -Latest |
2628
Sort-Object -Property InstallationVersion |
2729
Select-Object -Last 1
2830
} else {
2931
$VS =
30-
Get-VSSetupInstance -Prerelease:$(-not $Prerelease.IsPresent) |
32+
Get-VSSetupInstance -Prerelease:$(-not $ExcludePrerelease.IsPresent) |
3133
Select-VSSetupInstance -Latest -Product:$Product |
3234
Sort-Object -Property InstallationVersion |
3335
Select-Object -Last 1

Modules/VisualStudioShell/Import-VisualStudioShellModule.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ function Import-VisualStudioShellModule {
3131
}
3232
function ThrowIfModuleNotFound([string]$ModulePath) {
3333
throw [ErrorRecord]::new(
34-
[System.Exception]::new("Required assembly could not be located. This most likely indicates an installation error. Try repairing your Visual Studio installation. Expected location: $modulePath"),
35-
"DevShellModuleLoad",
36-
[ErrorCategory]::NotInstalled,
34+
[System.Exception]::new("Required assembly could not be located. This most likely indicates an installation error. Try repairing your Visual Studio installation. Expected location: $modulePath"),
35+
"DevShellModuleLoad",
36+
[ErrorCategory]::NotInstalled,
3737
$VisualStudio)
3838
}
3939
# Developer PowerShell for VS 2019 Preview

Modules/VisualStudioShell/Start-VisualStudio.ps1

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
#Requires -Module VSSetup
22
using module VSSetup
3+
<#
4+
.Synopsis
5+
Starts Common7\IDE\devenv.exe in the installation path for the Visual Studio setup instance
6+
provided explicitly, or if none was provided, the one selected running Get-VisualStudio.
7+
8+
.Parameter FileOrFolder
9+
The file or folder path to pass as the first argument to devenv.exe. The default is none.
10+
11+
.Parameter StartInPath
12+
The working directory for devenv.exe. Defaults to the current working directory.
13+
14+
.Parameter ExcludePrerelease
15+
Do not allow selection of Preview versions of Visual Studio. (Passed through negated to Get-VSSetupInstance)
16+
17+
.Parameter VisualStudio
18+
A setup instance obtained from the VSSetup PowerShell module.
19+
20+
.Parameter RemainingArguments
21+
Any arguments that will be provided unmodified to devenv.exe.
22+
#>
323
function Start-VisualStudio {
424
[CmdLetBinding(
525
SupportsShouldProcess = $true,
@@ -13,19 +33,26 @@ function Start-VisualStudio {
1333

1434
[switch]$Force = [switch]::new($false),
1535

36+
[Parameter(ParameterSetName='select')]
1637
[switch]$ExcludePrerelease = [switch]::new($false),
1738

39+
[Parameter(ParameterSetName='instance')]
1840
[Microsoft.VisualStudio.Setup.Instance]$VisualStudio = $null,
1941

2042
[Parameter(ValueFromRemainingArguments = $true)]
2143
[object[]]$RemainingArguments = $null
2244
)
2345
Process {
24-
if ($null -eq $VisualStudio) {
25-
$VisualStudio = Get-VisualStudio -ExcludePrerelease:($ExcludePrerelease.IsPresent)
26-
} elseif (-not (Confirm-VisualStudio $VisualStudio)) {
27-
Write-Error "The Visual Studio parameter is not valid. Remove the parameter or specify a valid value."
28-
return;
46+
switch ($PSCmdLet.ParameterSetName) {
47+
'instance' {
48+
if (-not (Confirm-VisualStudio $VisualStudio)) {
49+
Write-Error "The Visual Studio parameter is not valid. Remove the parameter or specify a valid value."
50+
return;
51+
}
52+
}
53+
default {
54+
$VisualStudio = Get-VisualStudio -ExcludePrerelease:($ExcludePrerelease.IsPresent) -Product:$Product
55+
}
2956
}
3057
if (-not (Import-VisualStudioShellModule -VisualStudio $VisualStudio)) {
3158
Write-Error "Could not load the Visual Studio Shell module."

Modules/VisualStudioShell/VisualStudioShell.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
@{
88
RootModule = 'VisualStudioShell.psm1'
9-
ModuleVersion = '0.3.1'
9+
ModuleVersion = '0.4.0'
1010
GUID = '5ca15b3d-9366-45d7-b366-2a9c1d2bcd25'
1111
Author = 'Eric'
1212
CompanyName = 'Eric'

0 commit comments

Comments
 (0)