Forum Visual Studio

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Third party package source in Visual Studio for Mac

trampstertrampster Member ✭✭✭
edited May 2020 in Visual Studio

We host our own nuget package source for some internal nuget packages

This works fine from Visual Studio for Windows. However on Visual Studio for Mac the build breaks with errors:

NuGet Config files used:
/Users/unifydev/.config/NuGet/NuGet.Config

Feeds used:
https://api.nuget.org/v3/index.json

Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package CoAPNetMobile. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Restore failed.

It appears to be using the NuGet.Config from my home folder instead of the one from my source. Which is in a folder called .nuget in the same folder as my solution.

The nuget manager in Visual Studio for Mac can see the package source and browse it no problem. But the build isn't using it. Is there a way to fix this or do I have to configure it in my home directly (affecting all projects instead of just the one that needs it)

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    It seems we need to use environment variables in nuget.config values (NuGet 3.4+) to apply settings at run time.

    For example, if the HOME environment variable on Windows is set to c:\users\username, then the value of %HOME%\NuGetRepository in the configuration file resolves to c:\users\username\NuGetRepository.

    Refer https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file#using-environment-variables.

  • trampstertrampster Member ✭✭✭

    @ColeX that document tells you how to use environment variables in your nuget config, but Its using the wrong config (from home instead of from project)

    So adding environment variables to it cannot possibly help.

  • mattwardmattward GBMember Xamurai

    If you move the NuGet.Config to the solution directory it should work. NuGet does not seem to check in the SolutionDir/.nuget directory for NuGet.Config files anymore. Older versions used to.

Sign In or Register to comment.