Skip to content

Commit 70a8faf

Browse files
committed
Enable CredentialProvider
1 parent ee86575 commit 70a8faf

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ RUN dotnet publish src -a $TARGETARCH -c Release -o /app/src/out
1717
FROM mcr.microsoft.com/dotnet/aspnet:7.0
1818
WORKDIR /app
1919
COPY --from=build /app/src/out .
20-
RUN mkdir /root/.nuget
20+
21+
# Install Azure Artifacts Credential Provider for MSI authentication
22+
RUN apt-get update && apt-get install -y wget unzip curl && \
23+
wget -qO- https://aka.ms/install-artifacts-credprovider.sh | bash && \
24+
apt-get clean && rm -rf /var/lib/apt/lists/*
25+
26+
RUN mkdir -p /root/.nuget/NuGet
2127
COPY ./NuGet.Config /root/.nuget/NuGet/NuGet.Config
2228
ENTRYPOINT ["dotnet", "UnityNuGet.Server.dll"]

src/UnityNuGet/RegistryCache.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
44
using System.IO;
@@ -14,6 +14,7 @@
1414
using Newtonsoft.Json;
1515
using NuGet.Common;
1616
using NuGet.Configuration;
17+
using NuGet.Credentials;
1718
using NuGet.Frameworks;
1819
using NuGet.PackageManagement;
1920
using NuGet.Packaging;
@@ -56,6 +57,9 @@ public RegistryCache(RegistryCache registryCache) : this(registryCache._rootPers
5657
public RegistryCache(string rootPersistentFolder, Uri rootHttpUri, string unityScope, string minimumUnityVersion,
5758
string packageNameNuGetPostFix, RegistryTargetFramework[] targetFrameworks, ILogger logger)
5859
{
60+
// Initialize credential service ONCE at app startup
61+
DefaultCredentialServiceUtility.SetupDefaultCredentialService(logger, nonInteractive: true);
62+
5963
_rootPersistentFolder = rootPersistentFolder ?? throw new ArgumentNullException(nameof(rootPersistentFolder));
6064
_rootHttpUri = rootHttpUri ?? throw new ArgumentNullException(nameof(rootHttpUri));
6165
_unityScope = unityScope ?? throw new ArgumentNullException(nameof(unityScope));

0 commit comments

Comments
 (0)