Table of contents:
When developing on Windows, I keep a few powershell consoles open (I use conemu) and perform a lot of actions from the command-line. PSDevtools is a set of small command-line functions that I find helpful while working like this.
- Initial version.
- Includes Open-Solution function.
Before installing PSDevtools make sure the following prerequisites have been met.
-
Windows PowerShell 5, 6 or 7
Check your PowerShell version by executing
$PSVersionTable.PSVersion
. -
On Windows, script execution policy must be set to either
RemoteSigned
orUnrestricted
. Check the script execution policy setting by executingGet-ExecutionPolicy
. If the policy is not set to one of the two required values, run PowerShell as Administrator and executeSet-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
.
PSDevtools is available on the PowerShell Gallery and can be installed using the PowerShellGet module.
-
Start Windows PowerShell
-
Execute one of the following two commands from an elevated PowerShell prompt, depending on whether (A) you've never installed PSDevtools, or (B) you've already installed a previous version:
# (A) You've never installed PSDevtools from the PowerShell Gallery # # NOTE: If asked to trust packages from the PowerShell Gallery, answer yes to continue installation of PSDevtools # NOTE: If the AllowPrerelease parameter is not recognized, update your version of PowerShellGet to >= 1.6 e.g. # Install-Module PowerShellGet -Scope CurrentUser -Force -AllowClobber PowerShellGet\Install-Module PSDevtools -Scope CurrentUser -AllowPrerelease -Force
OR
# (B) You've already installed a previous version of PSDevtools from the PowerShell Gallery PowerShellGet\Update-Module PSDevtools
If you need to test/debug changes prior to contributing here, or would otherwise prefer to install PSDevtools without
the aid of a package manager, you can execute Import-Module <path-to-src\PSDevtools.psd1>
. For example, if you
have git cloned PSDevtools to ~\git\PSDevtools
you can import this version of PSDevtools by executing
Import-Module ~\git\PSDevtools\src\PSDevtools.psd1
.
After you have installed PSDevtools, you can use the following functions.
Provided you have associated .sln files with Visual Studio, you can run the command
Open-Solution
or its alias
sln
from within the directory containing the solution file, and the solution will be opened in Visual Studio.
This is supposed to be similar to the Unix command touch
, albeit with less functionality. Used on an existing file, it updates the last access and last modifed dates. Used with the name of a file that doesn't exist, it creates an empty file with that name.
Set-FileDates filename.txt
or using the alias
touch filename.txt