转换 Visual Studio 2017 C# 解决方案/项目以在 Linux 上与 Mono 一起使用?

阿拉沃克斯

我有一个包含在 Visual Studio 2017 解决方案中的普通 C# windows x64 控制台应用程序项目。它在 Visual Studio 的 Windows 上编译。它的目标是 .NET v4.7.1,不过,我相信它可以在较低的 .NET 版本上编译。

我想移植应用程序以使用 Mono 在 Linux 上运行。执行此操作的程序是什么?

我试过简单地运行,dotnet build但这给出了错误消息:

user@user-VirtualBox:~/Desktop/svm_compute/svm_compute$ dotnet build
Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Nothing to do. None of the projects specified contain packages to restore.
/usr/share/dotnet/sdk/2.2.203/Microsoft.Common.CurrentVersion.targets(775,5): error : The OutputPath property is not set for project 'svm_compute.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='AnyCPU'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [/home/user/Desktop/svm_compute/svm_compute/svm_compute.csproj]

Build FAILED.

然后,我尝试了dotnet build svm_compute.csproj /p:ConfigurationPlatforms=Release /p:Platform="x64",它也给出了错误:

user@user-VirtualBox:~/Desktop/svm_compute/svm_compute$ dotnet build svm_compute.csproj /p:ConfigurationPlatforms=Release /p:Platform="x64"
Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Nothing to do. None of the projects specified contain packages to restore.
/usr/share/dotnet/sdk/2.2.203/Microsoft.Common.CurrentVersion.targets(1183,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/home/user/Desktop/svm_compute/svm_compute/svm_compute.csproj]

Build FAILED.

另一方面,如果我使用 IDE,monodevelop我可以加载解决方案、构建它并运行它。但是,这不是很有用,因为我需要能够在不使用 IDE 的情况下构建它并通过 linux 命令行界面运行它...

zhimin

由于您的项目目标是.Net Framework,您应该使用的构建工具是msbuild(包含在最近版本的mono中,请参阅https://www.mono-project.com/download/stable/mono-devel为您的linux安装包。

打开一个终端窗口,导航到您的项目目录,并尝试使用 构建它msbuild /t:build,如果您有对 nuget 的引用,请先尝试msbuild /t:restore

dotnet命令仅用于.Net Core项目。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用 Visual Studio 2017 打开解决方案

如何在Visual Studio的同一解决方案上运行多个项目

有没有办法在 Visual Studio 2017 中查看解决方案/项目构建使用的每个文件?

使用Visual Studio 2017的.NET Core解决方案上没有project.json,global.json ...等

使用cmake在Mac上生成Visual Studio解决方案

在Linux上使用Mono构建VS 2017 MSBuild csproj项目

使用CMake在同一解决方案中创建C#和C ++ / CLR项目(针对Visual Studio的CMake)

解决方案中的 Visual Studio 2017 可扩展性项目计数

用于整个解决方案的自定义C#重构的Visual Studio 2017扩展

Visual Studio Code是否可以与混合语言.NET Core解决方案一起使用?

使用Team Explorer中的Git存储库将现有项目添加到Visual Studio 2017解决方案中的源代码管理

在Visual Studio 2017中使用Windows Silverlight开发的解决方案?

C ++:dll在Visual Studio 2017上不起作用,但可与g ++一起使用

Visual Studio解决方案(.sln)/ C#:使用另一个项目的dll作为参数启动一个项目

如何在Mac上的Windows上编译C#Visual Studio解决方案

Visual Studio 2017加载时崩溃解决方案

如何在 Visual Studio 2017 中保存解决方案

Visual Studio 2017解决方案中的引用丢失

使用CentOS在TeamCity上从GitHub构建C#(Mono)解决方案

多项目Visual Studio解决方案无法调试一个项目dll

在多平台解决方案中构建 Visual Studio C++ 项目

在Mac上的Visual Studio Community 2017中使用C ++?

打开解决方案时未解析Visual Studio 2017对其他项目中代码的引用

如何从同一解决方案访问另一个项目?(Visual Studio 2012)

我可以让 Visual Studio 只在解决方案中构建每个项目一次吗?

Visual Studio 2015-如何从另一个解决方案引用项目?

如何在Linux下构建Visual Studio解决方案?

如何使用C#在Visual Studio 2010中以编程方式将现有项目添加到当前解决方案中

在一个解决方案 c# 上为多个项目使用 NLog