Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Blazor App mit Webseite und IoT Sensor Code erstellen

03.02.2022 (👁13466)


Mit folgendem Code kann einfach eine komplette Blazor Anwendung auf einem Raspberry Pi erstellt werden.

pi@raspberrypi:~ $ dir

bin  Bookshelf  Desktop  Documents  dotnetdebug.sh  Downloads  Music  obj  pi.csproj  Pictures  Program.cs  projects  Public  ScreenShots  sqlite_app  Templates  thinclient_drives  Videos  vsdbg

pi@raspberrypi:~ $ cd projects

pi@raspberrypi:~/projects $ mkdir Blazor.Pi

pi@raspberrypi:~/projects $ cd Blazor.Pi

pi@raspberrypi:~/projects/Blazor.Pi $ dotnet new -i Microsoft.AspNetCore.Blazor.Templates

 

The following template packages will be installed:

   Microsoft.AspNetCore.Blazor.Templates

 

Warning: Microsoft.AspNetCore.Blazor.Templates is not found in NuGet feeds https://api.nuget.org/v3/index.json.

Microsoft.AspNetCore.Blazor.Templates could not be installed, the package does not exist.

 

pi@raspberrypi:~/projects/Blazor.Pi $ dotnet new blazorwasm --hosted

The template "Blazor WebAssembly App" was created successfully.

This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/6.0-third-party-notices for details.

 

Processing post-creation actions...

Running 'dotnet restore' on /home/pi/projects/Blazor.Pi/Blazor.Pi.sln...

  Determining projects to restore...

  Restored /home/pi/projects/Blazor.Pi/Shared/Blazor.Pi.Shared.csproj (in 676 ms).

  Restored /home/pi/projects/Blazor.Pi/Server/Blazor.Pi.Server.csproj (in 14.4 sec).

  Restored /home/pi/projects/Blazor.Pi/Client/Blazor.Pi.Client.csproj (in 25.28 sec).

Restore succeeded.

 

pi@raspberrypi:~/projects/Blazor.Pi $ dir

Blazor.Pi.sln  Client  Server  Shared

 

pi@raspberrypi:~/projects/Blazor.Pi $ cd Server

pi@raspberrypi:~/projects/Blazor.Pi/Server $ dotnet add package System.Device.Gpio

 

  Determining projects to restore...

  Writing /tmp/tmp72MFEo.tmp

info : Adding PackageReference for package 'System.Device.Gpio' into project '/home/pi/projects/Blazor.Pi/Server/Blazor.Pi.Server.csproj'.

info :   GET https://api.nuget.org/v3/registration5-gz-semver2/system.device.gpio/index.json

info :   OK https://api.nuget.org/v3/registration5-gz-semver2/system.device.gpio/index.json 1176ms

info : Restoring packages for /home/pi/projects/Blazor.Pi/Server/Blazor.Pi.Server.csproj...

info :   GET https://api.nuget.org/v3-flatcontainer/system.device.gpio/index.json

info :   OK https://api.nuget.org/v3-flatcontainer/system.device.gpio/index.json 555ms

info :   GET https://api.nuget.org/v3-flatcontainer/system.device.gpio/2.0.0/system.device.gpio.2.0.0.nupkg

info :   OK https://api.nuget.org/v3-flatcontainer/system.device.gpio/2.0.0/system.device.gpio.2.0.0.nupkg 39ms

info : Installed System.Device.Gpio 2.0.0 from https://api.nuget.org/v3/index.json with content hash 7PsI5uD18QZP/60vPxQyhYlm2HywVythMxWeOkL7QAO8ZrSeJO1+ijn18Yd2q87dL9ED1MVCTKyR+DVPjxwx2w==.

info : Package 'System.Device.Gpio' is compatible with all the specified frameworks in project '/home/pi/projects/Blazor.Pi/Server/Blazor.Pi.Server.csproj'.

info : PackageReference for package 'System.Device.Gpio' version '2.0.0' added to file '/home/pi/projects/Blazor.Pi/Server/Blazor.Pi.Server.csproj'.

info : Committing restore...

info : Generating MSBuild file /home/pi/projects/Blazor.Pi/Server/obj/Blazor.Pi.Server.csproj.nuget.g.targets.

info : Writing assets file to disk. Path: /home/pi/projects/Blazor.Pi/Server/obj/project.assets.json

log  : Restored /home/pi/projects/Blazor.Pi/Server/Blazor.Pi.Server.csproj (in 1.59 sec).

 

pi@raspberrypi:~/projects/Blazor.Pi/Server $ dotnet run

Building...

info: Microsoft.Hosting.Lifetime[14]

      Now listening on: https://localhost:7253

info: Microsoft.Hosting.Lifetime[14]

      Now listening on: http://localhost:5061

info: Microsoft.Hosting.Lifetime[0]

      Application started. Press Ctrl+C to shut down.

info: Microsoft.Hosting.Lifetime[0]

      Hosting environment: Development

info: Microsoft.Hosting.Lifetime[0]

      Content root path: /home/pi/projects/Blazor.Pi/Server/

 

 

 

Man findet das Code Beispiel unter:
https://codedbeard.com/iot-with-blazor-on-raspberry-pi-part-3/