Resulting scripts can be used as templates to use on webpages on client-side.
- .Net Framework 4.5 Beta (can be compiled in 4.0 using source code)
- ASP.NET Razor 2.0 (can be found in ASP.NET MVC 4 or ASP.NET Web Stack)
- SharpKit v4.25.3000 (or higher, or even lower :)
Mark razor views to transform with special name in .csproj:
Include MSBuild task:
<UsingTask TaskName="XWeb.SharpKit.Razor.MSBuild.Generate" AssemblyFile="path to dll\XWeb.SharpKit.Razor.MSBuild.dll" />
Call task in build process before compiling:
<Output TaskParameter="GeneratedOutputFiles" ItemName="GeneratedView" />
<Compile Include="@(GeneratedView)" Exclude="@(Compile)" />
<Compile Include="Views.generated.cs" Exclude="@(Compile)" />
In this section:
- InputFiles required parameter is views to transform, used @(View) set.
- Namespace is the root namespace to generate classes in. Views in nested folders is placed in nested namespaces with same path. Required parameter.
- RootFolder represents root folder to determinate namespace relative path of views. Required parameter.
- ViewsInfoFile specifies filename to generate with views info. It can be included to the project to use strongly-typed views execution. Optional, if omited it does not generated.
- Output GeneratedOutputFiles represends generated output files (Folder/file.cshtml -> Folder.generated.cs). This file set is stored to @(GeneratedView) set.
- After task execution, resulting files included to @(Compile) set, using <ItemGroup> instruction. Exclude="@(Compile)" used for prevent double inclusion, if generated files is already inlcuded to project. ViewsInfoFile** 'Views.generated.cs' also included to compile.
<Import Project="$(MSBuildBinPath)\SharpKit\4\SharpKit.Build.targets" />
This instruction will generate after build the project .js file(s).
It comes soon ;)