title: ASP NET Core 2 Cannot find compilation library location for package 'Projectname.Model'
body: <p>In my solution, I have two projects. One of them is <code>web</code> project and the other one is <code>Model</code> project. You can see my solution structure in below:</p>
  
  <p><a href="https://i.stack.imgur.com/dDdfO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dDdfO.png" alt="enter image description here"></a></p>
  
  <p>Now when I run application I get the following error:</p>
  
  <blockquote>
    <p>InvalidOperationException: Cannot find compilation library location for package 'ContosoUniversity.Model'</p>
  </blockquote>
  
  <p>And here is full stack trace :</p>
  
  <pre><code>An unhandled exception occurred while processing the request.
  InvalidOperationException: Cannot find compilation library location for package 'ContosoUniversity.Model'
  Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List&lt;string&gt; assemblies)
  InvalidOperationException: Cannot find compilation library location for package 'ContosoUniversity.Model'
  Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List&lt;string&gt; assemblies)
  Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
  Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart+&lt;&gt;c.&lt;GetReferencePaths&gt;b__8_0(CompilationLibrary library)
  System.Linq.Enumerable+SelectManySingleSelectorIterator.MoveNext()
  Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable&lt;ApplicationPart&gt; parts, MetadataReferenceFeature feature)
  Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature&lt;TFeature&gt;(TFeature feature)
  Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences()
  System.Threading.LazyInitializer.EnsureInitializedCore&lt;T&gt;(ref T target, ref bool initialized, ref object syncLock, Func&lt;T&gt; valueFactory)
  Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences()
  Microsoft.AspNetCore.Mvc.Razor.Internal.LazyMetadataReferenceFeature.get_References()
  Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()
  Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument)
  Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
  Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
  Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)
  Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(string relativePath)
  Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CreateCacheEntry(string normalizedPath) 
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  System.Runtime.CompilerServices.TaskAwaiter.GetResult()
  Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(string relativePath)
  Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet&lt;IChangeToken&gt; expirationTokens, string relativePath, bool isMainPage)
  Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey)
  Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, string pageName, bool isMainPage)
  Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, string viewName, bool isMainPage)
  Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, string viewName, bool isMainPage)
  Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
  Microsoft.AspNetCore.Mvc.ViewResult+&lt;ExecuteResultAsync&gt;d__26.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+&lt;InvokeResultAsync&gt;d__19.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+&lt;InvokeNextResultFilterAsync&gt;d__24.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+&lt;InvokeNextResourceFilter&gt;d__22.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+&lt;InvokeFilterPipelineAsync&gt;d__17.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+&lt;InvokeAsync&gt;d__15.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  Microsoft.AspNetCore.Builder.RouterMiddleware+&lt;Invoke&gt;d__4.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+&lt;Invoke&gt;d__7.MoveNext()
  </code></pre>
  
  <p>I use ASP NET Core 2 and VS17.</p>
  
  <p>Here is my <code>ContosoUniversity.csproj</code> file if you need it:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
  
  &lt;PropertyGroup&gt;
    &lt;TargetFramework&gt;netcoreapp2.0&lt;/TargetFramework&gt;
  &lt;/PropertyGroup&gt;
  
  &lt;ItemGroup&gt;
    &lt;PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /&gt;
    &lt;PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;ItemGroup&gt;
    &lt;DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;ItemGroup&gt;
    &lt;Reference Include="ContosoUniversity.Model"&gt;
      &lt;HintPath&gt;..\ContosoUniversity.Model\bin\Debug\netcoreapp2.0\ContosoUniversity.Model.dll&lt;/HintPath&gt;
    &lt;/Reference&gt;
  &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>What should I do to solve this problem?</p>