Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplified script
  • Loading branch information
mguludag authored Jul 6, 2022
commit e4f612cdfd7fd7126259627f2f080538b2326ac9
107 changes: 43 additions & 64 deletions windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,11 @@
Set-ExecutionPolicy Bypass -scope Process -Force

# for admin privileges if isn't running as an admin
if (!
#current role
(New-Object Security.Principal.WindowsPrincipal(
[Security.Principal.WindowsIdentity]::GetCurrent()
#is admin?
)).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)
) {
#elevate script and exit current non-elevated runtime
Start-Process `
-FilePath 'powershell' `
-ArgumentList (
#flatten to single array
'-File', $MyInvocation.MyCommand.Source, $args `
| %{ $_ }
) `
-Verb RunAs
exit
if (!(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
#elevate script and exit current non-elevated runtime
Start-Process -FilePath 'powershell' -ArgumentList ('-File', $MyInvocation.MyCommand.Source, $args | %{ $_ }) -Verb RunAs
exit
}

$choice = Read-Host "Press enter to install C++ related tools, ctrl-c to cancel"
Expand All @@ -42,24 +28,24 @@ else
Write-Host "Build $buildNum is OK"
}


$cmdName = "winget"
$vclibPath = "$pwd/Microsoft.VCLibs.x64.14.00.Desktop.appx"
$wingetPath = "$pwd/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"

if (!(Get-Command $cmdName -errorAction SilentlyContinue))
{
Write-Error "$cmdName not exists"
Write-Error "$cmdName not exists"
Write-Host "Downloading $cmdName"
Out-File -FilePath "$pwd/.winget"
Import-Module BitsTransfer
Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Destination "$pwd/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
Start-BitsTransfer -Source "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx" -Destination "$pwd/Microsoft.VCLibs.x64.14.00.Desktop.appx"
Add-AppxPackage -Path "$pwd/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -DependencyPath "$pwd/Microsoft.VCLibs.x64.14.00.Desktop.appx"
$parameters = @{ ScriptBlock = { & "powershell.exe" $args[0] $args[1] }
ArgumentList = "$pwd/windows.ps1" }

Invoke-Command @parameters -NoNewScope
}
else
{
Write-Host "$cmdName found OK"
Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Destination $wingetPath
Start-BitsTransfer -Source "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx" -Destination $vclibPath
Write-Host "Installing $cmdName"
Add-AppxPackage -Path $wingetPath -DependencyPath $vclibPath

# cleanup winget setup files
Remove-Item $vclibPath
Remove-Item $wingetPath
}


Expand All @@ -68,48 +54,41 @@ winget install Git.git --silent --accept-package-agreements --accept-source-agre
winget install python3 --silent --accept-package-agreements --accept-source-agreements
winget install cppcheck --silent --accept-package-agreements --accept-source-agreements


$vsconfig = "{
`"version`": `"1.0`",`
`"components`": [
`"Microsoft.VisualStudio.Component.Roslyn.Compiler`",`
`"Microsoft.Component.MSBuild`",`
`"Microsoft.VisualStudio.Component.CoreBuildTools`",`
`"Microsoft.VisualStudio.Workload.MSBuildTools`",`
`"Microsoft.VisualStudio.Component.Windows10SDK`",`
`"Microsoft.VisualStudio.Component.VC.CoreBuildTools`",`
`"Microsoft.VisualStudio.Component.VC.Tools.x86.x64`",`
`"Microsoft.VisualStudio.Component.VC.Redist.14.Latest`",`
`"Microsoft.VisualStudio.Component.Windows10SDK.19041`",`
`"Microsoft.VisualStudio.Component.VC.CMake.Project`",`
`"Microsoft.VisualStudio.Component.TestTools.BuildTools`",`
`"Microsoft.VisualStudio.Component.VC.ATL`",`
`"Microsoft.VisualStudio.Component.VC.ASAN`",`
`"Microsoft.VisualStudio.Component.VC.Modules.x86.x64`",`
`"Microsoft.VisualStudio.Component.TextTemplating`",`
`"Microsoft.VisualStudio.Component.VC.CoreIde`",`
`"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core`",`
`"Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset`",`
`"Microsoft.VisualStudio.Workload.VCTools`"`
`"Microsoft.VisualStudio.Component.Roslyn.Compiler`",`
`"Microsoft.Component.MSBuild`",`
`"Microsoft.VisualStudio.Component.CoreBuildTools`",`
`"Microsoft.VisualStudio.Workload.MSBuildTools`",`
`"Microsoft.VisualStudio.Component.Windows10SDK`",`
`"Microsoft.VisualStudio.Component.VC.CoreBuildTools`",`
`"Microsoft.VisualStudio.Component.VC.Tools.x86.x64`",`
`"Microsoft.VisualStudio.Component.VC.Redist.14.Latest`",`
`"Microsoft.VisualStudio.Component.Windows10SDK.19041`",`
`"Microsoft.VisualStudio.Component.VC.CMake.Project`",`
`"Microsoft.VisualStudio.Component.TestTools.BuildTools`",`
`"Microsoft.VisualStudio.Component.VC.ATL`",`
`"Microsoft.VisualStudio.Component.VC.ASAN`",`
`"Microsoft.VisualStudio.Component.VC.Modules.x86.x64`",`
`"Microsoft.VisualStudio.Component.TextTemplating`",`
`"Microsoft.VisualStudio.Component.VC.CoreIde`",`
`"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core`",`
`"Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset`",`
`"Microsoft.VisualStudio.Workload.VCTools`"`
]
}"

Out-File -FilePath $pwd/.vsconfig -InputObject $vsconfig

winget install "Visual Studio Build Tools 2022" --silent --accept-package-agreements --override "--config $pwd/.vsconfig --installPath C:/VS2022-BuildTools --quiet --wait"

$Env:PATH+=";$env:localappdata/Programs/Microsoft` VS` Code"
Remove-Item "$pwd/.vsconfig"

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")

$parameters = @{
ScriptBlock = { & "powershell.exe" $args[0] $args[1] }
ArgumentList = "code --install-extension ms-vscode.cpptools-extension-pack --install-extension jeff-hykin.better-cpp-syntax --install-extension eamodio.gitlens --install-extension jdinhlife.gruvbox --install-extension xaver.clang-format"
}

Invoke-Command @parameters -NoNewScope
code --install-extension ms-vscode.cpptools-extension-pack --install-extension jeff-hykin.better-cpp-syntax --install-extension eamodio.gitlens --install-extension jdinhlife.gruvbox --install-extension xaver.clang-format

$parameters = @{
ScriptBlock = { & "powershell.exe" $args[0] $args[1] }
ArgumentList = "pip install --user conan ninja cmake"
}
pip install --user conan ninja cmake

Invoke-Command @parameters -NoNewScope
exit