Category Archives: Uncategorized

.NET CORE CONSOLE APPLICATION USING NLOG – RUNNING ON RASPBERRY PI / LINUX / ARM

Speed Comparison: Benchmarking 5 popular .NET logging libraries
https://www.loggly.com/blog/benchmarking-5-popular-net-logging-libraries/
Windows:Build:
dotnet publish -c Release -r linux-arm

Windows: Deploy:
scp -r ./bin/Release/netcoreapp2.1/linux-arm root@192.168.1.59:/home/userX/core/DotNet.RaspberryPi.App3/

Linux:Run:
./DotNet.RaspberryPi.App3

Source: 
https://github.com/matejv1/DotNet.RaspberryPi.App3

Reference:
NLog Configuration File:
https://github.com/NLog/NLog/wiki/Configuration-file

NLog Console Application:
https://github.com/NLog/NLog.Extensions.Logging/wiki/Getting-started-with-.NET-Core-2—Console-application

 

 

Advertisements

.NET Core Application using SQLite and Running on Raspberry Pi / Linux / ARM

Console .NET Core Application using SQLite.

Commands:

# create new console .net core application using command line
dotnet new console -o DotNet.RaspberryPi.App2

# change directory
cd DotNet.RaspberryPi.App2

# add ef nuget package to project
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet restore

# open project in vs code – open vs code using command line
code . #run visual studio code from current directory

# build database using entity framework migrations / update command
dotnet ef migrations add InitialCreate
dotnet ef database update

Build:

dotnet publish -c Release -r linux-arm

Publish:

To Raspberry Pi / Linux / ARM device using SCP / SSH remote connection. Important part: the executable file is located in bin/Release/netcoreapp2.1/linux-arm/publish. You will also need to run chmod +x if run under other user than root.

Example: scp -r ./bin/Release/netcoreapp2.1/linux-arm root@192.168.1.150:/home/appUser/apps/

More on this can be read on previous published article: Create .NET Core Application And Deploy it to Raspberry Pi / ARM Device / Linux

Source:

https://github.com/matejv1/DotNet.RaspberryPi.App2

References:

https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite

 

Create .NET Core Application And Deploy it to Raspberry Pi / ARM Device / Linux

Requirements:

  • Raspberry / ARM Device / Linux Device
  • SSH access to device / for deployment purposes
  • .NET SDK installed on Windows/Linux/Mac – where App will be developed
  • Windows Command Line SSH

Optional:

  • IDE / Visual Studio Code / Visual Studio

1. Create .NET Core application using command line / or Visual Studio

Command Line / Visual Studio Code

dotnet new console -o DotNet.RaspberryPi.App1

2. Build / Publish using Command Line

dotnet publish -c Release -r linux-arm

3. Deploy to Raspberry Pi device / Linux ARM Device

We will move / copy files to destination (ARM device) using SCP command, which stand for Secure Copy. Replace parameters to meet your needs.

  • Source Path / Folder
  • Destination Path / Folder
  • IP Address

scp -r <SOURCE-FOLDER> <USER>@<IP-ADDRESS>:<DESTINATION-FOLDER>

Example:

scp -r ./bin/Release/netcoreapp2.1/linux-arm root@192.168.1.150:/home/appUser/apps/

 

4. Run the App on the Device

First you’ll need to change permissions on executable ARM/Linux file by using chmod command. Also, move to publish directory where file is located.

This steps should be done on the device over SSH or direct connection. Connect to device using SSH command line command(alternative is Putty), Linux has command included by default.

IP address of the device can be found using:

  • nmap (nmap <IP-ADDRESS:RANGE-FROM>:<IP-ADDRESS:RANGE-TO>, example: nmap 192.168.1.1-255) or
  • you can go to your router and list devices. Router IP can be found using
    • ipconfig command line (Windows) or
    • ifconfig (Linux). Look for default gateway.

When you have all the parameters that you need, you can continue to executing the command below:

ssh <IP-ADDRESS>
#connecting to the remote device

cd /home/<USER>/apps/bin/Release/netcoreapp2.1/linux-arm/publish
#changing directory to publish folder

sudo chmod +x <AppName>
# change execution permissions on application

./<AppName>
#run application

Source Code

https://github.com/matejv1/DotNet.RaspberryPi.App1

Mail App (Apps for Office) And How To Build One Series

In this blog post you can read how to create a mail app. Mail apps are apps that get displayed next to Outlook items you’re viewing or writing to enhance the browsing or authoring experience. Mail apps are part of Apps for Office: msdn.microsoft.com

Main Pros of Mail Apps:

  • Can integrate business process directly into Outlook
  • Is working in OWA and Outlook – same code
  • Mail App project is build using Client side code only

What this Mail App will do:

  • Query custom web service (which we create)
    • send the email address of a user sending an email as a parameter to exposed web service
  • Display returned data in the mail app container using KnockoutJS

End Result

End result will be an app for Outlook as seen on the image above. It will display found company and its yearly report on Revenue/Profit. In example above, email was sent from one of MS people(@microsoft.com), since app shows data of Microsoft Corporation. All data is fictional, inserted in the step of creating a database.

Articles – Separated into smaller chunks:

  • (Coming) Article 1 – We will create database which will expose data – (Code First, Entitify Framework)
    • this database can represent data of a backend system, hosted in Azure
  • (Coming) Article 2 – Create web service using ASP.NET WebApi
  • (Coming) Article 3 – Display data using Knockout + HighCharts Javascript library
  • (Coming) Article 4 – Using created Web Service, javascript cross site call – JSONP