Skip to content
Abandoned - Strips all testing code from an assembly
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Chat on Gitter NuGet Status

Test Remover addin for Fody


Strips all testing code from an assembly


See also Fody usage.

NuGet installation

Install the Scalpel.Fody NuGet package and update the Fody NuGet package:

PM> Install-Package Fody
PM> Install-Package Scalpel.Fody

The Install-Package Fody is required since NuGet always defaults to the oldest, and most buggy, version of any dependency.

Add to FodyWeavers.xml

Add <Scalpel/> to FodyWeavers.xml


What it actually does.

When the compilation constant Scalpel is detected. (Requires Fody version 1.11.5 or higher)


  • Removes all types ending in Tests.
  • Removes all types ending in Mock.
  • Removes all types marked with Scalpel.RemoveAttribute.
  • Removes all references as defined in <Scalpel RemoveReferences='XXX'/> see below.


  • Removes all types marked with any Nunit attribute.
  • Remove the NUnit reference.


  • Removes all types containing an XUNit attribute.
  • Removes the Xunit reference.


  • Removes all types containing a field from Machine.Specifications or Machine.Specifications.Clr4
  • Removes the Machine.Specifications.Clr4 and Machine.Specifications references.
  • Removes all types that implement ISupplementSpecificationResults, IAssemblyContext or ICleanupAfterEveryContextInAssembly.


  • Removes the reference to NSubstitute.


  • Removes the reference to FakeItEasy.


  • Removes the reference to Moq.

But WHY?

When coding any tests then these tests should be a first class citizen to the functionality you are creating. As such it makes sense for them to be co-located with the code being tested. Unfortunately due to the nature of .net this is very difficult to achieve. The reason is that if you place tests next to the code being tested you and up having those tests include in your deployable assembly. You also have the problem of your assembly referencing unit test helper libraries like NUnit and Moq.

So Scalpel helps you work around the above problem by striping tests and references from your assembly. It also has the added side effect of allowing you to test internal types without needing to use the InternalsVisibleToAttribute.

But how do I test my deployable artifacts

One problem with this approach is testing your deployable artifacts if the tests are removed from them.

This is a legitimate problem. The recommended approached it to create another build configuration call Deployable. It can have all the same settings as your Release configuration with the addition of the Scalpel compilation constant. This way tests can run from your Release configuration and you can deploy from your Deployable configuration.

Configuration Options

All configuration options are access by modifying the Scalpel node in FodyWeavers.xml


A list of assembly names to removed at compile time.

Do not include .exe or .dll in the names.

Can take two forms.

As an element with items delimited by a newline.


Or as a attribute with items delimited by a pipe |.

<Scalpel RemoveReferences='Foo|Bar'/>


Exacto Knife designed by Edward Boatman from The Noun Project.

You can’t perform that action at this time.