This project complements the MSBuild.SDK.SystemWeb SDK (based on the discussion and ideas in Add support for ASP.NET (non-Core) projects) by adding an SDK project type for Razor Libraries. This uses the RazorGenerator project to provide compile time support for MVC5 views with-in a library.
When using an MSBuild Project SDK obtained via NuGet (such as the SDKs in this repo) a specific version must be specified.
Either append the version to the package name:
<Project Sdk="MSBuild.SDK.SystemWeb.RazorLibrary/4.0.xx">
...
Or omit the version from the SDK attribute and specify it in the version in global.json, which can be useful to synchronise versions across multiple projects in a solution:
{
"msbuild-sdks": {
"MSBuild.SDK.SystemWeb.RazorLibrary" : "4.0.xx"
}
}
Where xx is the latest release available on nuget.org
You can also use the templates to easily create new projects.
It is possible to mix this SDK with e.g. MSBuild.SDK.SystemWeb to allow pre-compiling the razor views during build.
<Project Sdk="MSBuild.SDK.SystemWeb/4.0.xx">
<Sdk Name="MSBuild.SDK.SystemWeb.RazorLibrary" Version="4.0.xx" />
</Project>
For this to work correctly, please ensure you are using MSBuild.SDK.SystemWeb.RazorLibrary versions >4.0.106
For more information see
| Property | Default value | Description |
|---|---|---|
ExcludeSDKDefaultPackages |
false | Do not include the default packages Microsoft.Net.Compilers.Toolset and Microsoft.CodeDom.Providers.DotNetCompilerPlatform |
ApplySDKDefaultPackageVersions |
true* | Apply default version numbers to packages unless using a Central Package Management system |
*Version numbers are not applied if you are using Microsoft.Build.CentralPackageVersions version 2.1.1 or higher. Remember to include the packages in your central package versions file.
| Property | Default value | Description |
|---|---|---|
MvcBuildViews |
true if Configuration is Release false otherwise |
Whether to invoke the AspNetCompiler automatically after build |
EnableWebFormsDefaultItems |
Same as EnableDefaultItems |
Whether to automatically include WebForms files as content <ul><li> *.asax</li><li> *.ascx</li><li> *.ashx</li><li> *.asmx</li><li> *.aspx</li><li> *.master</li><li> *.svc</li></ul> |
OverwriteAppConfigWithBindingRedirects |
false | If set, then any automatically generated binding redirects will be copied into your web.config and RazorAppConfigFiles files. |
EnableRazorGeneratorMVC |
true | If set, then the RazorGenerator.MVC package will automatically be added to your project. This will automatically register the contained views when consumed by an application. |
| Property | Default value | Description |
|---|---|---|
ExcludeDefaultRazorPackages |
false | Use ExcludeSDKDefaultPackages instead |
| Package | Default Version | Property |
|---|---|---|
Microsoft.Net.Compilers.Toolset |
5.0.0 | MicrosoftNetCompilersToolset_Version |
Microsoft.CodeDom.Providers.DotNetCompilerPlatform |
3.6.0 | MicrosoftCodeDomProvidersDotNetCompilerPlatform_Version |
| Package | Default Version | Property |
|---|---|---|
RazorGenerator.MsBuild |
2.5.0 | RazorGeneratorMSBuild_Version |
RazorGenerator.MVC |
2.4.9 | RazorGeneratorMVC_Version |
Microsoft.AspNet.Mvc |
5.3.0 | MicrosoftAspNetMvc_Version |
| Item Name | Default | Description |
|---|---|---|
RazorAppConfigFiles |
Views/web.configAreas/**/web.config |
List of config files that will be updated with binding redirects |