本文介绍了尝试在 linux 上运行 netcore 应用程序时出现无效的 runtimeconfig.json 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了 .net 核心控制台应用程序.它连接 Azure 表存储并从 azure 下载到本地数据库.应用程序在 Windows 10 PC 上运行没有任何问题.但是,当我将它发布到运行 Lubuntu 的 PC 并尝试运行时,我收到无效的 runtimeconfig.json 错误".

I have developed .net core console application. It connects with Azure table storage and downloads from azure to a local database. Application is working w/o any issues on a Windows 10 PC. However when I publish it to a PC running Lubuntu and try to run I receive "Invalid runtimeconfig.json error".

runtimeconfig.json 的内容是:

Content of runtimeconfig.json is:

{
  "runtimeOptions": {
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "1.1.2"
    }
  }
}

dotnet --info 的输出是:

and output of dotnet --info is:

NET Command Line Tools (1.0.4)
Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd
Runtime Environment:
OS Name: ubuntu
OS Version: 17.04
OS Platform: Linux
RID: ubuntu.16.10-x64
Base Path: /usr/share/dotnet/sdk/1.0.4

适用于 Linux 的 SDK 是最新版本.任何人都知道什么可能是错误的以及如何解决它?

SDK for Linux is the latest version. Anybody have any ideas what might be wrong and how to fix it?

推荐答案

经过反复试验,我解决了这个问题.问题实际上不是无效的配置文件.当 dotnet 运行 dll 文件时,它会创建一个 xxxx.runtimeconfig.dev.json,xxxx 是 dll 的名称.但是,在我的情况下,由于 Lubuntu 中缺少文件夹和文件访问权限,dotnet 无法创建 runtimeconfig.dev.json 文件.

After some trial and error I have resolved the issue. Problem is not really a invalid configuration file. When dotnet runs the dll file it creates a xxxx.runtimeconfig.dev.json, xxxx being the name of dll. However in my case due to missing folder and file access rights in Lubuntu, dotnet was not able to create the runtimeconfig.dev.json file.

我已通过执行以下终端命令(从 folderholdingmyapp 的父目录运行此命令)修改了对保存我的应用程序的文件夹的访问权限

I have modified access rights to folder holding my application by executing following terminal command (run this from parent directory of folderholdingmyapp)

chmod -R 1744 folderholdingmyapp

这篇关于尝试在 linux 上运行 netcore 应用程序时出现无效的 runtimeconfig.json 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 17:18