Where do I find system.web.Http in .NET CORE 2.0 project - asp.net-core

i need use System.Web.Http in my project.
I found that Microsoft.AspNet.WebApi.Core package has it, but in NET core project I have error:
Package 'Microsoft.AspNet.WebApi.Core 5.2.4' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Can you help?

Related

Is the nuget package Microsoft.AspNet.WebApi.Core 5.2.7 compatible with .Net Core 2.2?

I am getting the following warning in my .NET Core 2.2 application:
Warning NU1701 Package 'Microsoft.AspNet.WebApi.Core 5.2.7' was restored using
'.NETFramework,Version=v4.6.1' instead of the project target framework
'.NETCoreApp,Version=v2.2'.
This package may not be fully compatible with your project.
Are there any alternatives for this package?
As said in comments, this is not needed for a ASP.NET Core project. Remove it via NuGet and you should be good to go.

Can build and run on Visual Studio but cannot Publish

I am having a weird situation where I cannot publish my final Web project. Here is the project structure:
Foo.Services.Common: this is shared library: .NET Standard 2.0.3, Microsoft.AspNetCore.Mvc.Core 2.1.0 with the class DefaultWebSettings defined.
Foo.Services.Common.Razor: Razor Class Library, has reference back to Foo.Services.Common and uses DefaultWebSettings: NETStandard.Library 2.0.3, Microsoft.AspNetCore.Mvc 2.1.0 and some other ASP.NET Core related package (static files, Configuration)
Foo.Services.Api: ASP.NET Core API only (no View, no Razor), has reference back to Foo.Services.Common. Publish well. Uses: Microsoft.AspNetCore.App 2.1.0, Microsoft.NETCore.App 2.1.0.
Foo.Services.Web: front end project. This one is the one I cannot publish! This one has references to both Common projects. Uses: Microsoft.AspNetCore.App 2.1.0, Microsoft.NETCore.App 2.1.0
However, upon publish, this one shows up:
The type or namespace name 'DefaultWebSettings' could not be found
(are you missing a using directive or an assembly reference?)
The error location is in a file of Foo.Services.Common.Razor project, NOT the Web project.
Funnily, Visual Studio perfectly works even with IntelliSense and Go to Definition:
I can build in both Debug/Release mode, run with/without debug any project in the solution well. Moreover, publishing Foo.Services.Common.Razor works without any problem!
In short: I cannot publish my Web project and have no idea what is the problem. I have tried:
Clean/Build.
Delete/Re-add references.
Manually delete all obj and bin folders.
Please show me what I may missing.
In the end, I had to remove Reference of the Common from Common.Razor and Web projects. I guess they could not build because of some conflict between .NET Standard and .NET Core. Had to copy all code of Common into Common.Razor.

.net core 2.0 with akka.net and f#

I have tried to create basic akka.net sample in asp.net core2.0 using f#.Although sample project does not have any error but showing warnings as below
warning NU1701: Package 'Akka.FSharp 1.2.3' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
and same warning for all packages.
can I get the solution to resolve this warning?

Package was restored using .NetFramework instead of project target framework

I created a new project with the DevExtreme ASP.Net Core Application template.
Then I changed the framework from .Net Core 1 to .Net Core 2.0
However when I try to build I get the following error.
Warning NU1701 Package 'System.Linq.Queryable 4.0.0' was restored using
'.NETFramework,Version=v4.6.1' instead of the project target framework
'.NETCoreApp,Version=v2.0'. . This package may not be fully compatible with your project.
This problem is similar to This question about Nu1701 However the package in question is DevExtreme.AspNet.Core The name of the package indicates that it is meant to work with Core.
Upgrade to the DevExtreme 17.2.2 Beta and use the DevExtreme 17.2 ASP.Net Core Application (.NET Core) template

Using .NET 4.0 library with other dependencies from a .NET 4.5.1 project

I have a .NET project whose target framework is 4.5.1. This project depends on a NuGet library which only has a .NET 4.0 release and this library in turn depends on MVVMLight:
MyProject (4.5.1) --> Depends on MyLibrary (4.0) --> Depends on MVVMLight (4.0)
The MVVMLight NuGet also has a 4.5 version so when it's installed on MyProject it ends up referencing the 4.5 version (as opposed to MyLibrary which was compiled with MVVMLight for .NET 4.0).
This results in the following compilation error:
5>...\Adorners\CircleAdorner.cs(19,18,19,31): error CS0012: The type 'GalaSoft.MvvmLight.ObservableObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'GalaSoft.MvvmLight, Version=4.4.32.18939, Culture=neutral, PublicKeyToken=null'.
The error is from a class CircleAdorner which inherits from a class defined in MyLibrary which in turn inherits from ObservableObject from MVVMLight.
Is this situation "legal"? Is it OK to reference a .NET 4.0 library from a .NET 4.5.1 project? From my understanding it should be OK. However, the catch here is that the .NET 4.0 project expects another dependency which is not satisfied here.
Also, I noticed that the DLL version of GalaSoft.MvvmLight for the .NET 4.5 is 4.4.32.39728 and not 4.4.32.18939. In the project I marked this reference with <SpecificVersion>False</SpecificVersion> but it didn't help.
Yes it is legal for a .NET 4.5.1 project to use a .NET 4.0 assembly. .NET 4.5 is an in place update to .NET 4.0 and is backward compatible.
From NuGet's point of view if the version of project's target framework is less than or equal to the assembly version in the NuGet package then they are considered compatible. So NuGet will allow you to add a NuGet package that targets .NET 4.0 into a project that targets .NET 4.5. What you cannot do is add a NuGet package that only targets .NET 4.5 into a project that targets .NET 4.0 since the assemblies in the NuGet package may use parts of the .NET framework that is not included with .NET 4.0.
When installing a package NuGet will pick the highest version of the .NET framework that the NuGet package contains that is compatible with your project.
With your GalaSoft.MvvmLight version mismatch you should be able to resolve the problem using one of two options:
Update MyLibrary to use the same version of MvvmLight that your project is using.
Add a binding redirect to your project's app.config for GalaSoft.MvvmLight so MyLibrary's reference to it is mapped to the later version. If you are using Visual Studio 2013 and writing a .NET 4.5.1 desktop application you can enable automatic binding redirects instead of updating your app.config.