2021/03/29
I noticed I executed this command quite often:
PS D:\runtime> .\build.cmd -vs .\src\coreclr\System.Private.CoreLib\System.Private.CoreLib.sln
The command opens the System.Private.CoreLib solution in Visual Studio with the proper environment set so that Intellisense and symbols work well.
Instead of type that long string, I want to type the 3 letter command below, I want it to be independent from where I run it, and I want it to be permanent:
PS C:\other\location> spc
First, I need to create a function that executes the command:
PS D:\> function Open-SPCSln { D:\runtime\build.cmd -vs D:\runtime\src\coreclr\System.Private.CoreLib\System.Private.CoreLib.sln }
Second, I need to create an alias that invokes that function:
PS D:\> Set-Alias -Name spc -Value Open-SPCSln
Third, I test it:
PS D:\> spc
If it works well, then I add both the function and the alias at the end of my profile file:
PS D:\> notepad $PROFILE
After saving the file, I can now open any PowerShell window, invoke spc
and it will open the solution in VS.