Skip to content

Commit

Permalink
feat: Get LocalAppData path from Environment.SpecialFolder obj
Browse files Browse the repository at this point in the history
  • Loading branch information
Jklawreszuk committed Nov 8, 2024
1 parent d744a42 commit d79f4f6
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit d79f4f6

Please sign in to comment.