From d79f4f69d948442c5e81ea6967bb1e16d01662af Mon Sep 17 00:00:00 2001 From: jklawreszuk Date: Fri, 8 Nov 2024 20:52:23 +0200 Subject: [PATCH] feat: Get LocalAppData path from Environment.SpecialFolder obj --- .../Stride.NuGetResolver/NuGetAssemblyResolver.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs b/sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs index 5f6e66a478..6d63739c8c 100644 --- a/sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs +++ b/sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs @@ -1,14 +1,9 @@ // Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) // Distributed under the MIT license. See the LICENSE.md file in the project root for more information. -using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection; using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; using NuGet.Common; using NuGet.Configuration; using NuGet.Frameworks; @@ -18,7 +13,7 @@ namespace Stride.Core.Assets { public class NuGetAssemblyResolver { - public const string DevSource = @"%LocalAppData%\Stride\NugetDev"; + public const string DevSource = @"Stride\NugetDev"; static bool assembliesResolved; static readonly object assembliesLock = new object(); @@ -39,16 +34,16 @@ public static void SetupNuGet(string targetFramework, string packageName, string { // Make sure our nuget local store is added to nuget config var folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - string strideFolder = null; + var devSourcePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), DevSource); + while (folder != null) { if (File.Exists(Path.Combine(folder, @"build\Stride.sln"))) { - strideFolder = folder; var settings = NuGet.Configuration.Settings.LoadDefaultSettings(null); - Directory.CreateDirectory(Environment.ExpandEnvironmentVariables(DevSource)); - CheckPackageSource(settings, "Stride Dev", NuGet.Configuration.Settings.ApplyEnvironmentTransform(DevSource)); + Directory.CreateDirectory(devSourcePath); + CheckPackageSource(settings, "Stride Dev", devSourcePath); settings.SaveToDisk(); break;