0

I'm working on an ASP.NET Core project, where I have to grab information and packages from a Nuget feed. Everything works like a charm locally, but when I deploy the site and try to access the nuget feed, I get the following error:

Nuget.Configuration.NugetConfigurationException: Failed to read NuGet.Config due to unauthorized access. Path: c:\Windows\System32\Config\SystemProfile\AppData\Roaming\Nuget\Nuget.config

I tried many ways to instantiate the Nuget repository provider, but all of them ends with the same issue.

The code I use to create the repository source is as follows:

private SourceRepository GetRepository() {    List<Lazy<INugetResourceProvider>> providers = new List<Lazy<INugetResourceProvider>>();    providers.AddRange(Repository.Provider.GetCoreV3());    var packageSource = new PackageSource(<feedurl>)                             {                                Credentials = new PackageSourceCredential(...)                            };    return new SourceRepository(packageSource, providers);}

It fails when tries to create theSourceRepository.

I tried setting nuget file programmatically, even using environment variables. I even tried to add permission to the system folder, and it's not working anyway. Always the same issue.

marc_s's user avatar
marc_s
759k185 gold badges1.4k silver badges1.5k bronze badges
askedSep 25 at 19:05
Agustín Catellani's user avatar
4
  • What identity (user) is used for the process accessing the NuGet API; and what's the ACL on the config file?CommentedSep 25 at 19:47
  • From memory, IIS has a setting somewhere to tell it to "load profile" for the account that the pool or something is running as. Point is that it needs the user profile loaded.CommentedSep 25 at 20:02
  • If you're accessing your github package feed, I think you still can't access it without authentication stateCommentedSep 26 at 12:16
  • Richard, is using the App Identity of the pool. The file in this case, and in that location does not exists.CommentedSep 26 at 15:46

0

Know someone who can answer? Share a link to thisquestion viaemail,Twitter, orFacebook.

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.