Convert .NET Core 2.0 class libraries to .NET Standard

In the project file, you can point target compilation to netstandard with the exact version. Example of Proj.csproj: <Project Sdk=”Microsoft.NET.Sdk”> <PropertyGroup> <TargetFramework>netstandard1.6</TargetFramework> </PropertyGroup> </Project> … Microsoft provides good documentation about targeting types. Dotnet Standard is not a framework or a library, it is an abstract set of instructions: what functionality should have System.Array, String, List, … Read more

What does mean in csproj?

The sdk-style projects have a few automatic includes. By default, the sdk has something like <None Include=”**/*”> (simplified) that is added (included) before your project’s contents. But you don’t want your file to be in the “None” set, but in the “EmbeddedResource” set. MSBuild doesn’t have any problem with the files being in more than … Read more

Should HttpClient instances created by HttpClientFactory be disposed?

Calling the Dispose method is not required but you can still call it if you need for some reasons. Proof: HttpClient and lifetime management Disposal of the client isn’t required. Disposal cancels outgoing requests and guarantees the given HttpClient instance can’t be used after calling Dispose. IHttpClientFactory tracks and disposes resources used by HttpClient instances. … Read more

Compile a .NET Core application as an EXE file using Visual Studio 2017

Update 2019: .NET Core 3.0+ projects will now include an executable for the platform you build on by default. This is just a shim executable and your main logic is still inside a .dll file. But .NET Core 3.0 also introduced single-file deployments so deploying with dotnet publish -r win-x64 -p:PublishSingleFile=True –self-contained false will create … Read more

Visual Studio 2017 cannot update Microsoft.NETCore.App package (“Blocked by project”)

EDIT 2018: Only follow the instructions for updating the package if you really know what you are doing. In most cases, you never need to update this package – or other packages marked as “blocked by project” – manually. A framework-dependent app will use the latest runtime available and a self-contained application will perform an … Read more

How to run .NET Core console application from the command line

If it’s a framework-dependent application (the default), you run it by dotnet yourapp.dll. If it’s a self-contained application, you run it using yourapp.exe on Windows and ./yourapp on Unix. For more information about the differences between the two app types, see the .NET Core Application Deployment article on .NET documentation.