11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ #pragma warning disable ASPIREFILESYSTEM001 // Type is for evaluation purposes only
5+
46using System . Globalization ;
57using System . Text ;
68using System . Xml . Linq ;
@@ -22,12 +24,14 @@ internal static class MauiEnvironmentHelper
2224 /// <summary>
2325 /// Creates an MSBuild targets file for Android that sets environment variables.
2426 /// </summary>
27+ /// <param name="fileSystemService">The file system service for managing temp files.</param>
2528 /// <param name="resource">The resource to collect environment variables from.</param>
2629 /// <param name="executionContext">The execution context.</param>
2730 /// <param name="logger">Logger for diagnostic output.</param>
2831 /// <param name="cancellationToken">Cancellation token.</param>
2932 /// <returns>The path to the generated targets file, or null if no environment variables are present.</returns>
3033 public static async Task < string ? > CreateAndroidEnvironmentTargetsFileAsync (
34+ IFileSystemService fileSystemService ,
3135 IResource resource ,
3236 DistributedApplicationExecutionContext executionContext ,
3337 ILogger logger ,
@@ -68,8 +72,7 @@ await resource.ProcessEnvironmentVariableValuesAsync(
6872 }
6973
7074 // Create a temporary targets file
71- var tempDirectory = Path . Combine ( Path . GetTempPath ( ) , "aspire" , "maui" , "android-env" ) ;
72- Directory . CreateDirectory ( tempDirectory ) ;
75+ var tempDirectory = fileSystemService . TempDirectory . CreateTempSubdirectory ( "aspire-maui-android-env" ) . Path ;
7376
7477 // Prune old targets files
7578 PruneOldTargets ( tempDirectory , logger ) ;
@@ -215,12 +218,14 @@ private static string EncodeSemicolons(string value, out bool wasEncoded)
215218 /// <summary>
216219 /// Creates an MSBuild targets file for iOS that sets environment variables.
217220 /// </summary>
221+ /// <param name="fileSystemService">The file system service for managing temp files.</param>
218222 /// <param name="resource">The resource to collect environment variables from.</param>
219223 /// <param name="executionContext">The execution context.</param>
220224 /// <param name="logger">Logger for diagnostic output.</param>
221225 /// <param name="cancellationToken">Cancellation token.</param>
222226 /// <returns>The path to the generated targets file, or null if no environment variables are present.</returns>
223227 public static async Task < string ? > CreateiOSEnvironmentTargetsFileAsync (
228+ IFileSystemService fileSystemService ,
224229 IResource resource ,
225230 DistributedApplicationExecutionContext executionContext ,
226231 ILogger logger ,
@@ -251,8 +256,7 @@ await resource.ProcessEnvironmentVariableValuesAsync(
251256 }
252257
253258 // Create a temporary targets file
254- var tempDirectory = Path . Combine ( Path . GetTempPath ( ) , "aspire" , "maui" , "mlaunch-env" ) ;
255- Directory . CreateDirectory ( tempDirectory ) ;
259+ var tempDirectory = fileSystemService . TempDirectory . CreateTempSubdirectory ( "aspire-maui-mlaunch-env" ) . Path ;
256260
257261 // Prune old targets files
258262 PruneOldTargetsiOS ( tempDirectory , logger ) ;
0 commit comments