Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training

    Featured resources

    • Open Source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Improving ASP.NET Core build speed on Red Hat OpenShift

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

July 10, 2019
Tom Deseyn
Related topics:
.NETKubernetes
Related products:
Red Hat OpenShift

    In previous articles, I’ve covered two strategies for improving .NET Core build speed on Red Hat OpenShift by reducing time to restore dependencies: adding a local NuGet server and using incremental builds. In this article, I’ll look at another strategy: using a custom base image that has includes the dependencies.

    ASP.NET Core

    ASP.NET Core is the de facto framework for building web applications with .NET Core. The framework is open source on GitHub; however, for 1.x and 2.x, it does not have the infrastructure needed for a third party (e.g., Red Hat) to build it from source so that it matches Microsoft releases.

    Building from source is a key feature for open source projects. It reduces vendor lock-in by enabling other companies and communities to build and support the software. The ability to build code from source is a requirement for including packages in the default package repositories of Linux distributions (like Fedora, Debian, and Ubuntu). The upcoming ASP.NET Core 3.0 will be buildable from source!

    Because ASP.NET Core 2.x cannot be built from source, it cannot be included in Red Hat Enterprise Linux packages and Red Hat OpenShift’s .NET Core builder (s2i-dotnetcore). This leads to long restore times because applications need to fetch and extract those packages from nuget.org (or a local NuGet server).

    aspnet image streams

    As a Red Hat OpenShift user, to work around this limitation, you can build a custom image that includes the ASP.NET Core NuGet packages. I’ve written a resource file that does exactly that. You can import it into OpenShift using:

    $ oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/aspnet-2.x.json
    

    If you have a look into the file, you’ll see it defines an aspnet:2.1 and aspnet:2.2 image stream that builds on top of s2i-dotnetcore’s dotnet:2.1 and dotnet:2.2 using a Docker strategy. The ASP.NET Core packages are added by performing a dotnet new web. Because we build on top of the dotnet image streams, the aspnet streams will automatically be rebuilt when the base images are updated with security patches.

    After importing the file, it takes a couple of minutes for the images to be built.

    Let’s compare the difference in build speed by building https://github.com/redhat-developer/s2i-dotnetcore-ex using dotnet:2.2 and aspnet:2.2.

    $ oc new-app --name=dotnetapp dotnet:2.2~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnetcore-2.2 --build-env DOTNET_STARTUP_PROJECT=app
    $ oc new-app --name=aspnetapp aspnet:2.2~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnetcore-2.2 --build-env DOTNET_STARTUP_PROJECT=app
    

    When we do five builds, we get these build times:

    base image min max avg
    dotnet:2.1 43s 1m30s 47s
    aspnet:2.1 23s 31s 24s

    As you can see, the build times are halved using the aspnet image. What’s more, the build time variance is much smaller.

    Conclusion

    We can significantly reduce build times for .NET Core applications by creating a custom build image that includes common dependencies. aspnet-2.x.json provides build configurations that add ASP.NET 2.x Core packages to the s2i-dotnetcore dotnet images.

    Last updated: March 28, 2023

    Recent Posts

    • Red Hat UBI 8 builders have been promoted to the Paketo Buildpacks organization

    • Using eBPF in Red Hat products

    • How we made one data layer serve the UI, the mocks, and the E2E tests

    • Build trusted Python containers with Project Hummingbird and Calunga

    • Simplify distributed tracing: ObservabilityInstaller installation

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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