Skip to content

Commit e381661

Browse files
committed
Merge remote-tracking branch 'origin/master' into Localization
2 parents 9386370 + 8027e72 commit e381661

32 files changed

+604
-351
lines changed

src/Agent.Listener/Agent.Listener.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="6.0.0-preview.5.21301.5" />
2222
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.1" />
2323
<PackageReference Include="vss-api-netcore" Version="$(VssApiVersion)" />
24+
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.2" />
25+
<PackageReference Include="Microsoft.Azure.Storage.DataMovement" Version="2.0.5" />
26+
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
27+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
2428
</ItemGroup>
2529

2630
<ItemGroup>

src/Agent.Listener/Agent.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.VisualStudio.Services.Agent.Listener.Telemetry;
2020
using System.Collections.Generic;
2121
using Newtonsoft.Json;
22+
using Agent.Sdk.Knob;
2223

2324
namespace Microsoft.VisualStudio.Services.Agent.Listener
2425
{
@@ -326,6 +327,18 @@ private async Task<int> RunAsync(AgentSettings settings, bool runOnce = false)
326327
try
327328
{
328329
Trace.Info(nameof(RunAsync));
330+
331+
if (PlatformUtil.RunningOnWindows && AgentKnobs.CheckPsModulesLocations.GetValue(HostContext).AsBoolean())
332+
{
333+
string psModulePath = Environment.GetEnvironmentVariable("PSModulePath");
334+
bool containsPwshLocations = PsModulePathUtil.ContainsPowershellCoreLocations(psModulePath);
335+
336+
if (containsPwshLocations)
337+
{
338+
_term.WriteLine(StringUtil.Loc("PSModulePathLocations"));
339+
}
340+
}
341+
329342
_listener = HostContext.GetService<IMessageListener>();
330343
if (!await _listener.CreateSessionAsync(HostContext.AgentShutdownToken))
331344
{

src/Agent.PluginHost/Agent.PluginHost.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
1515
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
1616
<PackageReference Include="vss-api-netcore" Version="$(VssApiVersion)" />
17+
<PackageReference Include="Microsoft.Azure.Storage.DataMovement" Version="2.0.5" />
18+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
19+
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
1720
</ItemGroup>
1821
</Project>

src/Agent.Plugins/Agent.Plugins.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
<ItemGroup>
1616
<PackageReference Include="azuredevops-testresultparser" Version="1.0.2" />
1717
<PackageReference Include="vss-api-netcore" Version="$(VssApiVersion)" />
18+
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.2" />
19+
<PackageReference Include="Microsoft.Azure.Storage.DataMovement" Version="2.0.5" />
20+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
21+
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
1822
</ItemGroup>
1923
</Project>

src/Agent.Plugins/GitCliManager.cs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,12 @@ public bool EnsureGitLFSVersion(Version requiredVersion, bool throwOnNotMatch)
8282
return gitLfsVersion >= requiredVersion;
8383
}
8484

85-
public (string gitPath, string gitLfsPath) GetInternalGitPaths(
86-
AgentTaskPluginExecutionContext context,
87-
bool useLatestGitVersion)
85+
public (string gitPath, string gitLfsPath) GetInternalGitPaths(AgentTaskPluginExecutionContext context)
8886
{
8987
string agentHomeDir = context.Variables.GetValueOrDefault("agent.homedirectory")?.Value;
9088
ArgUtil.NotNullOrEmpty(agentHomeDir, nameof(agentHomeDir));
9189

92-
string gitPath;
93-
94-
if (useLatestGitVersion)
95-
{
96-
gitPath = Path.Combine(agentHomeDir, "externals", "ff_git", "cmd", $"git.exe");
97-
}
98-
else
99-
{
100-
gitPath = Path.Combine(agentHomeDir, "externals", "git", "cmd", $"git.exe");
101-
}
102-
103-
context.Debug($@"The useLatestGitVersion property is set to ""{useLatestGitVersion}"" therefore the Git path is ""{gitPath}""");
90+
string gitPath = Path.Combine(agentHomeDir, "externals", "git", "cmd", $"git.exe");
10491

10592
string gitLfsPath;
10693

@@ -127,12 +114,7 @@ public virtual async Task LoadGitExecutionInfo(AgentTaskPluginExecutionContext c
127114
{
128115
context.Debug("Git paths are resolving from internal dependencies");
129116

130-
var (resolvedGitPath, resolvedGitLfsPath) = GetInternalGitPaths(
131-
context,
132-
AgentKnobs.UseLatestGitVersion.GetValue(context).AsBoolean());
133-
134-
gitPath = resolvedGitPath;
135-
gitLfsPath = resolvedGitLfsPath;
117+
(gitPath, gitLfsPath) = GetInternalGitPaths(context);
136118

137119
// Prepend the PATH.
138120
context.Output(StringUtil.Loc("Prepending0WithDirectoryContaining1", "Path", Path.GetFileName(gitPath)));

src/Agent.Sdk/Agent.Sdk.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<PackageReference Include="System.Security.Principal.Windows" Version="6.0.0-preview.5.21301.5" />
1515
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
1616
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
17+
<PackageReference Include="Microsoft.Azure.Storage.DataMovement" Version="2.0.5" />
1718
<PackageReference Include="vss-api-netcore" Version="$(VssApiVersion)" />
19+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
20+
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
1821
</ItemGroup>
1922
</Project>

src/Agent.Sdk/Knob/AgentKnobs.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ public class AgentKnobs
142142
new EnvironmentKnobSource("USE_GIT_SINGLE_THREAD"),
143143
new BuiltInDefaultKnobSource("false"));
144144

145-
public static readonly Knob UseLatestGitVersion = new Knob(
146-
nameof(UseLatestGitVersion),
147-
"When true, set path to the latest git version",
148-
new RuntimeKnobSource("USE_LATEST_GIT_VERSION"),
149-
new EnvironmentKnobSource("USE_LATEST_GIT_VERSION"),
150-
new BuiltInDefaultKnobSource("false"));
151-
152145
public static readonly Knob AgentTerminalEncoding = new Knob(
153146
nameof(AgentTerminalEncoding),
154147
"If the correct encoding name is specified, the encoding from the environment will be used instead of default UTF-8",
@@ -553,6 +546,13 @@ public class AgentKnobs
553546
new EnvironmentKnobSource("AZP_75787_ENABLE_COLLECT"),
554547
new BuiltInDefaultKnobSource("false"));
555548

549+
public static readonly Knob UseNewNodeHandlerTelemetry = new Knob(
550+
nameof(UseNewNodeHandlerTelemetry),
551+
"Enables new approach to publish node handler information to the telemetry",
552+
new RuntimeKnobSource("AZP_USENEWNODEHANDLERTELEMETRY"),
553+
new EnvironmentKnobSource("AZP_USENEWNODEHANDLERTELEMETRY"),
554+
new BuiltInDefaultKnobSource("false"));
555+
556556
public static readonly Knob ProcessHandlerEnableNewLogic = new Knob(
557557
nameof(ProcessHandlerEnableNewLogic),
558558
"Enables new args protect logic for process handler",
@@ -684,13 +684,6 @@ public class AgentKnobs
684684
new EnvironmentKnobSource("AGENT_KEY_USE_CNG"),
685685
new BuiltInDefaultKnobSource("false"));
686686

687-
public static readonly Knob UseInteropToFindParentProcess = new Knob(
688-
nameof(UseInteropToFindParentProcess),
689-
"Uses native Windows function to find parent processes of a process.",
690-
new RuntimeKnobSource("AZP_AGENT_USE_INTEROP_TO_FIND_PARENT_PROCESS"),
691-
new EnvironmentKnobSource("AZP_AGENT_USE_INTEROP_TO_FIND_PARENT_PROCESS"),
692-
new BuiltInDefaultKnobSource("false"));
693-
694687
public static readonly Knob RsaKeyGetConfigFromFF = new Knob(
695688
nameof(RsaKeyGetConfigFromFF),
696689
"Get config from FF.",
@@ -711,5 +704,11 @@ public class AgentKnobs
711704
new EnvironmentKnobSource("ROSETTA2_WARNING"),
712705
new PipelineFeatureSource("Rosetta2Warning"),
713706
new BuiltInDefaultKnobSource("false"));
707+
708+
public static readonly Knob CheckPsModulesLocations = new Knob(
709+
nameof(CheckPsModulesLocations),
710+
"Checks if the PSModulePath environment variable contains locations specific to PowerShell Core.",
711+
new EnvironmentKnobSource("AZP_AGENT_CHECK_PSMODULES_LOCATIONS"),
712+
new BuiltInDefaultKnobSource("false"));
714713
}
715714
}

src/Agent.Sdk/TaskPlugin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class WellKnownJobSettings
3131
{
3232
public static readonly string HasMultipleCheckouts = "HasMultipleCheckouts";
3333
public static readonly string FirstRepositoryCheckedOut = "FirstRepositoryCheckedOut";
34+
public static readonly string DefaultWorkingDirectoryRepository = "DefaultWorkingDirectoryRepository";
3435
public static readonly string WorkspaceIdentifier = "WorkspaceIdentifier";
3536
public static readonly string CommandCorrelationId = "CommandCorrelationId";
3637
}

src/Agent.Sdk/Util/ProcessUtil.cs

Lines changed: 0 additions & 162 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Microsoft.IdentityModel.Tokens;
2+
using System;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.Versioning;
6+
7+
namespace Agent.Sdk.Util
8+
{
9+
public static class PsModulePathUtil
10+
{
11+
[SupportedOSPlatform("windows")]
12+
public static bool ContainsPowershellCoreLocations(string psModulePath)
13+
{
14+
if (psModulePath.IsNullOrEmpty())
15+
{
16+
return false;
17+
}
18+
19+
string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
20+
string programFilesPath86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
21+
22+
string psHomeModuleLocation = Path.Combine(programFilesPath, "PowerShell", "Modules");
23+
string psHomeModuleLocation86 = Path.Combine(programFilesPath86, "PowerShell", "Modules");
24+
25+
string programFilesModuleLocation = Path.Combine(programFilesPath.ToLower(), "powershell", "7", "Modules");
26+
string programFilesModuleLocation86 = Path.Combine(programFilesPath86.ToLower(), "powershell", "7", "Modules");
27+
28+
string[] wellKnownLocations = new[]
29+
{
30+
psHomeModuleLocation, psHomeModuleLocation86, programFilesModuleLocation, programFilesModuleLocation86
31+
};
32+
33+
bool containsPwshLocations = wellKnownLocations.Any(location => psModulePath.Contains(location, StringComparison.OrdinalIgnoreCase));
34+
35+
return containsPwshLocations;
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)