15

I am working on an ASP.NET project in which I need to do simple HTML templating.

The prettiest solution seems to be RazorEngine, which depends on Microsoft.AspNet.Razor. However, when trying to install Microsoft.AspNet.Razor via Nuget, the following error message is shown:

Installing 'Microsoft.AspNet.Razor 3.0.0'.
Successfully installed 'Microsoft.AspNet.Razor 3.0.0'.
Adding 'Microsoft.AspNet.Razor 3.0.0' to EBulkDBSManagementApp.
Uninstalling 'Microsoft.AspNet.Razor 3.0.0'.
Successfully uninstalled 'Microsoft.AspNet.Razor 3.0.0'.
Install failed. Rolling back...
Could not install package 'Microsoft.AspNet.Razor 3.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Any solution?

Tahir Hassan
  • 5,715
  • 6
  • 45
  • 65

1 Answers1

29

The latest RazorEngine 3.4.0 NuGet package depends on the Microsoft.AspNet.Razor 3.0.0 NuGet package which requires .Net 4.5

If you wish to use RazorEngine with a version of .NET prior to 4.5, then you will need to use the RazorEngine 3.3.0 NuGet pacakage.

You can install this using the package manager console with the following command.

Install-Package RazorEngine -Version 3.3.0
coxp
  • 406
  • 4
  • 2
  • 3
    If 3.3.0 does not work either, use "Install-Package RazorEngine -Version 2.1.0" instead. – WAKU Dec 04 '13 at 06:42
  • 1
    There is a nuget legacy package for ASP.NET MVC 4, it uses RazorEngine v2.1.0. – Jonathan Escobedo Jul 09 '14 at 17:10
  • How do you know this? This works perfect for me. But wondering in Nuget website, 3.2.3 is the latest stable https://www.nuget.org/packages/Microsoft.AspNet.Razor/ – CodeFarmer Aug 13 '15 at 00:37