Disable transitive project reference in .NET Standard 2

Transitive project references (ProjectReference) Transitive project references are new feature of SDK-style csproj (1,2) format used in .NET Core/.NET >= 5. You can also use this csproj for old .NET Framework projects (1,2,3) but with some exceptions. In this SDK-style format project references (represented by <ProjectReference> entry in .csproj file) are transitive. This is different … Read more

How Do You Reference a .NET Standard Library from a .NET Framework 4.5 Console Application in Visual Studio 2017?

.NET Framework 4.5 only supports using .net standard libraries targeting .NET Standard 1.0 or 1.1. Since your library targets 1.6, the tooling does the right thing here and errors out (since your library may use APIs not available in .NET Framework 4.5). If you published the library as NuGet package and consumed it via a … Read more

‘Could not load file or assembly ‘netstandard, Version=2.0.0.0, …’. Reference assemblies should not be loaded for execution

The netstandard.dll you are trying to load is a reference assembly that which cannot be loaded for runtime on .NET Framework as pointed out by others. However if you need to resolve that dependency you will need to runtime version that maps to the framework you are trying to run on. For .NET Standard support … Read more

How do I exclude files/folders from a .NET Core/Standard project?

There are also a few things you can do in the csproj files to make sure the files aren’t picked up: 1) Make sure none of the globbing patterns that look for “project items” pick up the files: <PropertyGroup> <DefaultItemExcludes>$(DefaultItemExcludes);your_nonproj.file;a\**\*.pattern</DefaultItemExcludes> </PropertyGroup> 2) Remove items explicitly: <ItemGroup> <None Remove=”hidden.file” /> <Content Remove=”wwwroot\lib\**\*” /> </ItemGroup> Note that, … Read more

HttpContext in .net standard library

There’s a problem to your approach: .NET Standard is the most bare-bones implementation of .NET available, meaning that only basic features which are platform- and scenario-agnostic are implemented. HttpContext exists on both the .NET Framework and .NET Core (both of which implement .NET Standard, by the way), but being specific to the Web, it does … Read more

How to properly unit test a .NET project with multiple target frameworks, given implementation differences among targets?

First, test projects can multi-target as well by making use of the <TargetFrameworks>property just like you used for the library. While the VS test runner currently only shows/runs one framework (the first one to be specific), any invocation of dotnet test will execute all frameworks (xunit is also developing custom console runner – dotnet xunit … Read more

Adding a bindingRedirect to a .Net Standard library

Binding redirects are a .NET framework concept, there are no binding redirects on .NET Standard and .NET Core. However, an application (the actual .NET Framework or .NET Core application) need to resolve the files to be used. On .NET Core, this is done by generating a deps.json file based on the build input and a … Read more

tech