IL.VirtualViews
2.1.0.1
dotnet add package IL.VirtualViews --version 2.1.0.1
NuGet\Install-Package IL.VirtualViews -Version 2.1.0.1
<PackageReference Include="IL.VirtualViews" Version="2.1.0.1" />
<PackageVersion Include="IL.VirtualViews" Version="2.1.0.1" />
<PackageReference Include="IL.VirtualViews" />
paket add IL.VirtualViews --version 2.1.0.1
#r "nuget: IL.VirtualViews, 2.1.0.1"
#:package IL.VirtualViews@2.1.0.1
#addin nuget:?package=IL.VirtualViews&version=2.1.0.1
#tool nuget:?package=IL.VirtualViews&version=2.1.0.1
IL.VirtualViews
Define Razor templates inside feature slices and register them at virtual MVC view paths. Targets .NET 10 and .NET 11. Compilation is build-time only: no runtime compiler, fallback mode, temporary debug files or first-request compilation.
Usage
Reference the
IL.VirtualViewsNuGet package in the project declaring the views.Add a template, such as
Features/Reports/Report.virtual.cshtml, with build action AdditionalFiles:<AdditionalFiles Include="Features/Reports/Report.virtual.cshtml" />@model string <p>@Model</p>Define its matching partial class and registration path:
using IL.VirtualViews.Attributes; namespace MyApp.Features.Reports; [VirtualViewPath("/Views/Reports/Report.cshtml")] public partial class Report;Register the library with the existing service or builder extension:
services.AddVirtualViewsCapabilities("MyApp*"); // Alternatively: builder.AddVirtualViewsCapabilities("MyApp*");
The package supplies the compiler tool, generated IVirtualView companion classes, Razor build integration and MVC registration. No consumer SDK change, explicit target import or separate tool installation is required. Ordinary .NET SDK projects and existing Web/Razor SDK projects are supported. The build tool runs on .NET 10 or later.
The generated namespace follows the existing folder convention: starting at the last directory whose name prefixes the assembly name, join the remaining directories with dots; otherwise use the assembly name. The partial class is matched to that namespace and the template filename case-insensitively (including the .virtual.cshtml suffix). Generated code retains the class's declared C# casing. Templates with ambiguous case-insensitive identities are rejected. Implicit accessibility is supported for template-backed partials: the generated part is public. Classes must be top-level and non-generic.
Linked templates
Templates outside the project remain supported:
<AdditionalFiles Include="../SharedTemplates/Report.virtual.cshtml" />
Paths containing .. are normalized before deriving the companion namespace. Edits and removals update intermediate outputs on the next build without requiring a clean.
Hand-written constant templates
For existing class-based templates, public IVirtualView classes can still declare constant content:
[VirtualViewPath("/Views/Sample.cshtml")]
public class Sample : IVirtualView
{
public static string ViewContent => "@model string\n<p>@Model</p>";
}
Expression-bodied properties, constant initializers and getters containing one constant return are supported. Arbitrary method calls and dynamic getters fail the build; move dynamic values into the Razor model. Consumer code is never executed to extract templates.
Compilation and path rules
The build tool creates intermediate Razor sources and the installed SDK compiles them into the declaring assembly in both Debug and Release. Invalid Razor and unresolved model types fail the build. MVC uses its normal compiled-view engine and cache; deployed applications need neither template sources nor a runtime C# compiler.
Registration maps compiled items to VirtualViewPath, including derived attributes. Repeated registration is supported; duplicate virtual paths and conflicts with ordinary compiled views are rejected. Paths must begin with /, end with .cshtml, and contain no traversal segments.
Templates compile beneath synthetic /_VirtualViews/<fully-qualified-class-name>.cshtml identifiers. Put shared @using, @inject and tag-helper directives in the project's root _ViewImports.cshtml or in each template. Folder-specific imports beneath the runtime path do not apply. Use absolute registered paths for layouts and partials, such as /Views/Shared/Layout.cshtml.
Rebuild after template changes. Build-time Razor source generation must stay enabled. Libraries declaring views must be rebuilt with these package assets; a host cannot retroactively compile templates inside a legacy binary.
Migration
The template + attribute + registration interface remains unchanged. The former runtime-only VirtualViewsProvider, VirtualViewSourcePathAttribute, debug physical-file option and configuration overloads have been removed. VirtualViews:Debug no longer applies. Use normal generated Razor source/PDB debugging instead.
The old analyzer has been replaced by a single build tool which owns both companion generation and Razor inputs. There is no runtime-compilation package dependency or compatibility mode.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
NuGet packages (2)
Showing the top 2 NuGet packages that depend on IL.VirtualViews:
| Package | Downloads |
|---|---|
|
IL.RulesBasedOutputCache
Rules based output cache. |
|
|
IL.AttributeBasedDI.Visualizer
Extension for IL.AttributeBasedDI |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 2.1.0.1 | 0 | 11/18/2026 | |
| 2.0.0.1 | 0 | 11/18/2026 | |
| 1.9.2.4 | 195 | 8/17/2026 | |
| 1.9.2.3 | 779 | 5/4/2026 | |
| 1.9.2.2 | 167 | 5/4/2026 | |
| 1.9.2.1 | 232 | 5/3/2026 | |
| 1.9.1.1 | 262 | 3/20/2026 | |
| 1.9.0.3 | 226 | 1/21/2026 | |
| 1.9.0.2 | 611 | 1/5/2026 | |
| 1.9.0.1 | 150 | 1/5/2026 | |
| 1.8.0 | 644 | 10/30/2025 | |
| 1.7.0 | 1,910 | 4/8/2025 | |
| 1.6.1 | 1,898 | 12/1/2024 | |
| 1.6.0 | 197 | 12/1/2024 | |
| 1.5.0 | 721 | 9/15/2024 | |
| 1.4.0 | 261 | 9/13/2024 | |
| 1.3.2 | 233 | 9/13/2024 | |
| 1.3.1 | 230 | 9/11/2024 | |
| 1.3.0 | 246 | 8/10/2024 | |
| 1.2.1 | 470 | 7/15/2024 |