我创建了基本的ASP.Net核心API应用程序,我希望通过Apache在debian上运行,我没有更改默认应用程序(在创建新项目时生成),除了.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifier>debian-x64</RuntimeIdentifier> <!-- NEW LINE -->
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
</ItemGroup>
</Project>
我将它发布到文件夹(它创建了两个文件夹:netcoreapp2.0
和PublishOutput
)并将其转移到debian。在那里我运行了sudo apt-get install dotnet-runtime-2.0.6
并试图在两个目录(./MyAppName
和PublishOutput
)中运行netcoreapp2.0/debian-x64
。
PublishOutput
返回了此错误:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.AspNetCore.Hosting.WebHostBuilder..ctor()
at Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(String[] args)
at MyAppName.Program.BuildWebHost(String[] args)
at MyAppName.Program.Main(String[] args)
Aborted
netcoreapp2.0/debian-x64
返回了此错误:
Error:
An assembly specified in the application dependencies manifest (SrovnavacPojistoven.deps.json) was not found:
package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1'
path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'
如果有人可以帮助我,我会非常高兴。我找不到任何有用的东西。我试图发布基本的.net核心控制台应用程序,没有任何问题,我只有ASP的问题。