1

I use .netCore 3.1 and Raspbian buster.

For the moment I build the .netCore 3.1 solution via this command :

dotnet publish -r linux-arm ../MySolution.sln

Then I publish it with SSH and Putty

pscp -scp -r -pw MYPASSWORD bin/Debug/netcoreapp3.1 pi@***.***.***.***:MySolution

It takes a lot of time to build all the solution and then send all the dll/symbols to the raspberry.

Is there a way to publish only the diff to the raspberryPi to accelerate the development/debug experience?

3
  • If my answer helped, I'd be grateful if you posted the details: which command increased the performance and by how much. Jun 24, 2020 at 7:13
  • 1
    I will try it in the next two days. I keep you inform. Jun 24, 2020 at 18:26
  • @DmitryGrigoryev I added an answer to the question. I am now able to use rsync to deploy only the diff to the raspberryPi. For the moment I only have the rsync solution (not the incremental build) And it takes only 10 seconds to deploy instead of (5-10mins). Thanks again! Jun 25, 2020 at 19:16

2 Answers 2

2
+50

To speed up the first command, you should enable incremental builds. I'm not familiar with MSbuild, but there seems to be a howto in the MS docs. Apparently, you need to make sure the inputs and outputs for each target are specified in the project file.

The second part is essentially a copy command, which can be accelerated by using an incremental copy tool such as rsync.

1

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:

  1. Install Windows Subsystem for linux (I use Ubuntu, any other linux distribution should work)

  2. Set your user as a super user on your WSL env (Ubuntu):

    sudo nano /etc/sudoers.d/myusername

    myusername ALL=(ALL) NOPASSWD:ALL

  3. Install sshpass on your WSL env (Ubuntu):

    sudo apt-get install sshpass

  4. Generate an ssh key then copy it to your raspberryPi

    ssh-keygen (keep all the default directory)

    ssh-copy-id pi@RASPBERRY_PI_IP

  5. 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.

  1. 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.

  1. 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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.