【问题标题】:Exception thrown when running asp.net core application on Ubuntu在 Ubuntu 上运行 asp.net 核心应用程序时抛出异常
【发布时间】:2018-05-01 12:27:16
【问题描述】:

我有一个 Ubuntu VM,它 publishes 一个带有 CakeBuild 的 ASP.Net Core 应用程序 2.0。

然后将输出移动到另一个已安装 .Net Core SDK 的 Ubuntu VM。

当我尝试dotnet主dll文件时,抛出以下异常:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, 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)
Aborted (core dumped)

这是我的build.cake

Task("Clean")
.Does(() =>
{
   CleanDirectory(binaryDir);
   CleanDirectory(objectDir);
   CleanDirectory(publishDir);
});

Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
   DotNetCoreRestore(solutionPath);
});

Task("Build")
.IsDependentOn("Restore")
.Does(() => {
   var settings = new DotNetCorePublishSettings
   {
      Configuration = configuration, // Release
      OutputDirectory = publishDir,
      Runtime = runtime // linux-x64
   };

   DotNetCorePublish(solutionPath, settings);
});

在应用程序中,我使用了两个从 Windows 机器(.Net Standard 2.0)发布的 nuget 包,这会导致 dotnet 失败吗?如果是,如何使用与 Linux 兼容的 nuget 包?

临时解决方案

现在我正在使用本机 dotnet CLI publish 命令构建应用程序,这可以解决问题;但这意味着现在蛋糕构建对我这里的情况没有用(当然直到问题得到解决)。

【问题讨论】:

  • 这听起来像是一个愚蠢的问题,但是运行时的版本是否匹配?如果你在两个虚拟机上运行dotnet --version,你会得到相同的输出吗?
  • 两者是同时安装的,所以是最新的2.0.2
  • 嗯。这真的很奇怪。
  • 您使用的是哪个版本的 Cake?
  • 最新我想,我只是打电话给build.sh,它会下载二进制文件。

标签: asp.net asp.net-core-2.0 dotnet-cli cakebuild


【解决方案1】:

经过进一步调查,我发现提供outputruntime 参数作为全名会导致问题(bug #8298),所以我认为这不是Cake 问题,而是他们调用了@ 987654325@ 带有全名参数的命令。

cake/src/Cake.Common/Tools/DotNetCore/Publish/DotNetCorePublisher.cs lines 63-75

// Output directory
if (settings.OutputDirectory != null)
{
    builder.Append("--output");
    builder.AppendQuoted(settings.OutputDirectory.MakeAbsolute(_environment).FullPath);
}

// Runtime
if (!string.IsNullOrEmpty(settings.Runtime))
{
    builder.Append("--runtime");
    builder.Append(settings.Runtime);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-30
    • 1970-01-01
    • 2012-05-21
    • 2018-05-14
    • 2021-12-01
    • 2021-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多