It is possible to compile C# code at runtime using the CSharpCodeProvider Class, look at this article, it is well explained. Although by the sound of it looks like you want to change (e.g. to weave) your library by injecting the code you are compiling in your AfterBuild task event.
If that is the case the only way to achieve what you want to do is to use an AOP (Aspect Oriented Programming) framework like PostSharp or Mono.Cecil. What they do is generating IL (Intermediate Language) and injecting at run-time or at compile time into your program.
In this answer are discussed a few AOP solutions for .NET.
EDIT:
To compile c# project (*.csproj) programmatically there are specific classes in the .NET framwork. Look at the Microsoft.Build.Evaluation namespace.
However this snippet should work for you. Try it in your Task and you should be able to fire another compilation process from your code.
const string projectPath = @"your csproj path";
var collection = new Microsoft.Build.Evaluation.ProjectCollection {DefaultToolsVersion = "4.0"};
collection.RegisterLogger(new ConsoleLogger());
collection.LoadProject(projectPath);
var project = new Microsoft.Build.Evaluation.Project(collection);
if (!project.Build())
{
//Error
}
hope it helps.