也许您可以帮助我使用私人 NuGet feed 进行身份验证,我已经花了一天时间研究不同的解决方案并注意到这个仓库 https://github.com/microsoft/artifacts-credprovider,但我仍在努力完成它。
我使用下面具有不同变体的 Dockerfile,但每次都未经授权
FROM microsoft/dotnet:2.2-sdk AS build
ARG VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
WORKDIR /api
#ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS={"endpointCredentials":[{"endpoint":"https://name.pkgs.visualstudio.com/_packaging/Feed/nuget/v3/index.json","username":"PAT","password":"PAT"}]}
# Auth with private feed
RUN wget https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh \
&& chmod +x installcredprovider.sh \
&& ./installcredprovider.sh
# Copy csproj and restore as distinct layers
COPY ["App.csproj", "./"]
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS runtime
WORKDIR /api
COPY --from=build /api/out ./
EXPOSE 4444
ENTRYPOINT ["dotnet", "App.dll"]
我尝试使用 ARG 和 ENV 设置 VSS_NUGET_EXTERNAL_FEED_ENDPOINTS,但每次都会收到此错误:
error NU1101: Unable to find package Package.Name. No packages exist with this id in source(s): nuget.org
目前我们的项目中没有专用的NuGet.Config,也许是这个问题的情况?
我需要创建它并将此私人存储库添加到其中吗?
谢谢。
Nuget.config
不是必需的,但是在恢复包时需要指定源,因为只有默认源(https://api.nuget.org/v3/index.json https://api.nuget.org/v3/index.json)
Dockerfile(我修改了环境变量):
FROM microsoft/dotnet:2.2-sdk AS build
#ARG VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
WORKDIR /api
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS '{"endpointCredentials":[{"endpoint":"https://pkgs.dev.azure.com/org/_packaging/feedname/nuget/v3/index.json","username":"name","password":"your personal access token"}]}'
# Auth with private feed
RUN wget https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh \
&& chmod +x installcredprovider.sh \
&& ./installcredprovider.sh
# Copy csproj and restore as distinct layers
COPY ["App.csproj", "./"]
RUN dotnet restore -s "https://pkgs.dev.azure.com/org/_packaging/feedname/nuget/v3/index.json" -s "https://api.nuget.org/v3/index.json"
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS runtime
WORKDIR /api
COPY --from=build /api/out ./
EXPOSE 4444
ENTRYPOINT ["dotnet", "App.dll"]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)