views:

676

answers:

3

Hi

When Compiling my Web Deployment Project which references a Asp.Net project with a App_Browsers folder I get the following compilation error:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /[PROJECTNAME].csproj -p "[FILEPATH]" -u -f -d .\TempBuildDir\ ASPNETCOMPILER : error ASPRUNTIME: Object reference not set to an instance of an object.

If I remove the App_Browsers folder everything works perfectly.

Any help would be appreciated.

+1  A: 

Ok, finally found a solution.

As stated the aspnet compiler crashes when including the App_Browsers folder. So to avoid that, I have excluded the folder from the build and put in an "after build" action which copies the folder to the destination. This is done by adding the following lines of code to the deployment project file:

  <ItemGroup>
      <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\App_Browsers\**\*.*"/>
      <MySourceFiles Include="$(SourceWebPhysicalPath)\App_Browsers\**\*.*"/>
  </ItemGroup>
  <Target Name="AfterBuild">
      <MakeDir Directories="$(OutputPath)\App_Browsers"></MakeDir>
      <Copy SourceFiles="@(MySourceFiles)" 
            DestinationFiles="@(MySourceFiles->'$(OutputPath)\App_Browsers\%(RecursiveDir)%(Filename)%(Extension)')">
      </Copy>
  </Target>

Hope it helps others, stuck with the same problem.

A: 

wow,thanks man, i was stuck with this big time i wouldn't have guessed it's the damn App_Browsers if i may ask how did u figure it out? anyway god bless microsoft for their weird errors, can't imagine my life without them.

mm
A: 

Check out this page: http://mdbf.codeplex.com/Thread/View.aspx?ThreadId=67453

Turns out this error occurs when the mobile.browser file is placed in the App_Browsers root folder, so just make a sub directory for it, i.e. instead of

App_Browsers
    -> mobile.browser

use this:

App_Browsers
    -> Mobile
        -> mobile.browser
Darren Oster