Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 迁移到netcore 2.0会导致Linux和Mac上的System.IO.Filesystem出现问题_C#_Linux_.net Core - Fatal编程技术网

C# 迁移到netcore 2.0会导致Linux和Mac上的System.IO.Filesystem出现问题

C# 迁移到netcore 2.0会导致Linux和Mac上的System.IO.Filesystem出现问题,c#,linux,.net-core,C#,Linux,.net Core,我在做一个网络核心项目。我的项目在NetCore1.1上运行良好,因为我可以发布Windows、Mac和Ubuntu的版本,这些版本的性能符合预期 但是,我想转到NetCore2.0,以利用新功能,并减少必须进行的构建数量,如中所述 我的项目包括一个使用NET Core 2.0的独立ASP.NET Core应用程序和一个使用NET Standard 2.0的库 应用程序引用的包如下所示: "Microsoft.ApplicationInsights.AspNetCore" Version="2.

我在做一个网络核心项目。我的项目在NetCore1.1上运行良好,因为我可以发布Windows、Mac和Ubuntu的版本,这些版本的性能符合预期

但是,我想转到NetCore2.0,以利用新功能,并减少必须进行的构建数量,如中所述

我的项目包括一个使用NET Core 2.0的独立ASP.NET Core应用程序和一个使用NET Standard 2.0的库

应用程序引用的包如下所示:

"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"
我的库还引用了几个包:

"MsgPack.Cli" Version="0.9.2"
"System.Xml.XmlSerializer" Version="4.3.0"
当使用构建目标win-x86和win-x64时,我的应用程序工作正常,但当我为linux-x64和osx-x64构建它时,我的应用程序在运行时返回以下错误:

无法加载文件或程序集“System.IO.FileSystem,Version=4.1.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”。定位的程序集清单定义与程序集引用不匹配。(来自HRESULT的异常:0x8013100)

我看到其他人也犯了这个错误,但他们问题的解决方案似乎并不适用于我的情况。我不知道为什么会出现这个错误,我甚至没有首先引用System.IO.Filesystem


我希望我的问题包含必要的信息来帮助人们帮助我:)

我自己设法找到了解决方案。 似乎我移植代码的方式不够完美。 与1.1版相比,ASP.NET Core 2.0版所需的依赖项要少得多

如果有人感兴趣,我所做的是将依赖关系减少到以下几点:

"Microsoft.AspNetCore.All" Version="2.0.0"
"Newtonsoft.Json" Version="10.0.3"
我认为“Newtonsoft.Json”现在甚至可能是多余的

此外,我发现从Visual Studio 2017发布与从Linux终端发布(我使用了Linux的Windows子系统)之间存在差异。 如果我从VisualStudio发布,可执行文件将不会在linux/mac上运行,但是如果我从WSL发布,它可以正常工作

从linux术语表发布的命令有

dotnet publish -c Release -r linux-x64

分别

dotnet publish -c Release -r osx-x64