Using the AspNetCompiler class
<p>I am trying to precompile an ASP.NET web site (not web application project) using the AspNetCompiler class, so that I don't have to run the aspnet_compiler.exe command directly.</p>

<p>The MSDN reference is here:  <a href="http://msdn.microsoft.com/en-us/library/ms124552.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms124552.aspx</a></p>

<p>Has anyone gotten this to work?</p>

<p>The code I'm trying to run is:</p>

<pre><code>AspNetCompiler anc = new AspNetCompiler();
anc.PhysicalPath = physicalPath;
anc.TargetPath = targetPath;
anc.VirtualPath = "/";
anc.Execute();
</code></pre>

<p>It errors with this:</p>

<p>Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Build.Utilities.TaskLoggingHelper.LogExternalProjectStarted(String message, String helpKeyword, String projectFile, String targetNames)
   at Microsoft.Build.Tasks.AspNetCompiler.Execute()</p>
