I have an ASP MVC 4 project. It started as MVC 1, so it uses old-style ASPX / ASCX views. I want the views to compile at build time, mainly to check for compile-time errors (and also, importantly, the errors display directly in Visual Studio). I am developing Visual Studio Pro 2015 using IIS Express as a debug server.
As for msdn , Haacked, and questions here such as this I installed the following my .vbproj:
<MvcBuildViews>true</MvcBuildViews>
and also in my .vbproj created task
<Target Name="BuildViews" Condition="'$(MvcBuildViews)'=='true'" AfterTargets="Build"> <Message Importance="normal" Text="Precompiling views" /> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> </Target>
However, this causes an error when trying to create:
'/ temp' is not a valid IIS application.
As a file, it simply refers to ASPNETCOMPILER
I tried various alternatives like VirtualPath - I have a project configured to run as a subdirectory / local in dev, so I tried this and the site names from the configuration in the .vs folder and nothing works.
Should I change VirtualPath (and if so, what), or is there any other config that is missing for temp to work?
Edit
In addition, I get the same error when starting the MSBuild command prompt. For my real production systems, I have a script that builds using the MSBuild command line, then moves the embedded package to the product servers and deploys. Thus, when it is not created, IIS express (or IIS works) will not. Do you need a web server linked only to compile views?
Edit 2
I am confused by the need to use virtulPath and the obvious connection to the web server. Some of the suggested solutions include IIS configuration. IIS Express (which I use for debugging) doesnβt even work until a successful build, as I understand it? In any case, my application works in the virtual directory quite successfully (/ local in debug mode), but using this as a value does not work. If that matters, this is the corresponding part of applicationhost.config in the .vs folder in my project (I tried putting the same paths in the applciationhost.config file in Documents / IIS Express):
<site name="CarWeb-Site" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\Users\adam.conway\Documents\My Web Sites\CarWeb-Site" /> </application> <application path="/local" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="filesystem path to my project" /> </application> <bindings> <binding protocol="http" bindingInformation="*:57047:localhost" /> <binding protocol="http" bindingInformation="*:57047:*" /> </bindings> </site>
Therefore, I really do not understand why just VirtualPath="/" does not work, since the virtual path is specified in these configurations.
While my main goal is to show display errors in Visual Studio (and I agree with the answer limited to this), this is also the case that I create for production environments using MSBuild on a machine that does not even have IIS installed.