Sunday, July 31, 2016

What is the purpose of "imports" in project.json of .NET Core apps?

I was doing the tutorial "Building Your First Web API with ASP.NET Core MVC and Visual Studio" and after I finished it, I thought of trying to see if Moq will work with .NET Core.


Then I changed the content project.json file with the JSON below whose significant parts came from the "Testing your Console App" section of the tutorial "Getting started with .NET Core on Windows/Linux/macOS using the command line":

Then I tried to remove the "imports" part of the project.json file because I do not know what it was for. But this error pops up in Visual Studio:



... and errors like this in the Output window:
Package xunit.assert 2.1.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package xunit.assert 2.1.0 supports:
- dotnet (.NETPlatform,Version=v5.0)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)

So I tried to look for the purpose of this "imports".

I found the docs for project.json but I do not understand what it is trying to say.

Will cause other packages targeting portable-net45+win8 to be usable when targeting netcoreapp1.0 with the current project.
What does that mean?

Then I tried to google for using this:
more explanation of "imports": "portable-net45+win8"
Google shows only one result which came from StackOverflow which led me to an article from the EF docs. It says this regarding EF:
Some of EF Core’s dependencies do not support .NET Standard yet. EF Core in .NET Standard and .NET Core projects may require adding “imports” to project.json as a temporary workaround.

The workaround is to manually import the portable profile “portable-net451+win8”. This forces NuGet to treat this binaries that match this profile as a compatible framework with .NET Standard, even though they are not. Although “portable-net451+win8” is not 100% compatible with .NET Standard, it is compatible enough for the transition from PCL to .NET Standard. Imports can be removed when EF’s dependencies eventually upgrade to .NET Standard.
That is a much better explanation! Even though I do not know what PCL is :) .

Happy coding!

Sunday, July 10, 2016

My first graph problem solved: "10928 - My Dear Neighbours"

[UPDATE (July 27, 2016): I remember that this is not really the first graph problem I solved. It is, rather, the first graph problem on UVA Online Judge that I solved. I was already able to solve a graph problem when I took the free Stanford course named CS106B last 2011. But I already forgot how I solved it.]

I am so excited!!!

I solved my first graph related problem: the UVA Online Judge's problem #10928 "My Dear Neighbours".

This might just be a very simple problem but at least I am able to get started with solving graph problems.

Picture taken from http://uhunt.felix-halim.net/

Here is my solution:


My actual solution is actually here.

Happy coding!!!