Is it possible to run .NET Core on Raspberry PI?

I have managed to run .NET Core 2 app on Raspberry PI 3 with Raspbian. I have followed https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md and https://github.com/dotnet/core/issues/447: On my laptop: Install .NET Core 2.0 SDK Run mkdir helloworld cd helloworld dotnet new console Edit helloworld.csproj <Project Sdk=”Microsoft.NET.Sdk”> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.0</TargetFramework> <RuntimeIdentifiers>win-arm;linux-arm</RuntimeIdentifiers> </PropertyGroup> </Project> Run dotnet publish -r linux-arm On Raspberry PI … Read more

How do you filter xunit tests by trait with “dotnet test”?

I found the answer (only tests attributed [Trait(“TraitName”, “TraitValue”)] are executed): dotnet test –filter TraitName=TraitValue Alternatively, you can filter by not having a trait value (tests attributed [Trait(“TraitName”, “TraitValue”)] are execluded from run) dotnet test –filter TraitName!=TraitValue In my example above, this means I can run: dotnet test –filter Color=Blue More docs here: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md

Use HttpClientFactory from .NET 4.6.2

All of the Microsoft.Extensions.* packages target .NET Standard 2.0. That means that you can use Dependency Injection, Configuration, Logging and HttpClientFactory if you add the appropriate package to your application. You need to add Microsoft.Extensions.Http to use HttpClientFactory and Microsoft.Extensions.Http.Polly if you want to use it with Polly To configure HttpClientFactory you’ll have to add … Read more

What is the right way to fix error NU1605: Detected package downgrade – log4net

According to Microsoft, this can be resolved by adding the following to your csproj. <PackageReference Include=”Microsoft.NETCore.Targets” Version=”3.0.0″ PrivateAssets=”all” /> https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1605#issue-1 “Certain combinations of packages which shipped with .NET Core 1.0 and 1.1 are not compatible with each other when they are referenced together in a .NET Core 3.0 or higher project, and a RuntimeIdentifier is … Read more

How to publish results using dotnet test command

You can see all the dotnet test options by executing dotnet test –help. One of the options is -l, –logger, which gives some great information: Specify a logger for test results. Examples: Log in trx format using a unqiue file name: –logger trx Log in trx format using the specified file name: –logger “trx;LogFileName=<TestResults.trx>” More … Read more

What does PrivateAssets=’All’ mean?

PrivateAssets is a metadata tag used to control dependency assets. You might be using a dependency purely as a development harness and might not want to expose that to projects that will consume your package. In this scenario, you can use the PrivateAssets metadata to control this behavior. Package references (PackageReference) in project files In … Read more

Entity Framework Core: How to get the Connection from the DbContext?

The Microsoft.EntityFrameworkCore.Relational (https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Relational/) package provides extension methods for this – you can use dbContext.Database.OpenConnection() or dbContext.Database.GetDbConnection() to get the DbConnection object. Note: if you have Microsoft.EntityFrameworkCore.SqlServer installed then you don’t have to explicitly install this package

How to get “Manage User Secrets” in a .NET Core console-application?

“Manage user secrets” from a right click is only available in web projects. There is a slightly different process for console applications It requires manually typing the required elements into your csproj file then adding secrets through the PMC I have outlined the process that worked for me in my current project step by step … Read more