Skip to content

Commit a989770

Browse files
committed
Adding AzureArtifactsCredentialProviderComponent.
1 parent 93a286a commit a989770

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
using JetBrains.Annotations;
4+
using System.IO;
5+
6+
namespace PostSharp.Engineering.BuildTools.Docker;
7+
8+
[PublicAPI]
9+
public sealed class AzureArtifactsCredentialProviderComponent : ContainerComponent
10+
{
11+
public override string Name => "AzureArtifactsCredentialProvider";
12+
13+
public override ContainerComponentKind Kind => ContainerComponentKind.AzureArtifactsCredentialProvider;
14+
15+
public override void WriteDockerfile( TextWriter writer )
16+
{
17+
writer.WriteLine(
18+
"""
19+
RUN $credProviderUrl = 'https://github.com/microsoft/artifacts-credprovider/releases/download/v1.1.2/Microsoft.NuGet.CredentialProvider.zip'; `
20+
$credProviderZip = 'Microsoft.NuGet.CredentialProvider.zip'; `
21+
$pluginsDir = 'C:\ProgramData\NuGet\plugins\netfx\CredentialProvider.Microsoft'; `
22+
Invoke-WebRequest -Uri $credProviderUrl -OutFile $credProviderZip; `
23+
New-Item -ItemType Directory -Force -Path $pluginsDir | Out-Null; `
24+
Expand-Archive -Path $credProviderZip -DestinationPath $pluginsDir -Force; `
25+
Move-Item -Path "$pluginsDir\plugins\netfx\CredentialProvider.Microsoft\*" -Destination $pluginsDir -Force; `
26+
Remove-Item -Path "$pluginsDir\plugins" -Recurse -Force; `
27+
Remove-Item $credProviderZip
28+
29+
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED=true
30+
""" );
31+
}
32+
}

src/PostSharp.Engineering.BuildTools/Docker/ContainerComponentKind.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public enum ContainerComponentKind
1818
Python,
1919
Gulp,
2020
GitHubCli,
21+
AzureArtifactsCredentialProvider,
2122
Timestamp,
2223
Claude,
23-
Epilogue
24+
Epilogue,
25+
2426
}

0 commit comments

Comments
 (0)