c# - c#在ubuntu 18.04服务器上访问路径被拒绝
问题描述
我和我的朋友想做一个不和谐的服务器。我在 c# 中制作了机器人,需要一些东西来托管它,以便它可以 24/7 运行,我选择了 Digitalocean。我创建了一个 ubuntu 18.04 droplet,在其上安装了 dotnet sdk 并克隆了我的 github bot repo(我知道这不是最好的解决方案)。但是当我尝试这样做时dotnet run
,我得到了“访问路径路径''被拒绝”错误。当我在 ubuntu 16.04 上使用 docker 尝试它时,我得到了同样的错误。谁能帮我解决这个问题?(它在 Windows 10 上运行良好)
Dockerfile:
FROM microsoft/dotnet:2.1-sdk
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy and build everything else
COPY . ./
RUN dotnet publish -c Release -o out
ENTRYPOINT ["dotnet", "out/Bot.dll"]
错误:
Unhandled Exception: System.UnauthorizedAccessException: Access to the path '/app/out' is denied. ---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Bot.Program.MainAsync() in /app/Program.cs:line 38
at Bot.Program.Main(String[] args) in /app/Program.cs:line 16
chmod -x 和 chmod -R 777 不起作用
解决方案
您必须为 ubuntu 发布发布,授予执行权限,chmod -R 777 PATHTOPUBLISHFOLDER
然后使用path to the file without extension in the publish folder
推荐阅读
- javascript - 从 puppeteter 评估函数中获取未定义
- javascript - Javascript 和 sqlite 请求
- python - SystemError:使用 Keras 加载模型时操作码未知
- sql - MS-ACCESS / SQL - 如何在多个条件下应用 where 子句
- android - Android studio 4.0 新更新版本说 Kotlin 与这个新版本不兼容
- javascript - 如何使用 Rails 响应 HTML 和 JSON?
- windows - 如果选择了错误的值,则 Windows 批处理
- javascript - 我正在使用 Chart JS 在悬停工具提示上显示 div
- database - 如何在数据库中存储每日时间表?
- python - 如何使用 webhook 使用 python 和 dialogflow 制作简单的面积计算器?