[英].net core 2.0 error running console app on ubuntu
I'm trying to run my first .net core 2.0 console app on ubuntu 16.04-x64. 我正在尝试在ubuntu 16.04-x64上运行我的第一个.net核心2.0控制台应用程序。 I followed the steps to publish my app for ubuntu: 我按照步骤发布了我的ubuntu应用程序:
dotnet publish -c release -r ubuntu.16.04-x64
and also tried it from Visual Studio by changing my .csproj file like so: 并通过更改我的.csproj文件从Visual Studio尝试它:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>ubuntu.16.04-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="sharpadbclient" Version="2.1.0" />
<PackageReference Include="System.IO.Ports" Version="4.4.0" />
</ItemGroup>
</Project>
and then publish it with a publish profile. 然后使用发布配置文件发布它。
I followed the instruction from Microsoft to install .net core on ubuntu . 我按照微软的指示在ubuntu上安装.net核心 。 I copied the published output to the PC running ubuntu ans when I'm trying to run the .dll file of my console app I'm getting this error: 当我试图运行我的控制台应用程序的.dll文件时,我将发布的输出复制到运行ubuntu ans的PC上我收到此错误:
Unhandled Exception: System.IO.FileLoadException:
Could not load file or assembly
'System.Console, 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)
at LinuxVersion.Program.InitializeComponent()
at LinuxVersion.Program.Main(String[] args)
Aborted (core dumped)
When I'm running dotnet restore
I'm getting a message saying: 当我运行dotnet restore
我收到一条消息说:
MSBUILD : error MSB1003: Specify a project or solution file.
The current working directory does not contain a project or solution file.
Am I missing a step here in the process? 我在这个过程中错过了一步吗?
Well, turns out there is a difference between publishing the app using Visual Studio publish profile (right clicking on the project and selecting "publish") and using the command line. 好吧,事实证明,使用Visual Studio发布配置文件(右键单击项目并选择“发布”)和使用命令行发布应用程序之间存在差异。 When I used the Visual Studio publish profile I got this error, then I switched to using the command line like so: dotnet publish -c release -r ubuntu.16.04-x64
but to run it I went into the publish folder of the output: cd /home/MyApp/publish
and then run the app using dotnet MyAppName.dll
. 当我使用Visual Studio发布配置文件时出现此错误,然后我切换到使用命令行,如下所示: dotnet publish -c release -r ubuntu.16.04-x64
但运行它我进入了输出的发布文件夹: cd /home/MyApp/publish
然后使用dotnet MyAppName.dll
运行应用程序。
This solved it for me. 这解决了我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.