Install the .NET agent using NuGet

This document explains how to install the .NET agent using NuGet.

Install agent using NuGet

The NewRelic.Agent NuGet package places the New Relic agent in your application's build output directory so that the agent gets deployed with your application.

Before installing the agent using NuGet, understand these important points:

  • In order to configure environment variables and directory permissions, you must have access to the systems where you are deploying your applications.
  • If you're using NuGet to update an existing .NET agent, this will overwrite previously made changes to newrelic.config. To preserve changes, first save the config file outside of your project, then restore it after updating.

Here's an example of using NuGet via Visual Studio to install the .NET agent:

  1. Open your Visual Studio solution, or create a new one by selecting File > New > Project. For multi-project solutions, be sure to select the correct project (for example, a specific website project).
  2. Open the Package Manager console by selecting Tools > Library Package Manager > Package Manager Console. Set your project as the default project.
  3. From the Package Manager command prompt, type Install-Package NewRelic.Agent and press Enter. When you build your project, the .NET agent folder will be copied to your build output directory.
  4. Set environment variables (below) and any other necessary configuration. How to do this will vary, depending on your environment and system.

    Environment variables for monitoring .NET Framework applications
    COR_ENABLE_PROFILING=1
    COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41}
    COR_PROFILER_PATH=APP_DEPLOYMENT_DIRECTORY\newrelic\NewRelic.Profiler.dll
    NEWRELIC_HOME=APP_DEPLOYMENT_DIRECTORY\newrelic
    NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
    NEW_RELIC_APP_NAME=YOUR_APP_NAME

    To monitor 32-bit applications, COR_PROFILER_PATH should be set to APP_DEPLOYMENT_DIRECTORY\newrelic\x86\NewRelic.Profiler.dll

    The license key and app name aren't required environment variables; they can be set in other ways.

    Environment variables for monitoring .NET Core applications on Windows
    CORECLR_ENABLE_PROFILING=1
    CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A}
    CORECLR_PROFILER_PATH=APP_DEPLOYMENT_DIRECTORY\newrelic\NewRelic.Profiler.dll
    CORECLR_NEWRELIC_HOME=APP_DEPLOYMENT_DIRECTORY\newrelic
    NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
    NEW_RELIC_APP_NAME=YOUR_APP_NAME
    

    To monitor 32-bit applications, CORECLR_PROFILER_PATH should be set to APP_DEPLOYMENT_DIRECTORY\newrelic\x86\NewRelic.Profiler.dll

    The license key and app name aren't required environment variables; they can be set in other ways.

    Environment variables for monitoring .NET Core applications on Linux
    CORECLR_ENABLE_PROFILING=1
    CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A}
    CORECLR_PROFILER_PATH=APP_DEPLOYMENT_DIRECTORY/newrelic/libNewRelicProfiler.so
    CORECLR_NEWRELIC_HOME=APP_DEPLOYMENT_DIRECTORY/newrelic
    NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
    NEW_RELIC_APP_NAME=YOUR_APP_NAME
    

    The license key and app name aren't required environment variables; they can be set in other ways.

If your application is receiving traffic, data should appear within a few minutes. If it doesn't, see No data appears.

For more help

Recommendations for learning more: