posh-vsdev.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
if (Get-Module posh-vsdev) { return; }

. $PSScriptRoot/posh-vsdev.ps1;

# Reset the environment when the module is removed
$ExecutionContext.SessionState.Module.OnRemove = {
    Reset-VisualStudioEnvironment;
};

# Aliases
@{
    # Backwards compatibility
    "Get-VisualStudioVersion" = "Get-VisualStudioInstance";
    "Reset-VisualStudioVersionCache" = "Reset-VisualStudioInstanceCache";

    # Shortcuts
    "Get-VSInstance" = "Get-VisualStudioInstance";
    "Get-VS" = "Get-VisualStudioInstance";
    "Use-VSEnvironment" = "Use-VisualStudioEnvironment";
    "Use-VS" = "Use-VisualStudioEnvironment";
    "Reset-VSEnvironment" = "Reset-VisualStudioEnvironment";
    "Reset-VSInstanceCache" = "Reset-VisualStudioInstanceCache";
}.GetEnumerator() | ForEach-Object { Set-Alias $_.Key $_.Value; };

# Export members
Export-ModuleMember `
    -Function:(
        'Get-VisualStudioInstance',
        'Use-VisualStudioEnvironment',
        'Reset-VisualStudioEnvironment',
        'Reset-VisualStudioInstanceCache',
        'Add-VisualStudioEnvironmentToProfile',
        'Get-WindowsSdk'
    ) `
    -Variable:(
        'VisualStudioVersion'
    ) `
    -Alias:(
        'Get-VisualStudioVersion',
        'Reset-VisualStudioVersionCache',
        'Get-VSInstance',
        'Get-VS',
        'Use-VSEnvironment',
        'Use-VS',
        'Reset-VSEnvironment',
        'Reset-VSInstanceCache'
    );