Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat 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
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud 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

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • 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

All Together Now: .NET, RHEL, Hyper-V and VSCode

May 16, 2016
Don Schenck
Related topics:
.NETLinux
Related products:
Red Hat Enterprise Linux

Share:

    I'm a .NET developer at heart, and I want to write C# code that runs natively in Linux - Red Hat Enterprise Linux (RHEL), to be specific. So, I hopped over to the Red Hat .NET Developers web site, installed the CDK and was up and running in short order. I had a no-cost developer's copy of RHEL running on my PC and was writing .NET code. Life was good. I had my instance of RHEL inside a Vagrant Box on my Windows 10 PC. It was easy to set up and quick to get going, but I have to admit it did feel a bit odd to be running Oracle's VirtualBox on my PC when I had Microsoft's Hyper-V at hand.

    In addition, I wanted to edit my code using Microsoft's free Visual Studio Code, which meant sharing a folder/directory between the RHEL instance and my Windows 10 host. (Windows folks call them "folders"; Linux folks prefer "directories"). However, after struggling and finding no good success at a "no-touch" folder sharing solution (I didn't like the "use rsync" option - I wanted something automatic), and because I felt using RHEL in a Hyper-V Virtual Machine (VM) seemed like a cleaner solution, I created the RHEL VM and started down that path.

    I ran into the first challenge when I tried to run dotnet restore; it would hang.

    For those of you who aren't familiar with the .NET CLI tools, when you run "dotnet restore", the .NET CLI will retrieve all of the dynamically linked libraries (DLLs) that are listed in your "project.json" file. Where the restore command will search for libraries is determined by the contents of the file NuGet.Config. By default - that is, when you run "dotnet new" for the first time to create a new project - the generated config file will point to nuget.org to look for the libraries. You can, of course, alter NuGet.Config to look anywhere, including a local drive. This is valuable in an environment where you do not want to pull the latest versions of libraries, or where your team uses a shared repository.

    So, in summary: I did everything by the book: Installed the .NET CLI, ran dotnet new, dotnet restore, and it just sat there. I was suspicious because restore really just downloads libraries, so I tried accessing to look up the nuget.org IP address via CURL, and as it turns turns out, the issue was actually with IPv6 - CURL timed out, too.

    My solution -- at this point I'm not sure if this is the right solution -- was to set my system's preference to use IPv4 before using IPv6 in my RHEL VM. I did this by editing the /etc/gai.conf file, adding the line

    precedence ::ffff:0:0/96  100

    That did the trick; dotnet restore ran fine and I was ready to run my program. Then I typed dotnet run and my app ran successfully:

    The next step was to share a folder between the host Windows system and the guest VM. Note that this is typically not something you want to do in a virtual machine environment, because it opens up a big security risk. For our needs (local development), however, this is okay; we are simply working on code within the confines of our own machines.

    On my RHEL VM, I installed the proper packages to support Server Message Block (SMB) volumes:

    sudo yum install -y samba-client samba-common cifs-utils

    I then shared a folder on my Windows 10 PC:

    On my RHEL VM, I created a directory into which to map my Windows shared folder using the mkdir command:

    mkdir ~/mnt

    Then I mounted it in my RHEL VM, using the IP address of my Windows 10 host and the path to the shared folder via the following command:

    sudo mount.cifs //10.0.0.21/shared ~/mnt/ -o username=user_here

    Then, back to my RHEL VM to clone my GitHub repository, I ran:

    git clone https://github.com/DonSchenck/DotNetOnLinux.git

    And moved into the /DotNetOnLinux/cli-samples-master/Speakr folder to run:

    dotnet restore

    Followed by:

    dotnet run

    And my web site was up and running!

    Switching over to the Windows file explorer, it was encouraging to see files that we created and accessible.

    Finally, I opened PowerShell, navigated to C:\shared\DotNetOnLinux\cli-samples-master\Speakr and opened the folder using Visual Studio Code with the handy code command:

    The code command will run VSCode open open the current folder in a treeview:

    At this point, I can edit the code in VSCode in Windows, then switch to RHEL to run the code.

    Wait! Wouldn't it be better to do all this in RHEL? And is that a program breakpoint in the screen capture above? Can you really edit and debug your .NET code in Linux?

    That's for another blog post :)

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

     

    Last updated: March 15, 2023

    Recent Posts

    • Skopeo: The unsung hero of Linux container-tools

    • Automate certificate management in OpenShift

    • Customize RHEL CoreOS at scale: On-cluster image mode in OpenShift

    • How to set up KServe autoscaling for vLLM with KEDA

    • How I used Cursor AI to migrate a Bash test suite to Python

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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