在Ubuntu上运行asp.net核心应用程序时抛出异常

问题描述 投票:0回答:1

我有一个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包?

Temp Solution

现在我正在使用本机dotnet CLI publish命令构建应用程序,该命令正在执行该操作;但这意味着现在蛋糕的构建对我的情况来说是无用的(直到问题得到解决)。

asp.net asp.net-core-2.0 dotnet-cli cakebuild
1个回答
0
投票

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

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);
}
© www.soinside.com 2019 - 2024. All rights reserved.