Last active
March 20, 2023 00:02
-
-
Save KZeronimo/e083537a255355b6090ae71a61cd0820 to your computer and use it in GitHub Desktop.
Winget based Boxstarter Script - Bootstrap - Win 10,11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set TLS 1.2 | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
# Import Choco Install-* | |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force | |
# Set up choco cache location to work around Boxstarter Issue 241 | |
$chocoCache = (Join-Path ([Environment]::GetEnvironmentVariable("LocalAppData")) "Temp\ChocoCache") | |
New-Item -Path $chocoCache -ItemType directory -Force | |
# Remove *.tmp from the choco cache directory so the ad-hoc package installs using Install-ChocolateyPackage behave idempotently - this is a hack | |
Remove-Item -Path (Join-Path $chocoCache '*.tmp') -Recurse -Force | |
# Get Post Build Content | |
Write-BoxstarterMessage "Getting post build content" | |
$path = "C:\_PostBuildContent" | |
$answersPath = "C:\Windows\Temp\User_Answers.json" | |
if (Test-Path -Path $path) { | |
Remove-Item -Path $path -Recurse | |
} | |
Invoke-WebRequest -UseBasicParsing https://github.com/KZeronimo/PostBuildContent/archive/refs/heads/master.zip -OutFile C:\PostBuildContent.zip | |
Expand-Archive -Path C:\PostBuildContent.zip -DestinationPath $path | |
Move-Item (Join-Path $path 'PostBuildContent-master\*') $path | |
if (Test-Path $answersPath) { | |
Copy-Item $answersPath -Destination (Join-Path $path 'User_Answers.json') | |
} | |
Remove-Item -Path (Join-Path $path 'PostBuildContent-master') | |
Remove-Item -Path C:\PostBuildContent.zip | |
# Configure Windows Explorer Options | |
Set-WindowsExplorerOptions -EnableShowFileExtensions -EnableShowHiddenFilesFoldersDrives -EnableShowFullPathInTitleBar | |
# Trust PSGallery | |
Get-PackageProvider -Name NuGet -ForceBootstrap | |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
# Install Source Code Pro and Nerd Fonts | |
Write-BoxstarterMessage "Installing Source Code Pro and Source Code Pro Nerd Fonts" | |
cinst sourcecodepro --cacheLocation $chocoCache | |
cinst nerd-fonts-sourcecodepro --cacheLocation $chocoCache | |
# Install Cascadia Code Nerd Font | |
Write-BoxstarterMessage "Installing Cascadia Code Nerd & PL Font" | |
cinst nerd-fonts-cascadiacode --cacheLocation $chocoCache | |
$latestBrowserDownloadUrl = Invoke-WebRequest -UseBasicParsing -Uri "https://api.github.com/repos/microsoft/cascadia-code/releases/latest" | ConvertFrom-Json | Select-Object -ExpandProperty assets | Select-Object -ExpandProperty browser_download_url | Where-Object { $_ -match '.*\/[^\/]*OTF[^\/]*\.zip$|.*\/[^\/]*\.zip$' } | Select-Object -First 1 | |
& C:\_PostBuildContent\helpers\install-font.ps1 -Url $latestBrowserDownloadUrl -FontFilesFilter '*.otf' | |
# Install oh-my-posh | |
Write-BoxstarterMessage "Installing posh-git and oh-my-posh" | |
Install-Module -Name posh-git -Scope CurrentUser | |
winget install JanDeDobbeleer.OhMyPosh --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install PowerShell Core | |
Write-BoxstarterMessage "Installing PowerShell Core" | |
winget install Microsoft.PowerShell --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Git (core credential mgr intalled with git for windows) | |
Write-BoxstarterMessage "Installing Git" | |
winget install Git.Git --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Window Terminal | |
Write-BoxstarterMessage "Installing Windows Terminal" | |
winget install 9N0DX20HK701 --source msstore --silent --accept-source-agreements --accept-package-agreements | |
# Install Visual Studio Code | |
Write-BoxstarterMessage "Installing VS Code" | |
winget install Microsoft.VisualStudioCode --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Notepad++ | |
Write-BoxstarterMessage "Installing Notepad++" | |
winget install Notepad++.Notepad++ --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Google Chrome | |
Write-BoxstarterMessage "Installing Chrome" | |
winget install Google.Chrome --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Refresh Environment | |
Write-BoxstarterMessage "Refresh Environment" | |
refreshenv | |
# Create root folder structure | |
Write-BoxstarterMessage "Creating root folder structure" | |
New-Item -Path "C:\_Src" -Type Directory -Force | |
New-Item -Path "C:\_Src\Prod" -Type Directory -Force | |
New-Item -Path "C:\_Src\Prod\Mesh" -Type Directory -Force | |
New-Item -Path "C:\_Src\Sdbx" -Type Directory -Force | |
# Remove Desktop Shortcuts | |
Write-BoxstarterMessage "Removing desktop shortcuts" | |
Get-ChildItem -Path "C:\Users\*\Desktop\*" -Recurse -Include *.lnk | Remove-Item -Force | |
# Deploy post build content | |
Write-BoxstarterMessage "Deploying post build content" | |
if (! (Test-Path -Path (Join-Path $env:UserProfile ".gitconfig"))) { | |
Copy-Item "C:\_PostBuildContent\git\.gitconfig" -Destination $env:UserProfile -Force | |
} | |
Copy-Item "C:\_PostBuildContent\terminal\Microsoft.PowerShell_profile.ps1" -Destination (New-Item (Join-Path $env:UserProfile "Documents\WindowsPowerShell") -Type container -Force) -Force | |
Copy-Item "C:\_PostBuildContent\terminal\Microsoft.PowerShell_profile.ps1" -Destination (New-Item (Join-Path $env:UserProfile "Documents\PowerShell") -Type container -Force) -Force | |
Copy-Item "C:\_PostBuildContent\terminal\wt_profiles_settings.json" -Destination (Join-Path $env:LocalAppData "Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json") -Force | |
Copy-Item "C:\_PostBuildContent\terminal\agnoster-mesh.omp.json" -Destination (Join-Path $env:LocalAppData "Programs\oh-my-posh\themes\agnoster-mesh.omp.json") -Force | |
Copy-Item -Path "C:\_PostBuildContent\themes\*" -Destination (New-Item (Join-Path $env:UserProfile "Pictures\Themes") -Type container -Force) -Recurse -Force | |
Copy-Item -Path "C:\_PostBuildContent\layouts\*" -Destination $env:LocalAppData -Recurse -Force | |
# Configure my .gitconfig | |
Write-BoxstarterMessage "Customizing gitconfig" | |
& C:\_PostBuildContent\git\configure-my-gitconfig.ps1 | |
# Setup configuration and dotfile tracking | |
$path = Join-Path $env:UserProfile ".myconf" | |
New-Item -Path ($path) -Type Directory -Force | |
Set-Location -Path $path | |
if (! (Test-Path -Path "HEAD")) { | |
Write-BoxstarterMessage "Setting up configuration and dotfile tracking" | |
git init --bare $path | |
Write-Output '*' >> $env:UserProfile/.myconf/info/exclude | |
} | |
# Clone OneFlow Repo | |
Set-Location -Path C:\_Src\Prod\Mesh | |
$path = "https://meshsystems@dev.azure.com/meshsystems/Mesh%20Systems/_git/Mesh.DevAutomation.OneFlow" | |
if (! (Test-Path -Path ($path -split '/')[-1])) { | |
Write-BoxstarterMessage "Cloning OneFlow repo" | |
git clone $path | |
} | |
# Clone DotNet Templates Repo | |
Set-Location -Path C:\_Src\Prod\Mesh | |
$path = "https://meshsystems@dev.azure.com/meshsystems/Mesh%20Systems/_git/Mesh.DotNet.Templates" | |
if (! (Test-Path -Path ($path -split '/')[-1])) { | |
Write-BoxstarterMessage "Cloning DotNet Templates repo" | |
git clone $path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment