Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error CS0433 in large precompiled Asp.net Website Project

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.

like image 914
Paul Lemke Avatar asked Feb 09 '13 02:02

Paul Lemke


1 Answers

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.

like image 60
David Ebbo Avatar answered Sep 19 '22 15:09

David Ebbo