To answer to the second part, I use rsync to deploy only the diff to the raspberryPi. I still build all the file since I haven't been able yet to set an incremental build for linux-arm.
Thanks to @Dmitry Grigoryev for the idea
This way we may deploy with a script that takes only 10 seconds instead of 5-10 minutes.
Here are the steps to do it with visual studio community & windows 10:
Install Windows Subsystem for linux (I use Ubuntu, any other linux distribution should work)
Set your user as a super user on your WSL env (Ubuntu):
sudo nano /etc/sudoers.d/myusername
myusername ALL=(ALL) NOPASSWD:ALL
Install sshpass on your WSL env (Ubuntu):
sudo apt-get install sshpass
Generate an ssh key then copy it to your raspberryPi
ssh-keygen (keep all the default directory)
ssh-copy-id pi@RASPBERRY_PI_IP
install rsync to your WSL env && to your raspberryPi by running :
sudo apt-get install rsync
RaspberryPi only
*On Debian, you may have a problem with the rrsync.gz that wont extract so run this command:
sudo sh -c 'zcat /usr/share/doc/rsync/scripts/rrsync.gz > /usr/local/bin/rrsync'
Then make rsync executable by running this command :
sudo chmod a+x /usr/local/bin/rrsync
Then make two bash script to build your app in linux-arm then start wsl to run a deployment script.
Build and trigg wsl to start rsync (trigger.sh)
echo "BUILDING APP..."
dotnet publish -r linux-arm ../MY_APP.sln
start wsl sh Rsync.sh
Since windows is not able to run rsync (didn't find how) we are in the obligation to pass the rsync command to the wsl.
Rsync.sh
PATH_TO_COPY=/mnt/c/DIRECTORY_OF_MY_APP
DESTINATION_PATH=/home/pi/MY_DESTINATION_DIRECTORY
RASPBERRY_IP=MY_RASPBERRY_IP
APP_NAME="MY_APP"
BACKUP_SERVER=pi@$RASPBERRY_IP:
PASSWORD=MY_PASSWORD
sudo sshpass -p $PASSWORD /usr/bin/rsync -avz $PATH_TO_COPY
$BACKUP_SERVER$DESTINATION_PATH
ssh pi@$RASPBERRY_IP sudo killall dotnet
ssh pi@$RASPBERRY_IP << EOF
cd MY_DESTINATION_DIRECTORY/netcoreapp3.1/linux-arm/publish/
sudo dotnet $APP_NAME.dll --urls "http://*:8080"
EOF
Very important : if you plan to make a bash script to run in wsl, I suggest you to use notepadd++ but set the setting like so :
Format: Unix/OSX
Default language: Shell
Encoding: UTF-8 without BOM
Because, windows will put some \r\n everywhere and the bash script will break at runtime. EVEN IF YOU USE NANO IN WSL !!!
Double click on trigger.sh to deploy your diff to your raspberryPI. Now you can save a LOT of time!