Skip to content

Commit

Permalink
new view engine
Browse files Browse the repository at this point in the history
  • Loading branch information
dlidstrom committed Mar 8, 2022
1 parent 42670b0 commit 82121f3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ by editing this MSBuild file. In order to learn more about this please visit htt
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FTP</WebPublishMethod>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<publishUrl>snittlistan.se</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<FtpPassiveMode>True</FtpPassiveMode>
<FtpSitePath>snittlistan.se/wwwroot</FtpSitePath>
<UserName>snittlis</UserName>
<_SavePWD>True</_SavePWD>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\temp\snittlistan</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)RavenDB-Web.config Connection String" />
Expand Down
28 changes: 28 additions & 0 deletions Snittlistan.Web/RazorGeneratorMvcStart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#nullable enable

using RazorGenerator.Mvc;
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages;

[assembly: WebActivatorEx.PostApplicationStartMethod(
typeof(Snittlistan.Web.RazorGeneratorMvcStart),
"Start")]

namespace Snittlistan.Web;

public static class RazorGeneratorMvcStart
{
public static void Start()
{
PrecompiledMvcEngine engine = new(typeof(RazorGeneratorMvcStart).Assembly)
{
UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
};

ViewEngines.Engines.Insert(0, engine);

// StartPage lookups are done by WebPages.
VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
}
}
17 changes: 5 additions & 12 deletions Snittlistan.Web/Snittlistan.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<Compile Include="Commands\UpdateUserSettingsCommandHandler.cs" />
<Compile Include="Infrastructure\MsmqFactory.cs" />
<Compile Include="Models\UserSettings.cs" />
<Compile Include="RazorGeneratorMvcStart.cs" />
<Compile Include="Views\Hacker\Index.generated.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down Expand Up @@ -1528,17 +1529,9 @@
<!-- https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata?view=vs-2022 -->
<Target Name="EnsureNoneOnHomeViews" BeforeTargets="BeforeBuild">
<ItemGroup>
<FilteredContent
Include="@(Content)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(FullPath)', 'Areas.+cshtml$'))" />
<FilteredContent Include="@(Content)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(FullPath)', 'Areas.+cshtml$'))" />
</ItemGroup>
<Message Text="%(FilteredContent.FullPath)"
Condition=""
Importance="high" />
<Error
Condition="'@(FilteredContent)'!=''"
Code="CSHTML"
File="$(MSBuildProjectDirectory)\%(FilteredContent.Identity)"
Text="View is not set to [BuildAction:None]" />
<Message Text="%(FilteredContent.FullPath)" Condition="" Importance="high" />
<Error Condition="'@(FilteredContent)'!=''" Code="CSHTML" File="$(MSBuildProjectDirectory)\%(FilteredContent.Identity)" Text="View is not set to [BuildAction:None]" />
</Target>
</Project>
</Project>

0 comments on commit 82121f3

Please sign in to comment.