Solution for the error “Cannot find compilation library location for package ‘Microsoft.Win32.Registry” : .Net Core Errors Part II


You can find all .Net core posts here.

.Net Core was introduced in last few months and people has started adopting it.

In this series of post, I will put some frequent errors during .Net Core development and some important topics for the Core.

In this post we will see how to resolve the error:

InvalidOperationException: Cannot find compilation library location for package ‘Microsoft.Win32.Registry’

When this error occurs?

While publishing the project on Docker container or Azure etc.

Why this error occurs?

As per Pranav from .Net team –

MvcRazorCompileOnPublish disables publishing refs assemblies meant for runtime compilation. The idea is that since your application has precompiled views, you wouldn’t need the refs for runtime compilation. However, your embedded views require these.

This error may occur if you are precompiling your views. If you want more details on precompiling views then have a look at my article here.

Along with having pre-compiling views, if you have class library which is embedding the views – this error may occur

How to resolve this error?

To resolve this error, you need to add MvcRazorExcludeRefAssembliesFromPublish to false in your .csproj file as shown below:


This should continue publishing the refs directory as part of the publish output.

One more way to resolve this is by pre-compiling your embedded views.

Hope it helps.


Leave a Reply

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

You are commenting using your 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 )

Connecting to %s