发布的ASP.NET核心站点上的错误:找不到包'Microsoft.AspNet.WebApi.Client'的编译库位置 [英] Error on published ASP.NET core site: Cannot find compilation library location for package 'Microsoft.AspNet.WebApi.Client'
问题描述
从Visual Studio运行时,我的webb应用程序工作正常,但是当我发布并尝试加载页面时,我得到:
My webb app works fine when run from Visual Studio, but when I publish and try to load a page, I get:
InvalidOperationException:找不到包'Microsoft.AspNet.WebApi.Client'的编译库位置 Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver解析程序,列表程序集)
InvalidOperationException: Cannot find compilation library location for package 'Microsoft.AspNet.WebApi.Client' Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List assemblies)
我已经坚持了很长时间.我试图在线程 https://github.com/中应用各种变通办法dotnet/core-setup/issues/2981 ,但没有一个起作用.
I've been stuck on this for quite a while. I've attempted to apply the various workarounds in the thread https://github.com/dotnet/core-setup/issues/2981, but none of them have worked.
我的csproj文件粘贴在下面.我不确定还有哪些其他信息会有用:
My csproj file is pasted below. I'm not sure what other information would be useful:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>aspnet-CrowdQuery2-8C668DB3-5C80-4D9E-851D-2434D0CDA7E9</UserSecretsId>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
<PropertyGroup>
<RuntimeFrameworkVersion>2.1.2</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.3" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Folder Include="ViewModels\" />
</ItemGroup>
</Project>
推荐答案
我在使用Microsoft Azure时遇到了同样的问题.
I've been having the same issue using Microsoft Azure.
在这种情况下,解决方案是使用Kudu(开发工具->高级选项)清理Web应用程序中的wwwroot
文件夹,因为在此之前,仍然还有一些旧的DLL.升级到.NET Core 2.1,因为.NET Core 1将DLL发布到wwwroot
文件夹,而在2.1中,DLL是从全局存储加载的.
The solution in this case was to clean up the wwwroot
folder in our web app using Kudu (Development Tools -> Advanced Options), because there were some old DLLs still left from before the upgrade to .NET Core 2.1, because .NET Core 1 publishes the DLLs to the wwwroot
folder, whereas in 2.1, the DLLs are loaded from a global store.
完全清空wwwroot
文件夹并重新部署应用程序后,该错误已解决,该应用程序按预期运行.
After having completely emptied the wwwroot
folder, and redeploying the app, the error was resolved and the app ran as expected.
这篇关于发布的ASP.NET核心站点上的错误:找不到包'Microsoft.AspNet.WebApi.Client'的编译库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!