我有一个包含在 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 命令行界面运行它...
由于您的项目目标是.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] 删除。
我来说两句