Home cshtml failed to build in production (vsts)
Reply: 0

cshtml failed to build in production (vsts)

user2326
1#
user2326 Published in April 22, 2018, 4:53 am

I'm using Aspnetboilerplate framework in my Web project.

Everything was working until I noticed that my production environment was very slow on first page access.

Doing some researchs I discovered that the problem was to not pre compile cshtml views on build. So, in my vsts build definition I added the follow:

/p:PrecompileBeforePublish=true /p:UseMerge=true /p:SingleAssemblyName=AppCode

But now I'm getting the follow error on all my cshtml views:

Seduca.Web\obj\Release\AspnetCompileMerge\Source\App\Main\views\aulas\index.cshtml(5,0): Error CS0103: The name 'IsGranted' does not exist in the current context

Works if I put this on top of each view:

@inherits Seduca.Web.Views.SeducaWebViewPageBase

but it looks like my file (web.config) is being ignored.

My .csproj looks like this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <MvcBuildViews>true</MvcBuildViews>
    <LangVersion>6</LangVersion>
  </PropertyGroup>
...
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <ItemGroup>
      <ExtraWebConfigs Include="$(BaseIntermediateOutputPath)\**\web.config" />
      <ExtraPackageTmp Include="$([System.IO.Directory]::GetDirectories(&quot;$(BaseIntermediateOutputPath)&quot;, &quot;PackageTmp&quot;, System.IO.SearchOption.AllDirectories))" />
    </ItemGroup>
    <Delete Files="@(ExtraWebConfigs)" />
    <RemoveDir Directories="@(ExtraPackageTmp)" />
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
  </Target>

And the web.config:

The error only happens in vsts build. In local deploy, (with release option and precompile) it works.

I've tried with hosted and private agents on vsts.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304954 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO