Razor pages compilation on Publish: Now default with .Net Core 2.0


.Net Core 2.0 is announced last week and it came up with some awesome features.

I am going to explain its one of the best features which is the compilation of views and pages on Publish.

Till now(before .Net core 2.0) whenever we publish any MVC application, Razor files are published as .cshtml files and they get compiled at runtime.

Which means:

  • It takes a bit more time just to compile all those cshtml files
  • Publish output size increases

.Net Core 2.0 has one inbuilt functionality which compiles page and views on publish.

It means:

  • Our Razor pages and views would get published with our app as a compiled assembly instead of being published as .cshtml source files that get compiled at runtime

So it has advantages as:

  • Reduces application startup time
  • Reduces Publish output size

So the conclusion is, our .Net Core 2.0 applications are faster than the older applications.

Please note that we can disable this feature if we do not require this.

It can be done by simply updating below property in csproj file:


Have a look here if you require more details.



One thought on “Razor pages compilation on Publish: Now default with .Net Core 2.0

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: