.NET Core on Linux with ServiceWire

After a BIOS update, I was able to get Hyper-V working on my Windows 10 Pro machine and spun up an Ubuntu 16.04 instance. Once it was up and running I just followed the .NET Core Linux install instructions. No other changes to the VM.

Using the Portable Application instructions on the new docs.microsoft.com site for .NET Core, I executed the following commands to prep the CoreTestClient1 project for deployment to the Linux VM with my command prompt in the root directory of the project.

dotnet restore

and then

dotnet publish -f netcoreapp1.0 -c release

From there it was just a matter of copying the files in the \bin\Release\netcoreapp1.0\publish folder to a new folder called test1 on the Linux VM using an smb local file share.

After spinning up a debug instance of CoreTestHost on my Windows machine in Visual Studio, I tried to run CoreTestClient1 in the Ubuntu VM first without the extension. Oops. Then got it right and then tried it again just our of sheer delight.

linuxdotnet

The results are not particularly impressive as I was running on a VM with a single core, but the fact that it ran and without a hitch was enough to make me very happy. With a single day of porting to .NET Core and one more to remember how to install and use Linux on a Windows Hyper-V virtual machine and not a single bug that had to be fixed, I was able to complete the following essential requirements using only .NET Core, C# and ServiceWire

Requirements

  • Write an interface in a class library project called Common.
  • Write an implementation for that interface in class library project called Impl.
  • Write a console app that will host the implementation in a project called Host.
    • This project may reference Common and Impl.
    • Using ServiceWire allow remote calls to the implementation of the interface.
  • Write a console app called project Client.
    • This project may only reference Common.
    • Using ServiceWire, connect to Host and call the methods on the interface.
    • Write the results to the console.
  • Write all of this code on a single Windows machine with Visual Studio.
  • Run the Host project on the Windows machine.
  • Deploy the Client project to a Linux machine and run it from the Linux shell.
  • No tricks. You may not use Mono.

For examples of the code that you might find in the Host and Client, have a look at my previous post.

What’s Next?

Next I will be working on producing a NuGet package for ServiceWire 5.0.

Final Confession
It wasn’t quite all that smooth as I had not touched Linux or Hyper-V in years, so there were a few bumps, including a hosed up virtual network adapter that left my first Ubuntu install crippled. I also tried building and deploying a self contained app which required changes to the project.json file, but I gave it up as folly since I had already installed .NET Core on the Linux VM. And after deploying the portable app the first time, I was trying to run the app with “dotnet run” rather than “dotnet {assemblyFileName}” and of course that did not work. All told, I spent about 6 to 8 hours on all of this but that was broken up by multiple distractions so it required two calendar days. Now that the learning curve has been climbed, the next time out of the box should be much easier. And I hope this post will help you. I know it will serve well as a bookmark for me the next time I climb this curve. And that should be soon.