====== Publishing, Deploying, and Running a .NET Application Using Visual Studio ======
To get a .NET application from your development environment to an ARM Linux device like the ComfilePi, you need to perform the following steps in order:
- Publish the application for the target device's CPU architecture and operating system.
- Deploy the resulting binaries to a target device.
- Execute the binaries on the target device.
See also [[https://learn.microsoft.com/en-us/dotnet/iot/deployment|Deploy .NET apps on ARM single-board computers]]
===== Publishing the Application =====
- To publish a .NET project using Visual Studio, right-click the project in Visual Studio's Solution Explorer and choose the //Publish// option. {{ :comfilepi:dotnet:deploy:visual_studio:vs_publish_1.png }} \\
- In the //Advanced Settings// choose the //linux-arm64// runtime. If the .NET SDK or runtime is already installed on the target deice, choose the //Framework Dependent// development mode.{{ :comfilepi:dotnet:deploy:visual_studio:vs_publish_2.png }} \\
- Press the //Publish// button to start the publish process. If successful, open the //Target location// to see the resulting binaries files. {{ :comfilepi:dotnet:deploy:visual_studio:vs_publish_3.png }}
===== Deploying the Application =====
- Copy the files to the ComfilePi using a GUI application like [[https://filezilla-project.org/|FileZilla]], or by executing the following [[https://manpages.debian.org/stable/openssh-client/scp.1.en.html|scp]] command in a terminal, with variables in curly braces substituted by the values for your device.
scp -r * {comfilepi_user}@{comfilepi_ip_address}:{comfilepi_folder}
- You may need to mark your main binary file as executable using the following [[https://manpages.debian.org/stable/coreutils/chmod.1.en.html|chmod]] command.
ssh {comfilepi_user}@{comfilepi_ip_address} chmod +x {comfilepi_folder}/{executable_file}
===== Running the Application =====
With the binary files successfully deployed to the target device and the main binary marked as executable, you can run the application by simply invoking the main binary executable from a terminal.
./{executable_file}
If you are invoking the application from an SSH session, and the application requires and X11 display, you must first set the ''DISPLAY'' environment variable to the local display, then run the executable file.
export DISPLAY=":0.0"
./{exectuable_file}