Since .NET Core is out I've been using more and more the command line as way of working and in general I'm using a lot PowerShell.
Whilst Visual Studio Code is very command line friendly, it can't be said the same for its big brother.
To improve the situation I have added the following to my $PROFILE file.
function Execute-VisualStudioAsAdmin
{
if ($args.Count -gt 0)
{
Start-Process "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" $args -Verb RunAs
}
else
{
Start-Process "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" -Verb RunAs
}
}
Set-Alias vsa Execute-VisualStudioAsAdmin -Option ReadOnly
Set-Alias vs "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" -Option ReadOnly
Now I can do
PS> vs
PS> vsa
PS> vs .\Solution.sln
PS> vsa .\Solution.sln
Everything works as expected but it's not as good as I would like. Maybe I'm overthinking it, but I wonder if there is a way to create a better function and have both aliases using it by passing different parameters.
Thanks in advance!