1010using System . Runtime . InteropServices ;
1111using Microsoft . VisualStudio . Services . WebApi ;
1212using Newtonsoft . Json . Linq ;
13- using System . IO ;
1413
1514namespace Microsoft . VisualStudio . Services . Agent . Util
1615{
@@ -218,39 +217,39 @@ private static bool TryGetValue(Tracing trace, IDictionary<string, string> sourc
218217 return false ;
219218 }
220219
221- public static string GetTfDirectoryPath ( IKnobValueContext context )
220+ public static string GetServerOMPath ( IHostContext hostContext , IKnobValueContext context )
222221 {
223- var ( useLatest , useLegacy , externalsPath ) = GetKnobsAndExternalsPath ( context ) ;
222+ ArgUtil . NotNull ( hostContext , nameof ( hostContext ) ) ;
223+ ArgUtil . NotNull ( context , nameof ( context ) ) ;
224224
225- return useLatest
226- ? Path . Combine ( externalsPath , Constants . Path . TfLatestDirectory )
227- : useLegacy
228- ? Path . Combine ( externalsPath , Constants . Path . TfLegacyDirectory )
229- : Path . Combine ( externalsPath , Constants . Path . ServerOMDirectory ) ;
225+ return AgentKnobs . UseLatestTfExe . GetValue ( context ) . AsBoolean ( )
226+ ? hostContext . GetDirectory ( WellKnownDirectory . ServerOMLatest )
227+ : AgentKnobs . InstallLegacyTfExe . GetValue ( context ) . AsBoolean ( )
228+ ? hostContext . GetDirectory ( WellKnownDirectory . ServerOMLegacy )
229+ : hostContext . GetDirectory ( WellKnownDirectory . ServerOM ) ;
230230 }
231231
232- public static string GetLegacyPowerShellHostDirectoryPath ( IKnobValueContext context )
232+ public static string GetTfPath ( IHostContext hostContext , IKnobValueContext context )
233233 {
234- var ( useLatest , useLegacy , externalsPath ) = GetKnobsAndExternalsPath ( context ) ;
234+ ArgUtil . NotNull ( hostContext , nameof ( hostContext ) ) ;
235+ ArgUtil . NotNull ( context , nameof ( context ) ) ;
235236
236- return ! useLatest && useLegacy
237- ? Path . Combine ( externalsPath , Constants . Path . LegacyPSHostLegacyDirectory )
238- : Path . Combine ( externalsPath , Constants . Path . LegacyPSHostDirectory ) ;
237+ return AgentKnobs . UseLatestTfExe . GetValue ( context ) . AsBoolean ( )
238+ ? hostContext . GetDirectory ( WellKnownDirectory . TfLatest )
239+ : AgentKnobs . InstallLegacyTfExe . GetValue ( context ) . AsBoolean ( )
240+ ? hostContext . GetDirectory ( WellKnownDirectory . TfLegacy )
241+ : hostContext . GetDirectory ( WellKnownDirectory . Tf ) ;
239242 }
240243
241-
242-
243- private static ( bool useLatest , bool useLegacy , string externalsPath ) GetKnobsAndExternalsPath ( IKnobValueContext context )
244+ public static string GetTfDirectoryName ( IKnobValueContext context )
244245 {
245246 ArgUtil . NotNull ( context , nameof ( context ) ) ;
246247
247- bool useLatest = AgentKnobs . UseLatestTfExe . GetValue ( context ) . AsBoolean ( ) ;
248- bool useLegacy = AgentKnobs . InstallLegacyTfExe . GetValue ( context ) . AsBoolean ( ) ;
249-
250- string agentHomeDirectory = context . GetVariableValueOrDefault ( Constants . Variables . Agent . HomeDirectory ) ;
251- string externalsPath = Path . Combine ( agentHomeDirectory , Constants . Path . ExternalsDirectory ) ;
252-
253- return ( useLatest , useLegacy , externalsPath ) ;
248+ return AgentKnobs . UseLatestTfExe . GetValue ( context ) . AsBoolean ( )
249+ ? "tf-latest"
250+ : AgentKnobs . InstallLegacyTfExe . GetValue ( context ) . AsBoolean ( )
251+ ? "tf-legacy"
252+ : "tf" ;
254253 }
255254 }
256255}
0 commit comments