8

Background

I've taken over a very large asp.net website project. The old deploy process was to copy .cs, .aspx, and .ascx files to IIS and have it build on the fly. I want to precompile it and use TeamCity to automatically deploy it. I've done this with some of the other website projects.

The project has about 350 user controls that are nicely organized in folders but are used all over the place. Controls referenced from other folders, from each other... Basically a circular file reference nightmare.

My Attempt

My first attempt was to build it like the others. MSbuild the whole vs2012 solution. I ran into tons of "circular file references are not allowed". Come to find out all these nicely organized controls are used everywhere and there are circular references are all over the place. I read this and I switched the "web.config" to compilation batch="false" and then in the build set the site to "not be updateable" and "use fixed naming assemblies". The site builds but takes literally 25 minutes to compile on my quad core, ssd, 16gb ram dev box. This is unacceptable build times.

I know that if I turn off "use fixed naming assemblies" that the site would build significantly faster. (I've proven it on one of the smaller websites. It went from 4 minutes to 45 seconds). When I do remove that setting I'm getting weird build errors:

c:\Projects\Web\Site.master(146): error CS0433: The type 'ASP.usercontrols_modules_viewprofilepopup_ascx' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_viewprofilepopup.ascx.4101713c.dll' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_xa514so5.dll'

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_site.master.cdcab7d2.0.cs(927): error CS0433: The type 'ASP.usercontrols_modules_viewprofilepopup_ascx' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_viewprofilepopup.ascx.4101713c.dll' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_xa514so5.dll'

error ASPPARSE: c:\Projects\web\Web\UserControls\Modules\JobsLeftMenu.ascx(128): error CS0433: The type 'ASP.usercontrols_modules_imagesgallerymodule_ascx' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_imagesgallerymodule.ascx.4101713c.dll' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_nvrj33tx.dll'

error ASPPARSE: c:\Projects\web\Web\Site.master(146): error CS0433: The type 'ASP.usercontrols_modules_viewprofilepopup_ascx' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_viewprofilepopup.ascx.4101713c.dll' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\web\8d37b2c6\4c39f0a\App_Web_xa514so5.dll'

Here is the exact aspnet_compiler.exe command:

aspnet_compiler.exe -v /web -p Web\ -f "Precompiled Web"

I googled around for answers. NO, they aren't duplicated in the code anywhere. They just happen to be in different folders, used by other controls in different folders. I have a feeling this is due to the circular file reference thing. Ok... Fine. I removed the usage of a few of these to see if it would build and the build process just moves onto other errors just like this one. I can't just remove code all over to accommodate this... How can I fix these errors without turning on "use fixed naming assembilies"?

Thing's I've Tried

  1. Cleared the Temporary ASP.NET Files all throughout my system.
  2. Tried a "publish" right from within visual studio 2012. Same errors.
  3. Tried converting the site to a Web Application but got too many errors (upwards of 600+).
  4. Again: made sure that there was no duplicate files and code that would explain it. I text searched the entire solution folder with notepad++ to validate that there wasn't another control with the same name.
  5. Checked this.
  6. I have msbuild performance tweaks turned on: /m /p:CreateHardLinksForCopyLocalIfPossible=true /p:BuildInParallel=true

I'm stumped and seem to think my only option is to rewrite the app, slog through the errors as I convert to a Web Application, or continue deploy source to the webserver but do it automated.

Paul Lemke
  • 5,494
  • 3
  • 47
  • 66
  • Is the error output you list above what you got from running aspnet_compiler? I would have expected to see the circular reference error instead. – David Ebbo Feb 11 '13 at 21:51
  • @DavidEbbo That error is caused by running with web.config: compilation batch="false" and msbuild without "fixednames". – Paul Lemke Feb 11 '13 at 22:27
  • So then under what condition are you instead seeing the `Circular file references are not allowed` error? When testing a trivial circular scenario, that's what I get. – David Ebbo Feb 11 '13 at 23:28

1 Answers1

8

I known you've tried that already, but avoiding the circular references is going to be your best bet here. Note that the term 'circular reference' is actually not quite correct. What the build system complains about is circular references at the directory level, not the file level.

e.g. sub1\page.aspx uses sub2\uc1.ascx uses sub1\uc2.ascx

At the file level, there is no circle, but at the directory level there is, and that messed up with the way batching works.

While it may seem like you have so many of these situations as to make it unfixable, I'd bet that if you look at the details of the 'directory circles', it's down to not all that many. Drawing the reference graph might help make sense of things.

Then you just need to move the offenders into a different folder and change the links accordingly.

Yes, it's a painful process, but it is likely solvable.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Would moving all the controls into one folder fix the issue too? Also, would that fix "The type 'blah' exists in both 'blah'" error? – Paul Lemke Feb 13 '13 at 14:31
  • 1
    Yes, moving all controls into one folder would fix it, though that might involve adjusting a lot of references. It will also fix the 'type exists in 2 places' error. Note that you might have both parse time references (@register directive) and runtime references (e.g. LoadControl()). You only need to fix the first part to compile, but you'll need the rest to actually run. – David Ebbo Feb 13 '13 at 18:30