Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom attributes to MSBuild Task

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 ?

like image 840
Dawid Kowalski Avatar asked Mar 15 '13 11:03

Dawid Kowalski


2 Answers

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)" />
like image 42
Josef Bláha Avatar answered Oct 13 '22 19:10

Josef Bláha


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.

like image 123
Dawid Kowalski Avatar answered Oct 13 '22 20:10

Dawid Kowalski