Adding Moq to .netcore project - moq

I have class library project (Target framework .net core 2.1) and trying to add Moq nuget.
Nuget installed but doesn't seems to be working. Please see below
Do I need to do something different in here

Related

Unable to install Nuget package in my Xamarin Cross Platform Application

I am developing a xamarin cross platform that is composed of following projects
1)Portable
2)IOS
3)Android
4)UWP
I am facing an issue while installing NuGet package for the xamarin portable project. Actually the NuGet that i am trying to install is targeted on .net Framework version 4.5.2. So we need the .net Version 4.5.2 or higher in our application in order to install this library. However when i try to change target framework version in my project properties to 4.6 then also i am facing the compatibility error that given package is not compatible with .net 4.5.
So what is the correct way that to set the .Net framework version in the project so that i can install it any project.
I have also referred to this doc by Microsoft
https://learn.microsoft.com/en-gb/dotnet/standard/net-standard#comparison-to-portable-class-libraries
that shows compatibility matrix.
I think it is related to .net standard 2.0. use these links
https://xamarinhelp.com/upgrade-pcl-net-standard-class-library/
https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-net-standard-2-0/

Trying to reference a .NET 4.6.1 class library from a .NET Core project

Screenshots => http://imgur.com/a/NWsbh
I'm trying to reference a .NET 4.6.1 Class library in a .NET Core 1.0.0 project. It's added to references but whenever I try to include the "using" statement in a controller I get "the type or namespace could not be found error."
Any suggestions?
You can either only target .NET 4.6.1, and that way you would not support .net core. Or you can add #if NET461 directives in your code, and that way it will be able to find the type and namespace in the if.
your problem is that the code is unsupported in .net core, and therefore cannot build for .net core
You need to set .NET 4.6.1 as the framework for the project. In your project.json, replace the "frameworks"-section with:
"frameworks":
{
"net461": {}
}

How to create a .NET Core library I can reference from a .NET Core App (Web API)

I'm working in Visual Studio 2015 Update 3 and .NET Core 1.0. I have a Web API project which is of type .NETCoreApp v1.0. When I add a .NET Core class library, it is of type .NETStandard v1.6. I can add this library to the Web API project as a reference, but it is not recognised when I try to add using statements.
If I create another project of type .NETCoreApp, I can reference it and use the classes without a problem.
How do I make use of a .NET Core class library from my .NET Core App?
Edit/Update:
This appears only to be an editor/Intellisense issue, because despite the editor warnings, the .NETCoreApp does build and run, calling into the class library.
I am running Resharper, which I see is blamed for similar problems with other types of projects: I have checked that I have the latest version and have cleared the Resharper cache and restarted VS2105.
This is a Resharper issue. At this time Resharper (v2016.1.2) does not support .NET Core 1.0.
There are 2 possible solutions:
Uninstall Resharper, and the Visual Studio native intellisense works.
Install the Resharper 2016.2 EAP (Early Access Program) version. I've done this and it's working. Obviously it comes with the caveats of any EAP/beta product.
Here is a link to the Jetbrains forum post where I was told .NET Core 1 was not yet supported and pointed to the EAP version.
Once you've built a library that targets netstandard1.X, you can either:
Produce a NuGet package with dotnet pack and host it locally or on NuGet. Then, install it in your netcoreapp project as any other dependency.
If your library and application are part of the same solution, make a local reference:
project.json
"dependencies":{
"MyLibrary.Core": {
"version": "1.0.0",
"target": "project"
}
}
target: project tells dotnet to look in the current solution for the dependency, instead of using your NuGet feeds. Again, this only works if you are developing the library and application in the same solution.

Can I use a .NETFramework project within a .NETCoreApp project?

I am building out a website using WebAPI in .NETCoreApp v1.0. However, I am trying to connect to an API for blackbook which is in another project that is built in .NETFramework v4.5.
When I attempt to add a reference to it in Reference Manager I get the following error:
The following projects are not supported as references:
BlackbookWCFProxy has target frameworks that are incompatible with targets in current project MainProject.
MainProject:
.NETCoreApp,Version=v1.0
BlackbookWCFProxy:
.NETFramework,Version=v4.5
So does that mean I have to scrap my entire project because a single API was built in .NETFramework? What about the other APIs I want to use? How can I get it to work nicely with my project?
You should install .NET Core RTM to make a .net core project so you will find this on following link

What is wrong with my class library reference in an MVC 6 Web Api project?

Working in VS 2015 Community, I've created a Services class library project, targeted at .NET 4.6. Now, in my main Api project, all references fall under DNX 4.5.1 and DNX Core 5. When I add the reference to Services, I get the compiler error :
Dependency Services >= 1.0.0-* could not be
resolved Api C:\Development\Surveys\src\Api\project.json
What do I have to do to make my class library compatible with the Api project?
Both of your projects have to target DNX Core 5 if your main (Api) project supports it
You can't reference .net project that has higher version than source one. So both of your projects should target 4.6
The way you described the problem I'm not sure if Services is normal (let's call it old) Class Library or ASP.NET 5 Class Library. If it is old then your main project can not target core clr. Just remove this TFM from project.json.

Resources