发布时找不到包的编译库位置-.Net Core 2.0-Visual Studio 2017 15.8.5

时间:2018-09-21 15:50:04

标签: asp.net-mvc visual-studio asp.net-core

我有一个.Net Core 2.0项目,该项目引用一个项目,而该项目又具有程序集引用。在我将Visual Studio 2017升级到版本15.8.5之前,一切工作正常。

升级后,当我尝试在VS中运行项目时,出现错误“找不到包的编译库位置”。这是令人惊讶的,因为我以前没有得到它,但是我以前见过此问题,并且已经通过.Net Core 2.0进行程序集引用所需的黑客解决了该问题,特别是替换了默认的MetadataReferenceFeatureProvider(有关详细信息,请参见{{ 3}})。完成此操作后,该项目将在Visual Studio中构建并正常运行。

但是,当我尝试发布该项目时,我再次遇到相同的错误。目前,我无法发布。

有人知道我对此可以做什么吗? (该项目需要一个已编译的MVC视图,因此我不能使用false禁用该编译。)

我越来越绝望了,正在考虑回滚到Visual Studio的早期版本(如果可能的话!)。令人沮丧的是,Microsoft敦促您更新VS,然后更新破坏了以前的工作!

这是堆栈跟踪:

  

找不到包'ShiftSchedulerSPA.Reference'的编译库位置      在Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver解析器,列表1 assemblies) at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.<>c.<GetReferencePaths>b__8_0(CompilationLibrary library) at System.Linq.Enumerable.SelectManySingleSelectorIterator 2.MoveNext()      在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.DefaultRazorReferenceManager.GetCompilationReferences() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func 1 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文档)      在Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)      在Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorProjectItem projectItem)      在Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(字符串路径)      在Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand。<> c__DisplayClass23_0.b__0(Int32 i)      在System.Threading.Tasks.Parallel处。<> c__DisplayClass19_0`1.b__1(RangeWorker和currentWorker,Int32超时,Boolean和ReplicationDelegateYieldedBeforeCompletion)

1 个答案:

答案 0 :(得分:0)

该解决方案实际上在上面引用的github文章中找到。我不知道为什么它在VS 2017升级后就坏了,但是解决发布问题的方法是编辑.csproj文件,将 Microsoft.AspNetCore.All 从2.0.0版本更改为< strong> 2.0.3 :

  <ItemGroup>
    <PackageReference Include="IdentityModel" Version="2.16.1" />
    <PackageReference Include="IdentityServer4" Version="2.0.6" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
    <PackageReference Include="Serilog.Extensions.Logging.File" Version="1.1.0" />
  </ItemGroup>