Skip to content
Permalink
Browse files

[NuGet] Add dev store before trying to restore packets

  • Loading branch information
xen2 committed Nov 26, 2018
1 parent 091ddeb commit 95f15bd884002a4fe3ade0ac34b33e9489c5d1dd
@@ -63,11 +63,11 @@ public class NugetStore : INugetDownloadProgress
/// <param name="rootDirectory">The location of the Nuget store.</param>
public NugetStore(string rootDirectory)
{
settings = NuGet.Configuration.Settings.LoadDefaultSettings(Directory.GetCurrentDirectory());
settings = NuGet.Configuration.Settings.LoadDefaultSettings(null);

// Add dev source
Directory.CreateDirectory(Environment.ExpandEnvironmentVariables(DevSource));
CheckPackageSource("Xenko Dev", DevSource);
CheckPackageSource("Xenko Dev", NuGet.Configuration.Settings.ApplyEnvironmentTransform(DevSource));
CheckPackageSource("Xenko", DefaultPackageSource);

InstallPath = SettingsUtility.GetGlobalPackagesFolder(settings);
@@ -88,11 +88,8 @@ public NugetStore(string rootDirectory)
private void CheckPackageSource(string name, string url)
{
var settingsPackageSources = settings.GetSettingValues("packageSources", true);
if (!settingsPackageSources.Any(x => x.Key == name && x.Value == url))
{
settings.DeleteValue("packageSources", name);
settings.SetValue("packageSources", name, url);
}
settings.AddOrUpdate("packageSources", new SourceItem(name, url));
settings.SaveToDisk();
}

private readonly NugetSourceRepositoryProvider sourceRepositoryProvider;
@@ -21,6 +21,8 @@ namespace Xenko.Core.Assets
{
static class RestoreHelper
{
public const string DevSource = @"%LocalAppData%\Xenko\NugetDev";

public static List<string> ListAssemblies(RestoreRequest request, RestoreResult result)
{
var assemblies = new List<string>();
@@ -47,7 +49,11 @@ public static List<string> ListAssemblies(RestoreRequest request, RestoreResult

public static async Task<(RestoreRequest, RestoreResult)> Restore(ILogger logger, string packageName, VersionRange versionRange)
{
var settings = NuGet.Configuration.Settings.LoadDefaultSettings(Directory.GetCurrentDirectory());
var settings = NuGet.Configuration.Settings.LoadDefaultSettings(null);

// Make sure our nuget local store is added to config
CheckPackageSource(settings, "Xenko Dev", NuGet.Configuration.Settings.ApplyEnvironmentTransform(DevSource));

var packageSourceProvider = new PackageSourceProvider(settings);

// not sure what these do, but it was in the NuGet command line.
@@ -128,5 +134,12 @@ public static async Task<(RestoreRequest, RestoreResult)> Restore(ILogger logger
return (mainResult.SummaryRequest.Request, mainResult.Result);
}
}

private static void CheckPackageSource(ISettings settings, string name, string url)
{
var settingsPackageSources = settings.GetSettingValues("packageSources", true);
settings.AddOrUpdate("packageSources", new SourceItem(name, url));
settings.SaveToDisk();
}
}
}
@@ -17,7 +17,7 @@
</PropertyGroup>
<Target Name="IncludeNuGetResolverAssemblies">
<ItemGroup>
<BuildOutputInPackage Include="$(OutputPath)System.ValueTuple.dll" />
<BuildOutputInPackage Include="$(OutputPath)System.ValueTuple.dll" />
<BuildOutputInPackage Include="$(OutputPath)NuGet*.dll" />
<BuildOutputInPackage Include="$(OutputPath)Newtonsoft.Json.dll" />
</ItemGroup>

0 comments on commit 95f15bd

Please sign in to comment.
You can’t perform that action at this time.