Build Instructions - Duet3D/DuetSoftwareFramework GitHub Wiki

In order to build packages like those on the package feed, check out the build.sh script in the pkg directory. If you wish to make changes to the existing software and to test it, you need to get the latest .NET SDK first.

Preparing the remote system

In order to deploy program files on the remote system, you need to set up SSH access first. To simplify the setup process, the SBC running DSF is changed to have a passwordless root login. Note that this is a potential security hazard in unprotected (public) networks; if you are operating a machine in such a scenario, consider using another passwordless login method (e.g. private SSH certificate file) instead.

Delete root password

Run sudo passwd -d root on the remote system to delete the root password. You may need to change nullok_secure to nullok in /etc/pam.d/common-auth as well in order to permit passwordless root logins over SSH. Note that this can be a security hazard, so use with care.

Permitting root logins via SSH without password

Open /etc/ssh/sshd_config with an editor of your choice, look for the lines

#PermitRootLogin prohibit-password
...
#PermitEmptyPasswords no

and replace it with

PermitRootLogin yes
...
PermitEmptyPasswords yes

Once done, restart the SSH daemon and change the root password to e.g. raspberry:

sudo systemctl restart sshd
sudo passwd

Building and deploying from a remote system

There are multiple ways to build and deploy DSF binaries from a remote system. You can choose if you wish to do this from Windows or Linux.

Note that the following scripts define VERIFY_OBJECT_MODEL which is used to report missing keys in the object model (if applicable). This switch is not used in the release packages.

Via Windows

Preparation

The recommended Windows deployment method involves rsync, which needs to be installed first. It is recommended to install Git for Windows before you add rsync.

Once it is installed, obtain the rsync and libxxhash packages from here and unpack them using zstd. When done, copy the contents of the resulting usr directory into C:\Program Files\Git\usr.

Automated deployment of a single project

New method using rsync (v3.6 and later, recommended)

You can use this batch script to deploy a single project:

@echo off
dotnet build -r linux-arm --self-contained /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%

echo Stopping services...
ssh root@%~1% "systemctl stop duetcontrolserver duetwebserver"

"C:\Program Files\Git\usr\bin\rsync.exe" -e "'C:\Program Files\Git\usr\bin\ssh.exe'" -ruv "./bin/Debug/net8.0/linux-arm/" root@%~1%:/opt/dsf/bin/

echo Starting services...
ssh root@%~1% "systemctl start duetcontrolserver duetwebserver duetpluginservice duetpluginservice-root"
echo Done!

This script can be invoked in the project directory containing the .csproj file. If you named it deploy-to.bat, invoke it via deploy-to.bat <remote machine> (e.g. deploy-to.bat ender3pro). Provided the compilation goes well, this script only copies newer files to the target.

New method using rsync (v3.5)

You can use this batch script to deploy a single project:

@echo off
dotnet build -r linux-arm --self-contained /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%

echo Stopping services...
ssh root@%~1% "systemctl stop duetcontrolserver duetwebserver"

"C:\Program Files\Git\usr\bin\rsync.exe" -e "'C:\Program Files\Git\usr\bin\ssh.exe'" -ruv "./bin/Debug/net6.0/linux-arm/" root@%~1%:/opt/dsf/bin/

echo Starting services...
ssh root@%~1% "systemctl start duetcontrolserver duetwebserver duetpluginservice duetpluginservice-root"
echo Done!

This script can be invoked in the project directory containing the .csproj file. If you named it deploy-to.bat, invoke it via deploy-to.bat <remote machine> (e.g. deploy-to.bat ender3pro). Provided the compilation goes well, this script only copies newer files to the target.

Old method (deprecated, only supported up to v3.5)

Every .NET application of DSF is references the DotnetPublishSsh package which allows you to compile and upload .NET applications for ARMv7/AArch64.

Before you can actually deploy files on the remote system, make sure to shut down all the DSF components before you continue. If you omit this step, you will get permission errors:

sudo systemctl stop duetcontrolserver duetwebserver

After that, open a new local console in one of the DSF application directories (where a .csproj file lies) and run:

dotnet publish-ssh -r linux-arm --ssh-host duet3 --ssh-user root --ssh-password raspberry --ssh-path /opt/dsf/bin /p:DefineConstants=VERIFY_OBJECT_MODEL

This will replace the stock DSF component with your own compiled variant. If you do not wish to publish everything to your board at the time of compiling, have a look at the dotnet publish command.

Once you are done, you can restart the DSF services again via SSH:

sudo systemctl start duetcontrolserver duetwebserver duetpluginservice duetpluginservice-root

Automated deployment of all DSF projects using rsync

If you wish to build and deploy all the DSF projects at once, you can use this script instead:

@echo off

mkdir BUILD
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\CodeConsole -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\CodeLogger -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\CodeStream -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\CustomHttpEndpoint -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\DuetControlServer -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\DuetPiManagementPlugin -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\DuetPluginService -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\DuetWebServer -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\ModelObserver -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet build -r linux-arm --self-contained .\DuetSoftwareFramework\src\PluginManager -o .\BUILD /p:DefineConstants=VERIFY_OBJECT_MODEL
if %errorlevel% neq 0 exit /b %errorlevel%

echo Stopping services...
ssh root@%~1% "systemctl stop duetcontrolserver duetwebserver"

"C:\Program Files\Git\usr\bin\rsync.exe" -e "'C:\Program Files\Git\usr\bin\ssh.exe'" -ruv "./BUILD/" root@%~1%:/opt/dsf/bin/

echo Starting services...
ssh root@%~1% "systemctl start duetcontrolserver duetwebserver duetpluginservice duetpluginservice-root"
echo Done!

del /S /Q BUILD
rmdir BUILD

Make sure to put it in the same directory where your DuetSoftwareFramework directory is located and to call it from there. Like the script above, you can run it via deploy-all-to.bat <remote machine> (e.g. deploy-all-to.bat ender3pro).

If you updated solution-wide dependencies, it is a good idea to run this script at least once to make sure other projects reference the same dependency versions.

Building on the SBC itself

Of course you can compile the required components on the SBC itself. Once the latest .NET SDK has been installed, enter the directory of the DSF application you want to compile and run dotnet build -o /opt/dsf/bin. This will generate suitable binaries for you. Make sure to stop/start the DSF services as well as mentioned in the instructions above.