Skip to content
Permalink
Browse files

[Launcher] Various fixes for downloading and error reporting

  • Loading branch information
xen2 committed Dec 24, 2018
1 parent c681063 commit 6c21e9ac03df9a95352fce6ff489d7d25dc5ced4
@@ -303,11 +303,11 @@ public async Task<NugetLocalPackage> InstallPackage(string packageId, PackageVer
installPath = oldRootDirectory;
}

var specPath = Path.Combine("TestProject", "project.json");
var projectPath = Path.Combine("XenkoLauncher.json");
var spec = new PackageSpec()
{
Name = "TestProject", // make sure this package never collides with a dependency
FilePath = specPath,
Name = Path.GetFileNameWithoutExtension(projectPath), // make sure this package never collides with a dependency
FilePath = projectPath,
Dependencies = new List<LibraryDependency>()
{
new LibraryDependency
@@ -322,35 +322,63 @@ public async Task<NugetLocalPackage> InstallPackage(string packageId, PackageVer
FrameworkName = NuGetFramework.Parse("net472"),
}
},
RestoreMetadata = new ProjectRestoreMetadata
{
ProjectPath = projectPath,
ProjectName = Path.GetFileNameWithoutExtension(projectPath),
ProjectStyle = ProjectStyle.PackageReference,
ProjectUniqueName = projectPath,
OutputPath = Path.Combine(Path.GetTempPath(), $"XenkoLauncher-{packageId}-{version.ToString()}"),
OriginalTargetFrameworks = new[] { "net472" },
ConfigFilePaths = settings.GetConfigFilePaths(),
PackagesPath = installPath,
Sources = SettingsUtility.GetEnabledSources(settings).ToList(),
FallbackFolders = SettingsUtility.GetFallbackPackageFolders(settings).ToList()
},
};

using (var context = new SourceCacheContext())
{
context.IgnoreFailedSources = true;

var provider = RestoreCommandProviders.Create(installPath, new List<string>(), sourceRepositoryProvider.GetRepositories(), context, new LocalPackageFileCache(), NativeLogger);
var request = new RestoreRequest(spec, provider, context, null, NativeLogger)
{
//RequestedRuntimes = { "win-d3d11" },
ProjectStyle = ProjectStyle.DotnetCliTool,
};
var dependencyGraphSpec = new DependencyGraphSpec();

var command = new RestoreCommand(request);
dependencyGraphSpec.AddProject(spec);

// Act
var result = await command.ExecuteAsync();
dependencyGraphSpec.AddRestore(spec.RestoreMetadata.ProjectUniqueName);

if (!result.Success)
IPreLoadedRestoreRequestProvider requestProvider = new DependencyGraphSpecRequestProvider(new RestoreCommandProvidersCache(), dependencyGraphSpec);

var restoreArgs = new RestoreArgs
{
throw new InvalidOperationException($"Could not restore package {packageId}");
}
foreach (var install in result.RestoreGraphs.Last().Install)
AllowNoOp = true,
CacheContext = context,
CachingSourceProvider = new CachingSourceProvider(new PackageSourceProvider(settings)),
Log = NativeLogger,
};

// Create requests from the arguments
var requests = requestProvider.CreateRequests(restoreArgs).Result;

foreach (var request in requests)
{
var package = result.LockFile.Libraries.FirstOrDefault(x => x.Name == install.Library.Name && x.Version == install.Library.Version);
if (package != null)
var command = new RestoreCommand(request.Request);

// Act
var result = await command.ExecuteAsync();

if (!result.Success)
{
throw new InvalidOperationException($"Could not restore package {packageId}");
}
foreach (var install in result.RestoreGraphs.Last().Install)
{
var packagePath = Path.Combine(installPath, package.Path);
OnPackageInstalled(this, new PackageOperationEventArgs(new PackageName(install.Library.Name, install.Library.Version.ToPackageVersion()), packagePath));
var package = result.LockFile.Libraries.FirstOrDefault(x => x.Name == install.Library.Name && x.Version == install.Library.Version);
if (package != null)
{
var packagePath = Path.Combine(installPath, package.Path);
OnPackageInstalled(this, new PackageOperationEventArgs(new PackageName(install.Library.Name, install.Library.Version.ToPackageVersion()), packagePath));
}
}
}
}
@@ -247,7 +247,7 @@ protected Task Download(bool displayErrorMessage)

if (displayErrorMessage)
{
var message = $"{InstallErrorMessage}{e.FormatSummary(true)}";
var message = $"{InstallErrorMessage}{Environment.NewLine}{Environment.NewLine}{Launcher.LastErrorOrWarning?.Replace(Environment.NewLine, Environment.NewLine + Environment.NewLine) ?? string.Empty}{Environment.NewLine}{e.FormatSummary(true)}";
await ServiceProvider.Get<IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
@@ -46,8 +46,8 @@ public override string FullName
get
{
var result = Version?.ToString() ?? "Unknown";
if (ServerPackage != null)
result += $" ({ServerPackage.Source})";
//if (ServerPackage != null)
// result += $" ({ServerPackage.Source})";
return result;
}
}
@@ -28,7 +28,7 @@
<AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies>

<!-- Assembly version for the launcher, used to generate the appropriate nuget package -->
<InformationalVersion>3.0.2</InformationalVersion>
<InformationalVersion>3.0.3</InformationalVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -2,7 +2,7 @@
<package>
<metadata>
<id>Xenko.Launcher</id>
<version>3.0.2</version>
<version>3.0.3</version>
<authors>Xenko</authors>
<owners>Xenko</owners>
<licenseUrl>http://xenko.com/license.txt</licenseUrl>

0 comments on commit 6c21e9a

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