命令行 dotnet 正在尝试将企业 nuget 提要用于开源解决方案 - 如何让它绕过它?
Command line dotnet is trying to use a corporate nuget feed for an open source solution - how to get it to bypass that?
我只是想从命令行编译然后 运行 测试。我不是要发布包。这是我在克隆 https://github.com/wouter1981/commercial-model:
后 运行
C:\Users\paul_h\scm\oss\commercial-model>dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/ourcompany/_packaging/ourcompany@Local/nuget/v3/index.json. [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
Build FAILED.
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/ourcompany/_packaging/ourcompany@Local/nuget/v3/index.json. [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.60
理想情况下,我正在寻找一个选项来指定 cmd.exe
中的 dotnet
命令,这将使其跳过公司的提要并仅从 public nuget 中提取依赖项喂养。说 --ignoreGlobalFeed
。我认为它不存在,那么命令行上 .NET 6.x 的替代方案是什么?
将特定的 NuGet 配置添加到解决方案文件夹
dotnet new nugetconfig
这将添加新文件 nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
在那里您将能够定义包源。
之后运行
dotnet build
更新
或者只添加特定的 nuget 提要到构建命令:
dotnet build --source https://api.nuget.org/v3/index.json
我只是想从命令行编译然后 运行 测试。我不是要发布包。这是我在克隆 https://github.com/wouter1981/commercial-model:
后 运行C:\Users\paul_h\scm\oss\commercial-model>dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/ourcompany/_packaging/ourcompany@Local/nuget/v3/index.json. [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
Build FAILED.
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/ourcompany/_packaging/ourcompany@Local/nuget/v3/index.json. [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
C:\Program Files\dotnet\sdk.0.102\NuGet.targets(130,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\paul_h\scm\oss\commercial-model\CommercialModel.sln]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.60
理想情况下,我正在寻找一个选项来指定 cmd.exe
中的 dotnet
命令,这将使其跳过公司的提要并仅从 public nuget 中提取依赖项喂养。说 --ignoreGlobalFeed
。我认为它不存在,那么命令行上 .NET 6.x 的替代方案是什么?
将特定的 NuGet 配置添加到解决方案文件夹
dotnet new nugetconfig
这将添加新文件 nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
在那里您将能够定义包源。
之后运行
dotnet build
更新
或者只添加特定的 nuget 提要到构建命令:
dotnet build --source https://api.nuget.org/v3/index.json