0

I have an Ubuntu VM which publishes an ASP.Net Core application 2.0 with CakeBuild .

The output is then moved to another Ubuntu VM where .Net Core SDK already installed.

When I try to dotnet the main dll file, the following exception is thrown:

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)

This is my 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);
});

In the application I am using two nuget packages which were published from a Windows machine (.Net Standard 2.0), will this cause dotnet to fail ? if yes, how to use nuget packages which are Linux compatible ?

Temp Solution

For now I am building the application using the native dotnet CLI publish command which is doing the trick; but that means for now cake build is useless for my case here (until the problem is fixed of course).

Community
  • 1
  • 1
Ayman
  • 1,387
  • 4
  • 20
  • 35
  • It'll sound like a silly question, but do the versions of the runtimes match up? If you run `dotnet --version` on both VMs, do you get the same output? – Jamie Taylor Nov 18 '17 at 11:47
  • Both were installed at the same time, so they are `2.0.2` which is the latest. – Ayman Nov 18 '17 at 13:45
  • Huh. That's really quite strange. – Jamie Taylor Nov 19 '17 at 10:31
  • Which version of Cake are you using? – devlead Nov 19 '17 at 15:36
  • Latest I suppose, I just call `build.sh` and it downloads the binaries. – Ayman Nov 19 '17 at 15:38
  • @Ayman If you run your build script with diagnostic verbosity `--verbosity=diagnostic` and compare the invocation of `dotnet restore` to how you invoke `dotnet publish` manually, is there a difference? Can you also output `dotnet --version` in your bootstrapper script before running to verify that it's using the correct SDK? – Patrik Svensson Dec 25 '17 at 13:44

1 Answers1

0

With further investigation, I found that providing the output or the runtime parameters as full names causes the issue (bug #8298), so I don't think it's a Cake issue, but rather they invoke the DotNetCorePublish command with full name arguments.

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);
}
Ayman
  • 1,387
  • 4
  • 20
  • 35