0

I'm working on a NET Core project. My project works fine on NET core 1.1, in that I can publish versions for Windows, Mac, and Ubuntu, which perform as expected.

However, I'd like to move to NET Core 2.0 in order to take advantage of the new features, and to decrease the number of builds I have to do, as described in https://stackoverflow.com/a/45705268/8363669

My project consists of a standalone ASP.NET Core application using NET Core 2.0, and a Library using NET Standard 2.0

The application references packages as seen here:

"Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
"Microsoft.AspNetCore" Version="2.0.0"
"Microsoft.AspNetCore.Mvc" Version="2.0.0"
"Microsoft.AspNetCore.StaticFiles" Version="2.0.0"
"Microsoft.EntityFrameworkCore.Design" Version="2.0.0"
"Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0"
"Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.3"
"Microsoft.Extensions.Logging.Debug" Version="2.0.0"
"Microsoft.NETCore.Runtime.CoreCLR" Version="2.0.0"
"Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0"
"Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0"
"NETStandard.Library" Version="2.0.0" />
"Newtonsoft.Json" Version="10.0.3"
"Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0"

And my library also references a few packages:

"MsgPack.Cli" Version="0.9.2"
"System.Xml.XmlSerializer" Version="4.3.0"

When using build targets win-x86 and win-x64, my application works perfectly, but when I build it for linux-x64 and osx-x64, my application returns the following error when I run it:

Could not load file or assembly 'System.IO.FileSystem, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have seen other people get this error, but the solution to their problem does not seem to apply in my case. I don't know why I get this error, I'm not even referencing System.IO.Filesystem in the first place.

I hope my question contains the necessary information to help people help me :)

1 Answers1

1

I managed to find a solution myself. Seems my way of porting the code was less than perfect. With ASP.NET Core 2.0, there are far fewer necessary dependencies than with version 1.1

In case anyone is interested, what I did was to reduce the dependencies to the following:

"Microsoft.AspNetCore.All" Version="2.0.0"
"Newtonsoft.Json" Version="10.0.3"

I think "Newtonsoft.Json" might even be redundant now.

Additionally, I found that there is a difference between publishing from Visual Studio 2017, and publishing from a Linux terminal (I used Windows subsystem for Linux). If I publish from Visual Studio, the executables will not run on linux/mac, but if I publish from WSL, it works just fine.

The commands for publishing from a linux termínal are

dotnet publish -c Release -r linux-x64

and

dotnet publish -c Release -r osx-x64

respectively.