5

I have TeamCity running MSBuild task for an ASP.NET MVC 3 application. Now every now and then (seemingly randomly) it throws "ASPNETCOMPILER : error ASPRUNTIME: The application domain in which the thread was running has been unloaded.". It happens when MSBuild executes "MvcBuildViews" and runs aspnet_compiler.exe.

Now I know there is an "-errorstack" switch for aspnet_compiler.exe (http://msdn.microsoft.com/en-us/library/ms229863(vs.80).aspx) that can give me stack trace information about this error, but it seems that AspNetCompiler Task does not expose possibility to set this attribute (http://msdn.microsoft.com/en-us/library/ms164291.aspx).

So my question is - is there a way to pass any custom attribute to existing MSBuild Task or I have to run aspnet_compiler.exe manually outside MSBuild to enable -errorstack feature ?

Dawid Kowalski
  • 1,197
  • 1
  • 9
  • 23
  • I came across a tip that may help in your situation -- It is probably worth a try. In Visual Studio, go to Tools -> Options -> Projects And Solutions (Check the box "Show All Settings" if you cannot find it) -> "Build and run". Then set the output verbosity to Diagnostic. Open the output window (Ctrl-Alt-O) and perform a build. – David Tansey Mar 21 '13 at 23:25
  • Thx for the tip David, in our case though problem was happening on a build server only so extra Diagnostics in Visual Studio wouldn't be of so much help. Anyway I think we had found a culprit, I will write a response below. Cheers. – Dawid Kowalski Mar 22 '13 at 10:00

2 Answers2

3

We had found a reason for this error (but not really how to add a custom attributes to MSBuild Tasks). It seems that this exception is happening when build servers are running low on memory.

Dawid Kowalski
  • 1,197
  • 1
  • 9
  • 23
3

You can achieve this by using the Exec MSBuild task in your csproj file. For example the original task:

<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />

becomes:

<Exec Command="$(MSBuildFrameworkToolsPath)\aspnet_compiler.exe -v temp -errorstack -p $(WebProjectOutputDir)" />
Josef Bláha
  • 1,033
  • 10
  • 21