Skip to content

Instantly share code, notes, and snippets.

@jrusbatch
Created May 26, 2020 16:41
Show Gist options
  • Save jrusbatch/9816c72fb5164836ff4928b26ea7e7f7 to your computer and use it in GitHub Desktop.
Save jrusbatch/9816c72fb5164836ff4928b26ea7e7f7 to your computer and use it in GitHub Desktop.
function Restore-Packages
{
$nuget = Join-Path $Env:UserProfile 'Tools/nuget.exe'
if (Test-Path $nuget) {
Write-Output "Restoring NuGet packages..."
& $nuget restore -verbosity quiet
}
else {
Write-Output "'$nuget' could not be found."
}
}
function Invoke-MSBuild() {
$path = (& 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -prerelease -products * -requires Microsoft.Component.MSBuild -property installationPath)
$msbuild = Join-Path $path 'MSBuild\Current\Bin\MSBuild.exe'
if (Test-Path $msbuild) {
$stopwatch = [system.diagnostics.stopwatch]::StartNew()
try {
& $msbuild /t:Build /p:RunCodeAnalysis=false /p:MvcBuildViews=false /clp:Verbosity=Minimal`;Summary /m $args /nr:false /bl
}
finally {
Write-Output -InputObject ("`n`nTotal build duration: {0:mm\:ss\.fff}" -f $stopwatch.Elapsed)
}
}
}
New-Alias -Name restore -Value Restore-Packages
New-Alias -Name msbuild -Value Invoke-MSBuild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment