You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Windows] No 'refs' directory in published output results in error "Cannot find compilation library location for package 'Microsoft.Win32.Registry'"
#2702
Closed
kichalla opened this issue
Apr 19, 2017
· 3 comments
Run the app dotnet C:\test\bin\Debug\netcoreapp2.0\publish\test.dll
The above step works
Stop the server (Ctrl + C)
Open the published output folder and rename the refs directory to something else
Run the app again dotnet C:\test\bin\Debug\netcoreapp2.0\publish\test.dll
Note: The same scenario works fine with a CLI version like 005418
Expected behavior
Application runs fine
Actual behavior
Exception is thrown:
Unhandled Exception: System.InvalidOperationException: Cannot find compilation library location for package 'Microsoft.Win32.Registry'
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable`1 parts, MetadataReferenceFeature feature)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager.GetCompilationReferences()
at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager.get_CompilationReferences()
at Microsoft.Extensions.DependencyInjection.MvcRazorMvcCoreBuilderExtensions.<>c__DisplayClass5_0.<AddRazorViewEngineServices>b__1(IRazorEngineBuilder b)
at Microsoft.AspNetCore.Razor.Language.RazorEngine.Create(Action`1 configure)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitClosedIEnumerable(ClosedIEnumerableCallSite closedIEnumerableCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(IApplicationBuilder app, Action`1 configureRoutes)
at refsdirectoryrepro.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at refsdirectoryrepro.Program.Main(String[] args)
Environment data
.NET Command Line Tools (2.0.0-preview1-005815)
Product Information:
Version: 2.0.0-preview1-005815
Commit SHA-1 hash: a150055dfb
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Users\kichalla\AppData\Local\Microsoft\dotnet\sdk\2.0.0-preview1-005815\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0-preview1-002028-00
Build : 6d0caecf154d3398b9bc0e637089b6af9e250479
When you have <PreserveCompilationContext>true</> in your .csproj, a refs folder is created on publish. If you are going to call, Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(), you need this folder in order to get your compilation libraries. If you move/delete the refs folder, the libraries can't be resolved, and the correct exception is thrown.
The consuming code either needs to not call ResolveReferencePaths, or you need to leave the refs folder in place.
The reason this used to work is because your development machine still has a NuGet cache on it. And there is resolution path logic that knows how to look in the NuGet cache. Even before our change, if you moved this app to a clean machine, it would still fail. It just so happened the NuGet cache exists on your dev machine.
With the latest fixes, the DependencyModel will only probe the locations that the host knows how to probe. Thus it will no longer check the NuGet cache, unless the host will also check the NuGet cache (which doesn't happen for published apps).
Steps to reproduce
2.0.0-preview1-005815
of CLIdotnet C:\test\bin\Debug\netcoreapp2.0\publish\test.dll
refs
directory to something elsedotnet C:\test\bin\Debug\netcoreapp2.0\publish\test.dll
Note: The same scenario works fine with a CLI version like
005418
Expected behavior
Application runs fine
Actual behavior
Exception is thrown:
Environment data
cc @mikeharder @pranavkm
The text was updated successfully, but these errors were encountered: