我们在本地TFS中使用私有nuget Feed(使用Package Management扩展名)。我们可以在本地和构建服务器上使用它而不会出现问题。现在我们正在使用Docker,我们知道我们需要使用外部源复制nuget.config,以便dotnet能够获得所需的包。此文件已存储所需的URL和凭据,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="XXX" value="https://xxx.xxx.xx/tfs/xxx/_packaging/xxxPackageFeed/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<XXX>
<add key="Username" value="domain\user" />
<add key="ClearTextPassword" value="password" />
</XXX>
</packageSourceCredentials>
</configuration>
我们已经验证,当我们使用Windows容器时,它会成功构建。如果我们切换到Linux容器,它将失败并显示消息:
Step 8/17 : RUN dotnet restore -nowarn:msb3202,nu1503
---> Running in f2b837b36b6b
Restoring packages for /src/xxx/xxx.csproj...
/usr/share/dotnet/sdk/2.1.101/NuGet.targets(104,5): error : Unable to load the service index for source https://xxx.xxx.xx/tfs/xxx/_packaging/xxxPackageFeed/nuget/v3/index.json. [/src/xxx.sln]
/usr/share/dotnet/sdk/2.1.101/NuGet.targets(104,5): error : Response status code does not indicate success: 401 (Unauthorized). [/src/xxx.sln]
ERROR: Service 'xxx-dev' failed to build: The command '/bin/sh -c dotnet restore -nowarn:msb3202,nu1503' returned a non-zero code: 1
有关如何使域凭据在Linux容器中工作的任何想法吗?