webmaster442 / ultimatedotnetcheatsheet

The ultimate .NET cheat sheet
https://webmaster442.github.io/ultimatedotnetcheatsheet/
Creative Commons Attribution Share Alike 4.0 International
18 stars 5 forks source link

Powershell commands for development #11

Closed webmaster442 closed 5 months ago

webmaster442 commented 6 months ago
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
function RemoveBinObj  {
    $directories = Get-ChildItem -Directory -Recurse | Where-Object { $_.Name -eq "bin" -or $_.Name -eq "obj" }
    foreach ($directory in $directories) {
        Write-Host "Deleting $($directory.FullName)" -ForegroundColor Yellow
        Remove-Item $directory.FullName -Recurse -Force
    }
    Write-Host "Cleanup complete!" -ForegroundColor Green
}

RemoveBinObj
  1. Make sure that profile exists:
if (!(Test-Path -Path $PROFILE)) {
  New-Item -ItemType File -Path $PROFILE -Force
}
  1. Open for editing:
notepad $PROFILE
  1. Add the following code:
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)
        dotnet complete --position $cursorPosition "$commandAst" | ForEach-Object {
            [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
        }
}