0 Comments

image

If you try to install latest .NET Core SDK 1.0.1 on Mint 18 or Elementary OS Loki (based on Ubuntu 14.04 and 16.04 LTS) by following instructions on http://get.asp.net, you might see this error:

mint-vbox hudo # sudo apt-get install dotnet-dev-1.0.0-preview2-003131
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
dotnet-dev-1.0.0-preview2-003131 : Depends: dotnet-sharedframework-microsoft.netcore.app-1.0.1 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

dotnet-sharedframework-microsoft.netcore.app-1.0.1 is missing, but if you try to apt-get that, then dependent libicu52 is missing, only libicu55 is in Ubuntu repository.

We can get it from this Url, by downloading .deb file: https://launchpad.net/ubuntu/wily/amd64/libicu52/52.1-8 (you’ll probably choose Arm64 release binary)

Since we can’t just execute this .deb by double-clicking on it (at least on Elementary OS), we have to move it to repo cache and use apt-get install, or better, use gdebi utility (Mint 18 already includes it):

sudo apt-get install gdebi

If we double-click to downloaded .deb file now, a window will appear offering:

image

After that, executing last .net core installation step takes us to the happy place Smile :

mint-vbox hudo # sudo apt-get install dotnet-dev-1.0.0-preview2-003131
Reading package lists... Done
….

Setting up dotnet-sharedframework-microsoft.netcore.app-1.0.1 (1.0.1-1) ...
Setting up dotnet-dev-1.0.0-preview2-003131 (1.0.0-preview2-003131-1) ...
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit
http://aka.ms/dotnet-cli-eulafor more information.
Processing triggers for libc-bin (2.23-0ubuntu4) ...
hudo-VirtualBox hudo # dotnet

Microsoft .NET Core Shared Framework Host

  Version  : 1.0.1
  Build    : cee57bf6c981237d80aa1631cfe83cb9ba329f12

Usage: dotnet [common-options] [[options] path-to-application]

Common Options:
  --help                           Display .NET Core Shared Framework Host help.
  --version                        Display .NET Core Shared Framework Host version.

Options:
  --fx-version <version>           Version of the installed Shared Framework to use to run the application.
  --additionalprobingpath <path>   Path containing probing policy and assemblies to probe for.

Path to Application:
  The path to a .NET Core managed application, dll or exe file to execute.

If you are debugging the Shared Framework Host, set 'COREHOST_TRACE' to '1' in your environment.

To get started on developing applications for .NET Core, install .NET SDK from:
 
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
mint-vbox hudo #

Visual Studio Code and Omnisharp support

Since elementary OS 0.4 Loki, platform Id changed from “elementary OS” to “elementary”. To fix Omnisharp problem of not recognizing  this version of OS, edit platform.js file in/home/username/.vscode/extensions/ms-vscode.csharp-1.4.1/out/ by changing line (I removed “OS” in line 76):

case 'elementary':

on mint, this case branch needs to be added to the end of switch statement:

case 'linuxmint':
    var versionId = getValue("VERSION_ID");
    if (versionId.startsWith("17")) {
        // This also works for Linux Mint
        return Platform.Ubuntu14;
    }
    else if (versionId.startsWith("18")) {
        return Platform.Ubuntu16;
    }
    break;

Don’t forget to restart VS Code after changing platform.js. Hopefully, VS Code and Omnisharp will be able to recognize the project, install necessary files, like build tasks and debugger support!

0 Comments

2016-10-26-PHOTO-00000133[1493]Last week I started new meetup user group in Dublin: "ASP.NET Workshop Dublin" (yes, very imaginative title…), aimed to everyone who wants to learn about new MVC Core by building real end-to-end application. Its here: https://www.meetup.com/ASP-NET-Workshop-Dublin

But, to get even more value from this and not just list the features of new framework, the idea is to build some useful application, deploy it to the production and release the source code on Github.

