CruiseControl failing view compilation with Asp.net MVC 2 RTM
Tehnologies: - CruiseControlNet - Asp.net MVC 2 RTM - enabled view compilation
The problem is UrlParameter.Optional
setting. I can't seem to make it work when I use this setting inside a view.
When I compile inside Visual Studio, everything works fine, but when CCNet uses MSBuild
to compile it it fails with following error:
errorCS0103: The name 'UrlParameter'开发者_如何学运维 does not exist in the current context
pointing to the line inside my view where this parameter is set on:
Html.RenderAction(...)
that sets certain route parameter(s) to optional.
I tried adding <%@ Assembly name="System.Web.Mvc" %>
at the top of my view, but it didn't work either. It works of course when I disable view compilation, but that's not really an option. And I also don't want to set my optional parameters to string.Empty
.
Anyone has any hint on this?
Check if your web.config has in the <compilation>
section the following entry:
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Solution/Workaround
I checked CCNet configuration of my project and I added the following line in the <msbuild>
element:
<buildArgs>/noconsolelogger /p:Configuration=Release</buildArgs>
After that I also changed my csproj file to set these:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
<MvcBuildViews>false</MvcBuildViews>
</PropertyGroup>
This way my views are only being compiled in development, where we compile as Debug, but not by MSBuild on CCnet where it now compiles as Release.
We had the same issue (actually, that is how I came to find your question/workaround). It turns out our build server had an older version of MVC 2. You need the RC.
HTH.
精彩评论