Skip to content

Commit 9a46e78

Browse files
authored
Merge pull request #17700 from dotnet/master
Update live with master
2 parents f0aeeab + 607e415 commit 9a46e78

4 files changed

Lines changed: 68 additions & 124 deletions

File tree

aspnetcore/mvc/views/view-compilation.md

Lines changed: 19 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -2,121 +2,25 @@
22
title: Razor file compilation in ASP.NET Core
33
author: rick-anderson
44
description: Learn how compilation of Razor files occurs in an ASP.NET Core app.
5-
monikerRange: '>= aspnetcore-1.1'
65
ms.author: riande
76
ms.custom: mvc
8-
ms.date: 12/05/2019
7+
ms.date: 4/8/2020
98
uid: mvc/views/view-compilation
109
---
1110
# Razor file compilation in ASP.NET Core
1211

1312
By [Rick Anderson](https://twitter.com/RickAndMSFT)
1413

15-
::: moniker range="= aspnetcore-1.1"
16-
17-
A Razor file is compiled at runtime, when the associated MVC view is invoked. Build-time Razor file publishing is unsupported. Razor files can optionally be compiled at publish time and deployed with the app—using the precompilation tool.
18-
19-
::: moniker-end
20-
21-
::: moniker range="= aspnetcore-2.0"
22-
23-
A Razor file is compiled at runtime, when the associated Razor Page or MVC view is invoked. Build-time Razor file publishing is unsupported. Razor files can optionally be compiled at publish time and deployed with the app—using the precompilation tool.
24-
25-
::: moniker-end
26-
27-
::: moniker range=">= aspnetcore-2.1 <= aspnetcore-2.2"
28-
29-
A Razor file is compiled at runtime, when the associated Razor Page or MVC view is invoked. Razor files are compiled at both build and publish time using the [Razor SDK](xref:razor-pages/sdk).
30-
31-
::: moniker-end
32-
3314
::: moniker range=">= aspnetcore-3.0"
3415

3516
Razor files with a *.cshtml* extension are compiled at both build and publish time using the [Razor SDK](xref:razor-pages/sdk). Runtime compilation may be optionally enabled by configuring your application.
3617

37-
::: moniker-end
38-
3918
## Razor compilation
4019

41-
::: moniker range=">= aspnetcore-3.0"
42-
4320
Build- and publish-time compilation of Razor files is enabled by default by the Razor SDK. When enabled, runtime compilation complements build-time compilation, allowing Razor files to be updated if they are edited.
4421

45-
::: moniker-end
46-
47-
::: moniker range=">= aspnetcore-2.1 <= aspnetcore-2.2"
48-
49-
Build- and publish-time compilation of Razor files is enabled by default by the Razor SDK. Editing Razor files after they're updated is supported at build time. By default, only the compiled *Views.dll* and no *.cshtml* files or references assemblies required to compile Razor files are deployed with your app.
50-
51-
> [!IMPORTANT]
52-
> The precompilation tool has been deprecated, and will be removed in ASP.NET Core 3.0. We recommend migrating to [Razor Sdk](xref:razor-pages/sdk).
53-
>
54-
> The Razor SDK is effective only when no precompilation-specific properties are set in the project file. For instance, setting the *.csproj* file's `MvcRazorCompileOnPublish` property to `true` disables the Razor SDK.
55-
56-
::: moniker-end
57-
58-
::: moniker range="= aspnetcore-2.0"
59-
60-
If your project targets .NET Framework, install the [Microsoft.AspNetCore.Mvc.Razor.ViewCompilation](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/) NuGet package:
61-
62-
[!code-xml[](view-compilation/sample/DotNetFrameworkProject.csproj?name=snippet_ViewCompilationPackage)]
63-
64-
If your project targets .NET Core, no changes are necessary.
65-
66-
The ASP.NET Core 2.x project templates implicitly set the `MvcRazorCompileOnPublish` property to `true` by default. Consequently, this element can be safely removed from the *.csproj* file.
67-
68-
> [!IMPORTANT]
69-
> The precompilation tool has been deprecated, and will be removed in ASP.NET Core 3.0. We recommend migrating to [Razor Sdk](xref:razor-pages/sdk).
70-
>
71-
> Razor file precompilation is unavailable when performing a [self-contained deployment (SCD)](/dotnet/core/deploying/#self-contained-deployments-scd) in ASP.NET Core 2.0.
72-
73-
::: moniker-end
74-
75-
::: moniker range="= aspnetcore-1.1"
76-
77-
Set the `MvcRazorCompileOnPublish` property to `true`, and install the [Microsoft.AspNetCore.Mvc.Razor.ViewCompilation](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/) NuGet package. The following *.csproj* sample highlights these settings:
78-
79-
[!code-xml[](view-compilation/sample/MvcRazorCompileOnPublish.csproj?highlight=4,10)]
80-
81-
::: moniker-end
82-
83-
::: moniker range="<= aspnetcore-2.0"
84-
85-
Prepare the app for a [framework-dependent deployment](/dotnet/core/deploying/#framework-dependent-deployments-fdd) with the [.NET Core CLI publish command](/dotnet/core/tools/dotnet-publish). For example, execute the following command at the project root:
86-
87-
```dotnetcli
88-
dotnet publish -c Release
89-
```
90-
91-
A *\<project_name>.PrecompiledViews.dll* file, containing the compiled Razor files, is produced when precompilation succeeds. For example, the screenshot below depicts the contents of *Index.cshtml* within *WebApplication1.PrecompiledViews.dll*:
92-
93-
![Razor views inside DLL](view-compilation/_static/razor-views-in-dll.png)
94-
95-
::: moniker-end
96-
9722
## Runtime compilation
9823

99-
::: moniker range="= aspnetcore-2.1"
100-
101-
Build-time compilation is supplemented by runtime compilation of Razor files. ASP.NET Core MVC will recompile Razor files when the contents of a *.cshtml* file change.
102-
103-
::: moniker-end
104-
105-
::: moniker range="= aspnetcore-2.2"
106-
107-
Build-time compilation is supplemented by runtime compilation of Razor files. The <xref:Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions> <xref:Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions.AllowRecompilingViewsOnFileChange> gets or sets a value that determines if Razor files (Razor views and Razor Pages) are recompiled and updated if files change on disk.
108-
109-
The default value is `true` for:
110-
111-
* If the app's compatibility version is set to <xref:Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1> or earlier
112-
* If the app's compatibility version is set to <xref:Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2> or later and the app is in the Development environment <xref:Microsoft.AspNetCore.Hosting.HostingEnvironmentExtensions.IsDevelopment*>. In other words, Razor files wouldn't recompile in non-Development environment unless <xref:Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions.AllowRecompilingViewsOnFileChange> is explicitly set.
113-
114-
For guidance and examples of setting the app's compatibility version, see <xref:mvc/compatibility-version>.
115-
116-
::: moniker-end
117-
118-
::: moniker range=">= aspnetcore-3.0"
119-
12024
To enable runtime compilation for all environments and configuration modes:
12125

12226
1. Install the [Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation/) NuGet package.
@@ -169,27 +73,35 @@ To enable runtime compilation based on the environment and configuration mode:
16973
}
17074
```
17175

172-
::: moniker-end
173-
17476
## Additional resources
17577

176-
::: moniker range="= aspnetcore-1.1"
177-
78+
* <xref:razor-pages/index>
17879
* <xref:mvc/views/overview>
80+
* <xref:razor-pages/sdk>
17981

18082
::: moniker-end
18183

182-
::: moniker range="= aspnetcore-2.0"
84+
::: moniker range="< aspnetcore-3.0"
18385

184-
* <xref:razor-pages/index>
185-
* <xref:mvc/views/overview>
86+
A Razor file is compiled at runtime, when the associated Razor Page or MVC view is invoked. Razor files are compiled at both build and publish time using the [Razor SDK](xref:razor-pages/sdk).
18687

187-
::: moniker-end
88+
## Razor compilation
89+
90+
Build- and publish-time compilation of Razor files is enabled by default by the Razor SDK. Editing Razor files after they're updated is supported at build time. By default, only the compiled *Views.dll* and no *.cshtml* files or references assemblies required to compile Razor files are deployed with your app.
18891

189-
::: moniker range=">= aspnetcore-2.1"
92+
> [!IMPORTANT]
93+
> The precompilation tool has been deprecated, and will be removed in ASP.NET Core 3.0. We recommend migrating to [Razor Sdk](xref:razor-pages/sdk).
94+
>
95+
> The Razor SDK is effective only when no precompilation-specific properties are set in the project file. For instance, setting the *.csproj* file's `MvcRazorCompileOnPublish` property to `true` disables the Razor SDK.
96+
97+
## Runtime compilation
98+
99+
Build-time compilation is supplemented by runtime compilation of Razor files. ASP.NET Core MVC will recompile Razor files when the contents of a *.cshtml* file change.
100+
101+
## Additional resources
190102

191103
* <xref:razor-pages/index>
192104
* <xref:mvc/views/overview>
193105
* <xref:razor-pages/sdk>
194106

195-
::: moniker-end
107+
::: moniker-end

aspnetcore/signalr/javascript-client.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Overview of ASP.NET Core SignalR JavaScript client.
55
monikerRange: '>= aspnetcore-2.1'
66
ms.author: bradyg
77
ms.custom: mvc
8-
ms.date: 11/12/2019
8+
ms.date: 04/08/2020
99
no-loc: [SignalR]
1010
uid: signalr/javascript-client
1111
---
@@ -19,38 +19,70 @@ The ASP.NET Core SignalR JavaScript client library enables developers to call se
1919

2020
## Install the SignalR client package
2121

22-
The SignalR JavaScript client library is delivered as an [npm](https://www.npmjs.com/) package. If you're using Visual Studio, run `npm install` from the **Package Manager Console** while in the root folder. For Visual Studio Code, run the command from the **Integrated Terminal**.
22+
The SignalR JavaScript client library is delivered as an [npm](https://www.npmjs.com/) package. The following sections outline different ways to install the client library.
23+
24+
### Install with npm
25+
26+
If using Visual Studio, run the following commands from **Package Manager Console** while in the root folder. For Visual Studio Code, run the following commands from the **Integrated Terminal**.
2327

2428
::: moniker range=">= aspnetcore-3.0"
2529

26-
```console
27-
npm init -y
28-
npm install @microsoft/signalr
29-
```
30+
```bash
31+
npm init -y
32+
npm install @microsoft/signalr
33+
```
3034

3135
npm installs the package contents in the *node_modules\\@microsoft\signalr\dist\browser* folder. Create a new folder named *signalr* under the *wwwroot\\lib* folder. Copy the *signalr.js* file to the *wwwroot\lib\signalr* folder.
3236

3337
::: moniker-end
3438

3539
::: moniker range="< aspnetcore-3.0"
3640

37-
```console
38-
npm init -y
39-
npm install @aspnet/signalr
40-
```
41+
```bash
42+
npm init -y
43+
npm install @aspnet/signalr
44+
```
4145

4246
npm installs the package contents in the *node_modules\\@aspnet\signalr\dist\browser* folder. Create a new folder named *signalr* under the *wwwroot\\lib* folder. Copy the *signalr.js* file to the *wwwroot\lib\signalr* folder.
4347

4448
::: moniker-end
4549

46-
## Use the SignalR JavaScript client
47-
48-
Reference the SignalR JavaScript client in the `<script>` element.
50+
Reference the SignalR JavaScript client in the `<script>` element. For example:
4951

5052
```html
5153
<script src="~/lib/signalr/signalr.js"></script>
5254
```
5355

56+
### Use a Content Delivery Network (CDN)
57+
58+
To use the client library without the npm prerequisite, reference a CDN-hosted copy of the client library. For example:
59+
60+
```html
61+
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/3.1.3/signalr.min.js"></script>
62+
```
63+
64+
The client library is available on the following CDNs:
65+
66+
::: moniker range=">= aspnetcore-3.0"
67+
68+
* [cdnjs](https://cdnjs.com/libraries/microsoft-signalr)
69+
* [jsDelivr](https://www.jsdelivr.com/package/npm/@microsoft/signalr)
70+
* [unpkg](https://unpkg.com/@microsoft/signalr@next/dist/browser/signalr.min.js)
71+
72+
::: moniker-end
73+
74+
::: moniker range="< aspnetcore-3.0"
75+
76+
* [cdnjs](https://cdnjs.com/libraries/aspnet-signalr)
77+
* [jsDelivr](https://www.jsdelivr.com/package/npm/@aspnet/signalr)
78+
* [unpkg](https://unpkg.com/@aspnet/signalr@next/dist/browser/signalr.min.js)
79+
80+
::: moniker-end
81+
82+
### Install with LibMan
83+
84+
[LibMan](xref:client-side/libman/index) can be used to install specific client library files from the CDN-hosted client library. For example, only add the minified JavaScript file to the project. For details on that approach, see [Add the SignalR client library](xref:tutorials/signalr#add-the-signalr-client-library).
85+
5486
## Connect to a hub
5587

5688
The following code creates and starts a connection. The hub's name is case insensitive.

aspnetcore/tutorials/grpc/grpc-start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Create a .NET Core gRPC client and server in ASP.NET Core
33
author: juntaoluo
44
description: This tutorial shows how to create a gRPC Service and gRPC client on ASP.NET Core. Learn how to create a gRPC Service project, edit a proto file, and add a duplex streaming call.
55
ms.author: johluo
6-
ms.date: 12/05/2019
6+
ms.date: 04/08/2020
77
uid: tutorials/grpc/grpc-start
88
---
99
# Tutorial: Create a gRPC client and server in ASP.NET Core
@@ -292,7 +292,7 @@ info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
292292
```
293293

294294
> [!NOTE]
295-
> The code in this article requires the ASP.NET Core HTTPS development certificate to secure the gRPC service. If the client fails with the message `The remote certificate is invalid according to the validation procedure.`, the development certificate is not trusted. For instructions to fix this issue, see [Trust the ASP.NET Core HTTPS development certificate on Windows and macOS](xref:security/enforcing-ssl#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos).
295+
> The code in this article requires the ASP.NET Core HTTPS development certificate to secure the gRPC service. If the .NET gRPC client fails with the message `The remote certificate is invalid according to the validation procedure.` or `The SSL connection could not be established.`, the development certificate isn't trusted. To fix this issue, see [Call a gRPC service with an untrusted/invalid certificate](xref:grpc/troubleshoot#call-a-grpc-service-with-an-untrustedinvalid-certificate).
296296
297297
[!INCLUDE[](~/includes/gRPCazure.md)]
298298

aspnetcore/tutorials/signalr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ At the end, you'll have a working chat app:
8585

8686
## Add the SignalR client library
8787

88-
The SignalR server library is included in the ASP.NET Core 3.0 shared framework. The JavaScript client library isn't automatically included in the project. For this tutorial, you use Library Manager (LibMan) to get the client library from *unpkg*. unpkg is a content delivery network (CDN)) that can deliver anything found in npm, the Node.js package manager.
88+
The SignalR server library is included in the ASP.NET Core 3.0 shared framework. The JavaScript client library isn't automatically included in the project. For this tutorial, you use Library Manager (LibMan) to get the client library from *unpkg*. unpkg is a content delivery network (CDN) that can deliver anything found in npm, the Node.js package manager.
8989

9090
# [Visual Studio](#tab/visual-studio/)
9191

@@ -317,7 +317,7 @@ At the end, you'll have a working chat app:
317317

318318
## Add the SignalR client library
319319

320-
The SignalR server library is included in the `Microsoft.AspNetCore.App` metapackage. The JavaScript client library isn't automatically included in the project. For this tutorial, you use Library Manager (LibMan) to get the client library from *unpkg*. unpkg is a content delivery network (CDN)) that can deliver anything found in npm, the Node.js package manager.
320+
The SignalR server library is included in the `Microsoft.AspNetCore.App` metapackage. The JavaScript client library isn't automatically included in the project. For this tutorial, you use Library Manager (LibMan) to get the client library from *unpkg*. unpkg is a content delivery network (CDN) that can deliver anything found in npm, the Node.js package manager.
321321

322322
# [Visual Studio](#tab/visual-studio/)
323323

0 commit comments

Comments
 (0)