如何在运行时添加Nuget包源?

How to add Nuget Package Source at runtime?

我有一个Nuget.Serverhttp://localhost/ABC。我必须将其用作项目中的提要。我现在可以要求用户将 URL 输入到 Nuget 服务器,我如何添加它并在 C# 的同一会话中使用它?我不想手动添加到包管理器。

我有一个应用程序 XYZ,它已启动并请求用户 URL 到 Nuget.Server。然后它会将其添加到提要中,稍后调用

installer.InstallPackage("All", project, "myPackage", (Version)null, false);

我该怎么做?

创建一个安装程序,它将使用 Nuger 服务器 URL 并调用 Nuget.exe 来源添加 -Name -Source \nuget