Rectangle 27 0

The only thing precompilation does is compile the views. The fact that this happens only when precompilation is set means that there's something in one of your views that is generating this error. That's kind of irrelevant, though.

The best way I've found to correct this particular error is to uninstall and reinstall the offending Nuget package.

Just go into the Package Manager Console, make sure the project that generates the error is selected for "Default Project", and then run:

> Uninstall-Package DotNetOpenAuth.Core -Force
> Install-Package DotNetOpenAuth.Core

That should resolve the issue and allow your site to publish and run fine, with or without precompilation.

Good advice perhaps for most. I discovered that by not publishing the Web.config file, a personal choice, that such was never copied to the temporary location, hence the binding redirects were not being made, and simplying including this made the pre-compilations succeeded.

razor - VS 2012 MVC Web App Publish fails when Precompilation set - St...

visual-studio-2012 razor asp.net-mvc-5 precompile
Rectangle 27 0

Solution: It turns out that since I wasn't publishing the Web.config file, that the binding redirects were not being made. The solution was to change this file back to being published (Build Action from "None" to "Content"), and then the pre-compilation was succeeding.

For others with an MVC or ASP.NET web site that runs slow each time hitting a new page/view, I'd recommend giving this pre-compilation feature with publishing a try. It's just hidden under file options in the publication settings (VS 2012.) I chose to Precompile, and to make the site not-updatable to avoid the dynamic view/page compilations. See for more information: What effect does the new precompile during publishing option have on MVC4 applications? .

Also, to push the correct settings and connection strings to Live and Test I started using the Translation Templates "Web.Release.config" and "Web.Debug.config". These will swap out Web.config lines when deploying only. See http://go.microsoft.com/fwlink/?LinkId=125889 for more information.

I recently had another problem with precompile on publish. I was getting a CS1528, because a view had "ViewBag.En" on a code line. Clearly someone started typing something that they never finished (and checked in), but it builds and other pages run fine locally when you aren't trying to pre-compile the views...

So, if you've been able to publish precompiled previously, and suddenly it starts having problems, consider the fact that the precompile on publish compile errors are very likely within your views. The Likely culprit is then likely in the same folder as the last precompiled item, or in the following folder.

razor - VS 2012 MVC Web App Publish fails when Precompilation set - St...

visual-studio-2012 razor asp.net-mvc-5 precompile
Rectangle 27 0

Solution: It turns out that since I wasn't publishing the Web.config file, that the binding redirects were not being made. The solution was to change this file back to being published (Build Action from "None" to "Content"), and then the pre-compilation was succeeding.

For others with an MVC or ASP.NET web site that runs slow each time hitting a new page/view, I'd recommend giving this pre-compilation feature with publishing a try. It's just hidden under file options in the publication settings (VS 2012.) I chose to Precompile, and to make the site not-updatable to avoid the dynamic view/page compilations. See for more information: What effect does the new precompile during publishing option have on MVC4 applications? .

Also, to push the correct settings and connection strings to Live and Test I started using the Translation Templates "Web.Release.config" and "Web.Debug.config". These will swap out Web.config lines when deploying only. See http://go.microsoft.com/fwlink/?LinkId=125889 for more information.

I recently had another problem with precompile on publish. I was getting a CS1528, because a view had "ViewBag.En" on a code line. Clearly someone started typing something that they never finished (and checked in), but it builds and other pages run fine locally when you aren't trying to pre-compile the views...

So, if you've been able to publish precompiled previously, and suddenly it starts having problems, consider the fact that the precompile on publish compile errors are very likely within your views. The Likely culprit is then likely in the same folder as the last precompiled item, or in the following folder.

razor - VS 2012 MVC Web App Publish fails when Precompilation set - St...

visual-studio-2012 razor asp.net-mvc-5 precompile
Rectangle 27 0

The only thing precompilation does is compile the views. The fact that this happens only when precompilation is set means that there's something in one of your views that is generating this error. That's kind of irrelevant, though.

The best way I've found to correct this particular error is to uninstall and reinstall the offending Nuget package.

Just go into the Package Manager Console, make sure the project that generates the error is selected for "Default Project", and then run:

> Uninstall-Package DotNetOpenAuth.Core -Force
> Install-Package DotNetOpenAuth.Core

That should resolve the issue and allow your site to publish and run fine, with or without precompilation.

Good advice perhaps for most. I discovered that by not publishing the Web.config file, a personal choice, that such was never copied to the temporary location, hence the binding redirects were not being made, and simplying including this made the pre-compilations succeeded.

razor - VS 2012 MVC Web App Publish fails when Precompilation set - St...

visual-studio-2012 razor asp.net-mvc-5 precompile