Posted on 10-11-2023 12:08 PM
Just putting this out to share since deploying software via Jamf apps have been very flakey for me lately. I am by no means a scripting expert so feel free to make changes or offer any refinement, so far it does what I want it to do, downloads the universal zip file for VS Code, Unzips it, moves it to Applications, trusts the app, and then deletes the install folder for the secure temp folder.
#!/bin/sh
pkgfile="VSCode-darwin-universal.zip"
tmpDir=$(/usr/bin/mktemp -d "/tmp/VSCode-install.XXXXXX")
logfile="/Library/Logs/VSCodeInstallScript.log"
url='
https://code.visualstudio.com/sha/download?build=stable&os=darwin-universal'
/bin/echo "--" >> ${logfile}
/bin/echo "`date`: Downloading latest version." >> ${logfile}
/usr/bin/curl -L -o ${tmpDir}/${pkgfile} ${url}
/bin/echo "`date`: Installing..." >> ${logfile}
cd ${tmpDir}
tar xvfz VSCode-darwin-universal.zip
/bin/sleep 5
mv "${tmpDir}/Visual Studio Code.app" "/Applications/Visual Studio Code.app"
/bin/echo "`date`: Deleting package installer." >> ${logfile}
rm -rf "${tmpDir}"
#Bless VS Code
xattr -rc "/Applications/Visual Studio Code.app"
exit 0
Posted on 10-11-2023 12:55 PM
You might consider adding a `codesign` check to verify that your download is authentic:
/usr/bin/codesign -dvv /path/to/Visual\ Studio\ Code.app
# expected values:
#
# Developer ID Application: Microsoft Corporation (UBF8T346G9)
# TeamIdentifier=UBF8T346G9
Posted on 10-11-2023 01:50 PM
thanks Ill check it out!
Posted on 10-11-2023 01:48 PM
I have seen that after the Visual Studio Code was updated it fails to open, as of recent.
I will test your script and get back to you on the effectiveness.
Thank you!
Posted on 10-11-2023 02:21 PM
Initially, I received these when testing your script, see screenshots. I then simply added a line to the script to remove before installation and all went well. After that, I removed the line and tried again and all was ok. I think I am still going with MacApps as the issue with Visual Studio Code seems to be resolved for us.
Posted on 10-11-2023 02:25 PM
I had one similar to this last week with Xcode, for some reason it was showing as installed in my ~/Applications folder which was weird and had to manually uninstall it. I still cant find an approved process from my security team to deploy Xcode because my users refuse to be on the current version at any time, and also not allow local admin rights.