Visual Studio Code Install

New Contributor II

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.


tmpDir=$(/usr/bin/mktemp -d "/tmp/VSCode-install.XXXXXX") 
/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
/bin/sleep 5
mv "${tmpDir}/Visual Studio" "/Applications/Visual Studio"
/bin/echo "`date`: Deleting package installer." >> ${logfile}
rm -rf "${tmpDir}"
#Bless VS Code
xattr -rc "/Applications/Visual Studio"
exit 0

Contributor III

You might consider adding a `codesign` check to verify that your download is authentic:

/usr/bin/codesign -dvv /path/to/Visual\ Studio\

# expected values:
# Developer ID Application: Microsoft Corporation (UBF8T346G9)
# TeamIdentifier=UBF8T346G9

New Contributor II

thanks Ill check it out!

Valued Contributor

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!


Valued Contributor

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. 

Screenshot 2023-10-11 at 3.52.28 PM.pngScreenshot 2023-10-11 at 3.52.37 PM.png

New Contributor II

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.