Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowsPB : Add Visual Studio 2022 installation #3172

Merged
merged 10 commits into from
Sep 12, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
################################
# Visual Studio Community 2022 #
################################

- name: Test if VS 2022 is installed
win_stat:
path: 'C:\Program Files\Microsoft Visual Studio\2022\Community'
register: vs2022_installed
tags: adoptopenjdk

- name: Transfer VS2022 Layout File
win_copy:
src: /Vendor_Files/windows/vs_layout_2022.zip
dest: C:\TEMP\VS2022_Layout.zip
remote_src: no
when: (not vs2022_installed.stat.exists)
failed_when: false
tags: adoptopenjdk

# Check For The Transferred File & Exit If AdoptOpenJDK Run
- name: Check If Layout Has Transferred
win_stat:
path: 'C:\TEMP\VS2022_Layout.zip'
register: vs2022_layout_ready
tags: adoptopenjdk

- name: Get SHA256 checksum of the file
win_shell: |
$filePath = "C:\TEMP\VS2022_Layout.zip"
$expectedChecksum = "7BEBEF0A67E01FA3DF718D019DE58C47FF24DF1A24CCE3DE5B1DD9E302C04F43"

$actualChecksum = Get-FileHash -Path $filePath -Algorithm SHA256 | Select-Object -ExpandProperty Hash

if ($actualChecksum -ne $expectedChecksum) {
Write-Output "Checksum mismatch"
exit 1
}
register: checksum_result
changed_when: false
tags: adoptopenjdk

# Exit Play If No VS2022 Layout & AdoptOpenJDK = true
# This Is Defined Behaviour - This Shouldnt Occur But If It Does, Its Captured Here
- name: Exit With Error When No Layout Within AdoptOpenJDK
fail:
msg: "The VS2022 Layout File Appears To Be Missing From Vendor_Files"
when: (not vs2022_layout_ready.stat.exists) and (not vs2022_installed.stat.exists)
tags: adoptopenjdk

# Install VS2019 From Layout For AdoptOpenJDK
steelhead31 marked this conversation as resolved.
Show resolved Hide resolved
- name: Unzip VS2022 Layout
win_unzip:
src: C:\TEMP\VS2022_Layout.zip
dest: C:\TEMP
when: (vs2022_layout_ready.stat.exists) and (not vs2022_installed.stat.exists)
tags: adoptopenjdk

- name: Run Visual Studio 2022 Installer From Layout
win_shell: |
Start-Process -Wait -FilePath 'C:\temp\VSLayout2022\vs_community.exe' -ArgumentList '--nocache --quiet --norestart --wait --noweb --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --includeOptional --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.ATL.ARM64 --add Microsoft.VisualStudio.Component.VC.MFC.ARM64'
args:
executable: powershell
when: (vs2022_layout_ready.stat.exists) and (not vs2022_installed.stat.exists)
tags: adoptopenjdk

- name: Remove VS2022 Zip File
win_file:
path: C:\TEMP\VS2022_Layout.zip
state: absent
when: (not vs2022_installed.stat.exists)
tags: adoptopenjdk

- name: Remove VS2022 Unzipped Layout
win_file:
path: C:\temp\VSLayout2022
state: absent
when: (not vs2022_installed.stat.exists)
tags: adoptopenjdk
#
## Check If VS2019 Has Been Installed From Layout Even If Not AdoptOpenJDK
- name: Test if VS 2022 is installed
win_stat:
path: 'C:\Program Files\Microsoft Visual Studio\2022\Community'
register: vs2022_installed

# Download & Install VS2019 When No Layout & Not AdoptOpenJDK
steelhead31 marked this conversation as resolved.
Show resolved Hide resolved
# This is the target that you're redirected to when you go to https://aka.ms/vs/16/release/vs_community.exe
steelhead31 marked this conversation as resolved.
Show resolved Hide resolved
- name: Download Visual Studio Community 2022
win_get_url:
url: 'https://aka.ms/vs/17/release/vs_Community.exe'
checksum: ef3e389f222335676581eddbe7ddec01147969c1d42e19b9dade815c3c0f04b1
checksum_algorithm: sha256
dest: 'C:\temp\vs_community22.exe'
force: no
when: (not vs2022_installed.stat.exists)

- name: Run Visual Studio 2022 Installer From Download
win_shell: |
Start-Process -Wait -FilePath 'C:\temp\vs_community22.exe' -ArgumentList '--wait --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --includeOptional --quiet --norestart'
args:
executable: powershell
when: (not vs2022_installed.stat.exists)
register: vs2022_error
failed_when: vs2022_error.rc != 0 and vs2022_error.rc != 3010

- name: Install ARM64 components
win_shell: Start-Process -FilePath 'C:\temp\vs_community22.exe' -Wait -NoNewWindow -ArgumentList
'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community" --quiet
--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.ATL.ARM64 --add Microsoft.VisualStudio.Component.VC.MFC.ARM64'
when: (not vs2022_installed.stat.exists)

- name: Register Visual Studio Community 2022 DIA SDK shared libraries
win_command: 'regsvr32 /s "{{ item }}"'
with_items:
- C:\Program Files\Microsoft Visual Studio\2022\Community\DIA SDK\bin\msdia140.dll
- C:\Program Files\Microsoft Visual Studio\2022\Community\DIA SDK\bin\amd64\msdia140.dll
when: (not vs2022_installed.stat.exists)

- name: Reboot machine after Visual Studio installation
win_reboot:
reboot_timeout: 1800
shutdown_timeout: 1800
when: (not vs2022_installed.stat.exists)
tags:
- reboot
Loading