I've been trying to update the permissions so that I can run a command (specificially dotnet restore). I'm not sure if this issue is specific to running dotnet, or if it is more generic.

I can run the command using sudo dotnet restore, however I want to be able to run this command without sudo. This is because I want to execute these commands via a CI tool (Jenkins), and I don't want that tool to have access to root commands. . The Jenkins user is unable to run dotnet restore (because of the errors below) or sudo dotnet restore (because it doesn't have root access).

When I run without sudo, I have the following errors from dotnet restore:

/usr/share/dotnet/sdk/2.1.104/NuGet.targets(104,5): error : Access to the path '/{file_path_to_project.csproj}/obj' is denied. 
/usr/share/dotnet/sdk/2.1.104/NuGet.targets(104,5): error :   Permission denied [{file_path_to_project.csproj}]

I've been trying to update the read and write permissions for my user on the /usr/share/dotnet/sdk/2.1.104/NuGet.targets file, and the {file_path_to_project.csproj} directory, but so far I still get the same errors. Does it have something to do with the /obj directory? – When I run ls the obj file is not shown.

How can I update the permissions so that I can access these files without running sudo?

I created a /etc/sudoers.d/dotnet file to see if it would enable dotnet to be run without needing to call sudo. I added the following contents: {myusername} {myhostname} = (root) NOPASSWD: /usr/bin/dotnet. However, this still required me to run sudo before dotnet restore to get the correct output.

  • 1
    Comments are not for extended discussion; this conversation has been moved to chat. – Thomas Ward Apr 24 '18 at 19:38
  • Would you please edit and clarify about the CI tool you're using? What is it, how does it operate? If you can run dotnet restore via it, why can't you do the same with sudo dotnet restore even without it having root permissions? – dessert Apr 25 '18 at 6:39

One possibility is to use mono instead of dotnet. It's an open source implementation of the .NET framework and doesn't require root permission to run. It supports almost all of the .NET 4.7 features (see https://www.mono-project.com/docs/about-mono/compatibility/ for exceptions).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.