Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

.NET Core Magic: Develop on one OS, run on another

June 19, 2017
Don Schenck
Related topics:
.NET

Share:

    I recently attempted to write a blog post about Angular and .NET Core 2.0 [Note: It will be posted as soon as the .NET Core 2.0 RPMs are released], using my Red Hat Enterprise Linux (RHEL) VM as the operating system. Even though the .NET Core 2.0 bits are not available yet from Red Hat, I gave it a shot by using a daily build. When I tried to run the code, however, I got an error related to the Roslyn compiler. Sometimes, when you play with fire -- i.e. a daily build -- you get burned.

    And that's when the creative juices, combined with the knowledge of .NET Core's Self-contained deployment technology (you might also see it referred to as a "Standalone app") came to the rescue.

    Since everything was working in Windows, what if I created, debugged and built the application on my Windows 10 machine, but deployed it to my RHEL VM? I don't have docker for Windows on my PC, so I'd have to use some command line wizardry to pull this off. As it turns out the wizardry was as simple a third-grade magic trick.

    Creating the Angular App

    Creating the angular app was one command: dotnet new angular. Boom ... Angular app. Granted, it's just scaffolding and a tiny demo app, but hey ... this is about the underlying technology, not the app itself. Sometime in the future... (Dreams of writing a fantastic app using Angular, then remembers his existing technical debt) ... yeah, where was I?

    Creating the Angular app/scaffolding yields the following, by the way:

    Running the Angular App

    At this point, all I need to do is restore the dependencies and run the program:

    Success! Now I simply open my browser and point it to localhost:5000 and I have my Angular app. Here's the browser screenshot:

    Wait. What happened? This is supposed to be easy!

    Flipping over to the PowerShell session where I launched my app, I found the following error:

    Chocolatey to the Rescue

    Aha! Angular needs Node.js to be installed. And this brought me to the coolest part of this exercise. On a whim, based on experience and knowing how things are supposed to work, I tried the following command to install Node.js: choco install nodejs ... and it worked!

    Up and Running on Windows

    I then ran refreshenv (as chocolatey was kind enough to suggest) to reload my environment variables and PATH settings and tried running dotnet run again. I refreshed my browser (which was still looking for localhost:5000) and was rewarded with a running app:

    Running the Build on RHEL

    So after installing Node.js, the app is running. Now I can build it to run on RHEL by using the following command: dotnet publish -c Release -r rhel.7.2-x64. This creates a DLL in a directory under the project:

    Because I have the directory (bin/Release/netcoreapp1.1/rhel.7.2-x64/publish) shared between my Windows 10 host machine and the RHEL VM, I can switch over to the VM and run the DLL.

    But it occurs to me: I'll need Node.js on my RHEL VM as well if I want this to work.

    So, hopping over to my RHEL VM, I installed Node.js using the following commands (which I found at the Node.js website):
    [Note: I had to log in as super user (su) in order for these commands to work.]

    curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
    yum -y install nodejs

    Now that my RHEL VM has Node.js installed, I should be able to run the DLL that I compiled from within Windows: The application, compiled on my Windows PC, is running on Linux. That is pretty cool.

    Exposing the Web Site

    But here's the only problem: It's using localhost. I need to expose the web server so it can be reached from outside of my VM, i.e. a browser running on my Windows PC. To accomplish this, I can use an environment variable, ASPNETCORE_URLS, as follows:

    export ASPNETCORE_URLS="http://*:5000"

    Now when I run bin/Release/netcoreapp1.1/rhel.7.2-x64/publish/angular on my Linux VM -- remember, the code was compiled on my Windows PC -- I have the following:

    Finally, I can point my browser to the IP address of the VM and see the Angular website, compiled on Windows, running on RHEL:

    Review

    To review: In this particular case, the need to install Node.js complicated the issue. In a "Happy Path" scenario, it's as simple as this:

    1. Build the code on your Windows PC, targeting RHEL.
    2. Install (or share) the created DLL on your RHEL system.
    3. Run the app on your RHEL system.

    Hmmm ... can this code run in a Linux container now? That's for my next blog entry.

    For additional information and articles on .NET Core visit our .NET Core web page for more on this topic.


    If you know the basic commands of Linux then download the Advanced Linux Commands Cheat Sheet, this cheat sheet can help you take your skills to the next level.

    Last updated: September 3, 2019

    Recent Posts

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    • How to debug confidential containers securely

    • Announcing self-service access to Red Hat Enterprise Linux for Business Developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue