Skip to content

Commit 8c81b4c

Browse files
Log a warning when hostobject found with no creds (#228)
1 parent 493caf7 commit 8c81b4c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Microsoft.NET.Build.Containers/CreateNewImageToolTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ string responseFileSwitch
156156
)
157157
{
158158
VSHostObject hostObj = new VSHostObject(HostObject as System.Collections.Generic.IEnumerable<ITaskItem>);
159-
if (hostObj.ExtractCredentials(out string user, out string pass))
159+
if (hostObj.ExtractCredentials(out string user, out string pass, (string s) => Log.LogWarning(s)))
160160
{
161161
extractionInfo = (true, user, pass);
162162
}

Microsoft.NET.Build.Containers/VSHostObject.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
34
using Microsoft.Build.Framework;
@@ -16,7 +17,7 @@ public VSHostObject(IEnumerable<ITaskItem>? hostObject)
1617
_hostObject = hostObject;
1718
}
1819

19-
public bool ExtractCredentials(out string username, out string password)
20+
public bool ExtractCredentials(out string username, out string password, Action<string> logMethod)
2021
{
2122
bool retVal = false;
2223
username = password = string.Empty;
@@ -31,6 +32,10 @@ public bool ExtractCredentials(out string username, out string password)
3132
{
3233
password = credentialItem.GetMetadata(PasswordMetaDataName);
3334
}
35+
else
36+
{
37+
logMethod("HostObject credentials not detected. Falling back to Docker credential retrieval.");
38+
}
3439
}
3540
}
3641
return retVal;

0 commit comments

Comments
 (0)