【问题标题】:.Net Coe App in Linux fails with - ProjectFactory did not find ProjectLinux 中的 .Net Core 应用程序失败 - 项目工厂未找到项目
【发布时间】:2021-04-08 05:02:27
【问题描述】:

以下是我的服务器环境

  • 服务器:VPS
  • 主机:AWS EC2
  • 操作系统:CentOS Linux 8.3.2011
  • Plesk:Plesk 黑曜石 18.0.34
  • .Net 版本:.Net Core 3.1.11(从 linux CLI 手动安装)

我在寻找什么

我创建了一个 .Net 核心测试应用程序并尝试使用以下命令运行该应用程序,一切正常。应用程序运行良好,“Hello World!”,一切顺利。

dotnet new console
dotnet run

但是当我尝试发布和运行应用程序时,

dotnet publish -c Release 
dotnet -d contest.dll

它给出了以下错误,我已经确定路径和文件名都是正确的。

Telemetry is: Disabled
projectfactory: MSBUILD_EXE_PATH = /usr/lib64/dotnet/sdk/3.1.111/MSBuild.dll
projectfactory: MSBuild project path = 
projecttoolscommandresolver: ProjectFactory did not find Project.
Microsoft.DotNet.Cli.Utils.CommandUnknownException: Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-contest.dll does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
   at Microsoft.DotNet.CommandFactory.CommandFactoryUsingResolver.Create(ICommandResolverPolicy commandResolverPolicy, String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

我尝试过 API、Console 和其他模板。错误对所有人都一样。

任何帮助将不胜感激。

非常感谢和问候

【问题讨论】:

    标签: linux api .net-core console publish


    【解决方案1】:

    首先尝试dotnet contest.dll。请注意命令中没有选项-d

    即使这样它也没有运行,很可能是权限问题。用户是否具有可执行权限? 您可以尝试使用chmod ### directory/where/dotnet/publish 授予权限完成。尝试授予 777 权限并检查。

    如果其他用户使用了chmod 命令,您也可以尝试使用命令rm /tmp/NuGetScratch/lock/* 清除/tmp/NuGetScratch/lock/ 处的Nuget 缓存文件。如果多个用户可以访问 lock 目录,有时 nuget 锁定文件会产生问题。

    【讨论】:

    • 非常感谢@Nischal。这绝对是文件夹的权限问题。我已经安装了 plesk 并且可执行文件在 /var/www/vhosts 中。授予权限并清理 NuGet 解决了该问题。
    猜你喜欢
    • 2018-03-16
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多