Time to move on with some lessons learned using Visual Studio Code in the Raspberry Pi 4.
One of the first issues you may find working with VSCode in the device is related to file write permissions when you are saving a file.
So, it was a good opportunity for me to learn about files and folder permissions in Linux. I found a great starting article “How to Manage File and Folder Permissions in Linux” (see references), and it allowed me to fix this issue.
My next error was triggered when I try to build my project. Again, it was a permission related error.
/home/pi/dotnet/sdk/2.2.401/Microsoft.Common.CurrentVersion.targets(4195,5): error MSB3021: Unable to copy file "obj/Debug/netcoreapp2.2/dotnethelloworld.dll" to "bin/Debug/netcoreapp2.2/dotnethelloworld.dll". Access to the path is denied. [/home/pi/dotnethelloworld/dotnethelloworld.csproj]
However, this time the fix was not related to file and folder permissions.
One of the solutions I found, was to run VSCode with admin privileges. This is probably one of the worst ideas ever, and you can find tons of articles explaining why this is bad (see references).
Anyways, I decided to give it a try. Of course, it worked. Let me share how.
I run VSCode with the following command, which runs the app in root mode.
sudo code-oss --user-data-dir=/home/pi/dotnethelloworld
The VSCode team is aware of this, so you will find a warning about this scenario
Even so, you can still use VSCode to edit and build C# .Net Core Projects.
And you can run them also
So far, so good. Or maybe not, broken a lot of good practices. I’ll see this as an amazing chance to learn and test new stuff!
Greetings @ Burlington
- How to Manage File and Folder Permissions in Linux https://www.linux.com/tutorials/how-manage-file-and-folder-permissions-linux/
- Ask Ubuntu Why is it bad to log in as root? https://askubuntu.com/questions/16178/why-is-it-bad-to-log-in-as-root
- GitHub –user-data-dir incorrect help https://github.com/Microsoft/vscode/issues/41429
My posts on Raspberry Pi ⚡🐲⚡
Dev posts for Raspberry Pi
- How to grant permissions to a folder after git clone, to perform dotnet restore on a Raspberry Pi
- How to install .Net Core 3.1 in a Raspberry Pi 4
- Installing Visual Studio Code in a Raspberry Pi 4, run as root, fix black screen
- How to install .Net Core in a Raspberry Pi 4 and test with Hello World
- Build and Run C# NetCore projects in a Raspberry Pi 4 with Visual Studio Code
- Let’s do some Git dev in Raspberry Pi 4 (GitHub and Azure DevOps!)
- Install OpenCV
- Install Python 🐍 Virtual Environments in Raspberry Pi
- Setup SSH passwordless access to remote work with Docker 🐳
- Manage Docker 🐳 as a non-root user
- Build Docker 🐳 images from Visual Studio Code remotely using a Raspberry Pi
Tools and Apps for Raspberry Pi
- Where is my Task Manager in RaspberryPi? Let’s try htop
- Multi-monitor 📺 in Raspberry Pi 4 rocks !
- Double Commander on RaspberryPi4, because files are important
- How to install Docker 🐳 in a Raspberry Pi 4
- Installing Visual Studio Code in a Raspberry Pi
- Installing Visual Studio Code in a Raspberry Pi, run as root, fix black screen (Updated)
- 6 commands to install OpenCV for Python 🐍 in a Raspberry Pi 4
Setup the device
- 1st Setup without monitor 📺: auto connect to WiFi 📶, enable SSH, update and more
- Setup without monitor: enable VNC
- How to enable auto start with HDMI safe mode
- Running a Python 🐍 script in a Python Virtual Environment on reboot / startup
- Setup Wifi on Ubuntu