Legend
| Static method: int RunPostBuildChecks( |
string | sourcePath | Specifies the path to the folder containing the C# source files. |
Assembly[] | assemblies | Specifies the compiled assemblies from which to run post-build checks. |
In non-DEBUG mode, does nothing and returns 0.
Intended use is as follows:
Add the following line to your project's post-build event:
"$(TargetPath)" --post-build-check "$(SolutionDir)."
Add the following code at the beginning of your project's Main() method:
if (args.Length == 2 && args[0] == "--post-build-check") return PostBuildChecker.RunPostBuildChecks(args[1], Assembly.GetExecutingAssembly());
If your project entails several assemblies, you can specify additional assemblies in the call to
PostBuildChecker.RunPostBuildChecks(typeof(SomeTypeInMyLibrary).Assembly
.
Add post-build check methods to any type where they may be relevant. For example, you might use code similar to the following:
#if DEBUG private static void PostBuildCheck(IPostBuildReporter rep) { if (somethingWrong()) rep.Error("Error XYZ occurred.", "class", "Gizmo"); } #endif
The method is expected to have one parameter of type IPostBuildReporter, a return type of void, and it is expected to be static and non-public. Errors and warnings can be reported by calling methods on said IPostBuildReporter object. (In the above example, PostBuildChecker will attempt to find a class called Gizmo to link the error message to a location in the source.) Throwing an exception will also report an error.