【发布时间】:2018-08-17 04:49:53
【问题描述】:
我正在尝试使用 .net 内核编译和运行我的第一个跨平台应用程序以迁移 c# 应用程序。我正在尝试在 Debian stretch 9.3 上运行它
我已经运行了这两个命令。
dotnet build -r debian-x64
dotnet publish -c release -r debian-x64
dotnet build -r linux-x64
dotnet publish -c release -r linux-x64
我为每个文件夹(分别为 bin\Release\netcoreapp2.0\linux-x64 和 bin\Release\netcoreapp2.0\debian-x64)获取了我使用 SFTP 复制到我的 linux 机器的文件夹。 在 linux 中,我 cd 进入文件夹并运行 .\program
我在尝试使用 debian 特定或通用 linux 编译代码时收到以下错误。
Error:
An assembly specified in the application dependencies manifest (nfz_core.deps.json) was not found:
package: 'runtime.linux-x64.Microsoft.NETCore.App', version: '2.0.0'
path: 'runtimes/linux-x64/lib/netcoreapp2.0/Microsoft.CSharp.dll'
我想我可能在我的 csproj 文件中做错了什么,但我似乎无法弄清楚我做错了什么。
这是我的 .csproj 文件
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win10-x64;debian-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup>
</Project>
我很欣赏人们可以提供的任何见解。
【问题讨论】:
-
“我得到了每个文件夹”,这是什么文件夹?这是
publish文件夹还是另一个文件夹? -
尝试从 Visual Studio 构建,将
bin\Release\netcoreapp2.0文件夹复制到 Linux,然后使用dotnet program.dll命令运行您的应用程序。另请参阅此问题,可能相关:github.com/dotnet/cli/issues/7543 -
@soonts 我会试试的。
-
@omajid bin\Release\netcoreapp2.0\linux-x64 和 bin\Release\netcoreapp2.0\debian-x64 分别
-
使用发布文件夹:
bin\Release\netcoreapp2.0\linux-x64\publish。这就是dotnet publish的输出。
标签: c# .net linux debian .net-core