【问题标题】:How to create NuGet.config for my project?如何为我的项目创建 NuGet.config?
【发布时间】:2021-08-23 06:26:49
【问题描述】:

我有一个小项目(稍后我会添加一些文件)。在 VS 中,从工具->NuGet 包管理器

我的仓库中的目录

Mode                 LastWriteTime         Length Name                                                                                  
----                 -------------         ------ ----                                                                                  
d-----         8/22/2021   3:28 PM                bin                                                                                   
d-----         8/22/2021   6:11 PM                obj                                                                                   
-a----         8/22/2021   6:12 PM           9563 Appointments.csproj                                                                   
-a----         8/20/2021   1:57 PM            344 Appointments.csproj.user                                                              
------         7/27/2021   7:13 AM           2100 Appointments.sln                                                                      
------         7/27/2021   7:13 AM           1749 Package.appxmanifest                                                                  
------         7/27/2021   7:13 AM           1985 SampleConfiguration.cs                                                                
------         7/27/2021   7:13 AM          12184 Scenario1_Define.xaml.cs                                                              
------         7/27/2021   7:13 AM           2334 Scenario2_Add.xaml.cs                                                                 
------         7/27/2021   7:13 AM           3991 Scenario3_Replace.xaml.cs                                                             
------         7/27/2021   7:13 AM           3387 Scenario4_Remove.xaml.cs                                                              
------         7/27/2021   7:13 AM           1475 Scenario5_Show.xaml.cs                                                                
------         7/27/2021   7:13 AM           6284 Scenario6_Recurrence.xaml.cs 

用于解决方案的 Nuget 包

如何在我的仓库中创建 NuGet.config 文件?

【问题讨论】:

  • 您使用自定义 nuget 存储库吗?否则你不需要任何 NuGet.conf 文件,因为使用了全局文件。更多信息请关注docs.microsoft.com/en-us/nuget/reference/nuget-config-file
  • @MichaelMairegger 我想将代码推送到 Azure Devops,所以我认为 NuGet.conf 文件在这种情况下会有所帮助。
  • @MichaelMairegger 我只有 UWP,但以后可能需要更多包。
  • 如果您需要的每个包都可以在 nuget.org 上找到,那么您无需执行任何操作。通常是这种情况。

标签: c# nuget


【解决方案1】:

假设您已安装 .NET (Core) SDK,因此有可用的 dotnet CLI,请在要创建 nuget.config 文件的目录中运行 dotnet new nugetconfig

我还建议使用 dotnet cli 和/或 nuget.exe 来编辑文件,或使用文本编辑器进行编辑。 Visual Studio 选项对话框不够复杂,无法知道要将源添加到哪个 nuget.config 文件(并且不提供用于编辑源以外的任何设置的 gui),因此您可能会找到源并从中添加和删除nuget.config 文件,如果你不使用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2010-11-13
    相关资源
    最近更新 更多