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

Welcome to Red Hat Enterprise Linux, MSBuild, a build tool for .NET Core CLI!

 

January 6, 2017
Takayoshi Tanaka
Related topics:
.NETLinux
Related products:
Red Hat Enterprise Linux

Share:

    Microsoft announced the first "alpha" release of the new MSBuild-based .NET Core tools. .NET Core SDK which can be downloaded from the Red Hat Developer Program site consists of .NET Core Runtime and .NET Core command line tools (.NET Core CLI). (Reminder - you must have a Red Hat Enterprise Linux subscription first.  If you don't, you can go here for a no-cost subscription.) The MSBuild tool is included in .NET Core 1.0 preview 3 (not in the latest release .NET Core 1.1). The version number is something complicated because .NET CLI is not GA but still under preview. The MSBuild tool can be used with both .NET Core 1.0 and .NET Core 1.1 runtimes. RHEL is not listed in the .NET Core SDK 1.0 Preview 3 download list. But you can try MSBuild with the .NET Core CLI daily build.

    NOTE: Red Hat has just released .NET Core 1.1. However, .NET Core 1.1 doesn't include the MSBuild tool, you can try MSBuild following this blog.

    Install .NET Core daily build

    We can get the download link in the dotnet/cli repository. This build is now under development as preview 5. After downloading the latest .NET Core SDK Binaries for RHEL 7.2, please execute the following commands to install.

    $ sudo mkdir -p /opt/dotnet
    $ sudo tar zxf dotnet.tar.gz -C /opt/dotnet
    $ sudo ln -s /opt/dotnet/dotnet /usr/local/bin

    You can update the SDK again with the same commands above after downloading a new binary when a new daily build is available. If you have already installed the .NET Core SDK via Red Hat Software Collections or other places, please be sure to configure the PATH environmental variable. Here is my environment.

    $ which dotnet
    /opt/dotnet/dotnet
    $ dotnet --info
    .NET Command Line Tools (1.0.0-preview4-004130)
    
    Product Information:
     Version:            1.0.0-preview4-004130
     Commit SHA-1 hash:  a0060ac321
    
    Runtime Environment:
     OS Name:     rhel
     OS Version:  7.3
     OS Platform: Linux
     RID:         rhel.7.2-x64
     Base Path:   /opt/dotnet/sdk/1.0.0-preview4-004130

    Working with csproj

    The new dotnet CLI tools generate csproj instead of project.json.

    $ dotnet new
    Created new C# project in /home/tanaka-takayoshi/MSBuildSample.
    $ ls
    MSBuildSample.csproj  Program.cs

    "dotnet restore" and "dotnet run" are the same as before.

    $ dotnet restore
      Restoring packages for /home/tanaka-takayoshi/MSBuildSample/MSBuildSample.csproj...
      Writing lock file to disk. Path: /home/tanaka-takayoshi/MSBuildSample/obj/project.assets.json
      Generating MSBuild file /home/tanaka-takayoshi/MSBuildSample/obj/MSBuildSample.csproj.nuget.g.targets.
      Generating MSBuild file /home/tanaka-takayoshi/MSBuildSample/obj/MSBuildSample.csproj.nuget.g.props.
      Restore completed in 486.995ms for /home/tanaka-takayoshi/MSBuildSample/MSBuildSample.csproj.
    
      NuGet Config files used:
          /home/tanaka-takayoshi/.nuget/NuGet/NuGet.Config
    
      Feeds used:
          https://api.nuget.org/v3/index.json
    $ dotnet run
    Hello World!

    Now let's look into the csproj, in the csproj of .NET Core, we can include all the source files with wildcard although we must include all the source files separately in the original csproj of .NET Framework.

    <ItemGroup>
        <Compile Include="**\*.cs" />
        <EmbeddedResource Include="**\*.resx" />
      </ItemGroup>

    Next, if you add NuGet library to your project, you have to add ItemGroup/PackageReference element. Then execute "dotnet restore" command.

    <ItemGroup>
        <PackageReference Include="NewtonSoft.Json">
          <Version>9.0.1</Version>
        </PackageReference>
      </ItemGroup>

    Migrate project.json

    If you have project.json style project, you can migrate it to csproj and only have to execute the "dotnet migrate" command. This command converts without confirmation, but you can restore the original project.json file under backup directory.

    $ ls
    Program.cs  project.json
    $ dotnet migrate
    Project Migrate migration succeeded (/tmp/Migrate)
    Summary
    Total Projects: 1
    Succeeded Projects: 1
    Failed Projects: 0
    
    $ ls *
    Migrate.csproj  Program.cs
    
    backup:
    project.json

    Visual Studio Code Support

    Visual Studio Code C# extension now supports csproj file. This is the initial support and I'm looking forward to more features like intelisense support in csproj.

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

    Takayoshi Tanaka

    About the author:

    Takayoshi Tanaka is a Software Maintenance Engineer at Red Hat. He is mainly in charge of OpenShift, .NET Core on Red Hat Enterprise Linux and Red Hat solutions on Microsoft Azure. He is a Microsoft MVP for Visual Studio and Development Technologies. He writes many articles in his personal blog and web sites, and also provides many technical sessions at community events.

    Last updated: March 22, 2023

    Recent Posts

    • Profiling vLLM Inference Server with GPU acceleration on RHEL

    • Network performance in distributed training: Maximizing GPU utilization on OpenShift

    • Clang bytecode interpreter update

    • How Red Hat has redefined continuous performance testing

    • Simplify OpenShift installation in air-gapped environments

    What’s up next?

     

    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