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)
install rsync to your WSL env && to your raspberryPi by running :
sudo apt-get install rsync
*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.
sudo sshpass -p $PASSWORD /usr/bin/rsync -avz $PATH_TO_COPY
ssh pi@$RASPBERRY_IP sudo killall dotnet
ssh pi@$RASPBERRY_IP << EOF
sudo dotnet $APP_NAME.dll --urls "http://*:8080"
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 :
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!