NmpCore MSBuild Task
An MSBuild task is available that can be used to run NmpCore when building a project using MSBuild. The NmpCore task is available in the following NuGet packages:
SciTech.NmpCore.Task:
Includes the free NmpCore tool and the NmpCore MsBuild task.SciTech.NmpCore.TestProject:
Includes a .NET Memory Profiler test project that will automatically run unit tests under NmpCore after build. To activate the NmpCore select "NmpCore" as the build action for the file ProfileTest.prfproj.
To run the NmpCore task explicitly in a project, the NmpCore task can be added to a target like this:
<Target Name="RunNmpCore">
<NmpCore Project="SomeProfilerProject.prfproj" />
</Target>
This target will start profiling a process based in the settings in the provided profiler project.
The NmpCore NuGet package includes a target that will run NmpCore on all files in the NmpCore item group. A profiler project can be added to the NmpCore items by selecting the build action NmpCore. The target forwards the following MSBuild properties to NmpCore:
TargetPath, TargetDir, TargetName, TargetFileName
ProjectPath, ProjectDir, ProjectName, ProjectFileName
ConfigurationName
These properties can be used in the profiler project using the MSBuild property syntax, e.g. $(TargetPath)
.
Using a profiler project is the easiest way of specifying the process to profile, but it is also possible to specify profiling settings using the task properties. Most of the properties maps directly to a corresponding NmpCore command line argument. For more information about the command line arguments, see Command Line Arguments.
Below is a list of the available properties:
NmpCore task property | Corresponding command line argument |
---|---|
AppPoolNames | /apppools |
AttachToProcess | /attach |
AttachType | /attachtype |
AutoCollectInterval | /autocollect |
AutoCollectStopCount | /collectandstop |
CollectRealTime | /collectrealtime |
DisableInlining | /disableinlining |
EnableAllocationCallStacks | /callstacks |
EnableDisposeTracker | /disposetracker |
EnableResourceTracker | /resourcetracker |
IisExpressConfig | /iisexpressconfig |
IncludeInstanceData | /includeinstancedata |
InstanceTracking | /instancetracking |
MaxTriggeredSnapShots | /maxsnapshots |
MemLeakCollectFullSnapshot | /memleakcollect |
MemLeakHaltThread | /memleaksuspend |
MemLeakStopSession | /memleakstopsession |
PassThroughExitCode | /passthrough |
PeakMemoryThreshold | /peaksnapshotthreshold |
ProcessFilter | /profileprocess |
ProfilingLevel | /profilinglevel |
ProfilingType | /profilingtype |
ProgramArguments | (arguments provided to the profiled process) |
ProgramPath | /program |
Properties | /properties |
RequestUrl | /requesturl |
SaveProject | /saveproject |
ServiceName | /service |
SessionEndAction | /sessionend |
SessionFile | /sessionfile |
ToolPath | /toolpath |
TrackAppDomains | /appdomaintracker |
TrackHeapUtilization | /heaputil |
TrackPeakMemory | /peaksnapshot |
WinStoreAppUserModelId | /winstorepackage |
WinStorePackageId | /winstoreapp |
WorkingDirectory | /workingdirectory |
The SciTech.NmpCore.TestProject NuGet package includes a profiler project that can be used to profile a unit test project. The profiler project can be edited using the XML-editor in Visual Studio, or by opening the project in .NET Memory Profiler. If using the XML-editor, it is recommended that only the StartInfo and SessionSettings are modified. The test project contains comments about the settings that can be modified, e.g. how to change the unit testing framework.