I need to set up monitoring for multiple .NET Core 2.0 web-applications, which are hosted on the same server. As far as I know, you should add environment variables for this, so I added these lines in web.config and New Relic agent started correctly:
<environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" />
<environmentVariable name="CORECLR_PROFILER" value="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" />
<environmentVariable name="CORECLR_NEWRELIC_HOME" value="C:\Program Files\New Relic\.NET Agent NetCore2.0" />
<environmentVariable name="CORECLR_PROFILER_PATH" value="%CORECLR_NEWRELIC_HOME%\NewRelic.Profiler.dll" />
<environmentVariable name="NEW_RELIC_APP_NAME" value="Some App Name" />
However, in ASP.NET Core 2.0 web.config is generated automatically when you publish your app, so it is not a suitable way of defining variables for CI/CD pipeline. Is there any other way to specify those variables somewhere else, for example in appsettings.json? Or how could I add them automatically to autogenerated web.config file?
In my related searches I've found a handy way of setting the variables in my .net core app
"CoreApp": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production",
"CORECLR_ENABLE_PROFILING": "1",
"CORECLR_PROFILER": "{36032161-FFC0-4B61-B559-F6C5D41BAE5A}",
"CORECLR_NEWRELIC_HOME": "PATH_TO_INSTALL",
"CORECLR_PROFILER_PATH": "PATH_TO_INSTALL\\NewRelic.Profiler.dll"
},
See more on the discussion here