On the first meetup we agreed on the topic (no title yet, that's usually the most difficult part anyway!), and it will be about sharing positive news and random acts of kindness. While every news portal is bombarding us with depressing and negative articles, reading or sharing some positive stores can help every one of use. Small things, like paying coffee to someone, helping change the tire or noticing kind person… There's even some medical science behind this!

While building this app the group will learn how to start with empty .NET Core project, add MVC frameworks, middlewares, render views, model data, store data to database, use Git and deploy app to web server.

Plan is to have around 5 to 10 meetups and to have working version of application with basic UI, authentication, database, that people can use. Further improvements can be made by contributing to the project repository.

Source code will be available of Github (link will be updated here, as soon as I find some title for the app).

5 Comments

It started as a quick evening project (HTML Pager for Bootstrap), one class library I needed for some web projects to generate Bootstrap-happy pager HTML, and it ended up in hours of chasing weird VS2015 project configuration issues. I just wanted to package Core project into nuget and use it from MVC6 Core projects and also "old" full .NET 4.6 web projects (MVC5). Soon after I started splitting projects and importing DLLs, Visual Studio complained and I just couldn't reference Core project from my MVC 5 web app!

Scott Hanselman explained similar in his blog post, but I needed the exact opposite thing!

Maybe .NET Core is in RTM, but it reminded me that tooling support is still in deep Preview 2 state where half of things just doesn't work, meaning there's no UI support for them.

Plan is to have 3 packages:

  1. Core class library, with no special dependencies to MVC, but just pager renderer class (xproj)

  2. MVC 5 html helper wrapper (full .net 4.6, csproj), dependency to MVC 5

  3. MVC 6 html helper wrapper (core, netstandard1.6, xproj), dependency to MVC 6

For 3), its easy since xproj can be referenced from another xproj, but Core project can't be referenced from 4.6 (csproj) project! The trick is to package core bits into nuget and then import that into csproj.

projectstructure

Core class library needs to specify both frameworks in project.json, like this:

"frameworks": {
   "netstandard1.3": {
     "dependencies": {
       "NETStandard.Library": "1.3.0"
     }
   },
   "net46": {
     "dependencies": { "System.Runtime": "4.0.20" }
   }
}

It has two frameworks, so library can be used from .net 4.6 and Core. I'm using Func<,> and System.Runtime package has to be added to net46 project.

The problem is, you can Add Project Reference to it from other Core (xproj) project, but not from standard 4.6 project. To use it from 4.6, a package needs to be created and added through nuget. Every time I change something in the Core lib, I have to create the package and re-install it to 4.6 project.

In my case, I added small .bat file to the Core project root, which creates package into a common folder:

dotnet pack -o ../../InternalRepository

Dotnet pack command uses information from project.json to create the package, like id, title, dependency libs, etc. Convenient UI tool for managing nupkg and nuspec files is Package Manager Explorer https://github.com/NuGetPackageExplorer/NuGetPackageExplorer

InternaRepository is folder referenced by solution nuget.config, used by all projects in the solution:

 <configuration>
  <packageSources>
    <add key="Local" value="InternalRepository" />
    <add key="NugetV3" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Note: if you change something in Core project, package needs to be created again and re-installed into 4.6 project. One way is updating build semver (1.0.x) and then update the package, other way is re-installing existing package with (in Package-Manager Console):
Update-Package JA.Pagination -reinstall

Why I didn't just pack Core package into nuget and used that? I wanted to have extension methods for Razor, so pager can be called with just Html.RenderPager(...), instead of Html.Raw(Pager.Build(...).Render()).

Since MVC5 and MVC6 have different HtmlHelper classes, I needed two additional projects, each one targeting different version of MVC and adding extension method to specific HtmlHelper class.

To be honest, I’m still not sure if this is the best way of managing 4.6 and Core projects in the same solution, but it’s the only thing that worked! In case somebody knows better way, I would be happy to hear about it, so please post the comment!

Full source code is available on Github.