Cosmos/source/Cosmos.Build.Builder/Services/VisualStudioSetup/VisualStudioSetupErrorState.cs
José Pedro f969601a53
Builder improvements.
- Added check for dependencies, which can be installed from the builder.
- Replaced CosmosTask with CosmosBuildDefinition, which is much simpler.
- The builder can be opened without any command line arguments.
- If the VS path is not specified as a command line argument, it can be selected in a dialog.
2018-03-30 19:44:19 +01:00

50 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.VisualStudio.Setup.Configuration;
namespace Cosmos.Build.Builder.Services.VisualStudioSetup
{
class VisualStudioSetupErrorState : ISetupErrorState3
{
private ISetupErrorState3 _setupErrorState;
public VisualStudioSetupErrorState(ISetupErrorState3 setupErrorState)
{
_setupErrorState = setupErrorState;
}
public ISetupFailedPackageReference[] GetFailedPackages()
{
var packages = RunOnMainThread(_setupErrorState.GetFailedPackages);
for (int i = 0; i < packages.Length; i++)
{
packages[i] = new VisualStudioSetupFailedPackageReference((ISetupFailedPackageReference3)packages[i]);
}
return packages;
}
public ISetupPackageReference[] GetSkippedPackages()
{
var packages = RunOnMainThread(_setupErrorState.GetSkippedPackages);
for (int i = 0; i < packages.Length; i++)
{
packages[i] = new VisualStudioSetupPackageReference(packages[i]);
}
return packages;
}
public string GetErrorLogFilePath() => RunOnMainThread(_setupErrorState.GetErrorLogFilePath);
public string GetLogFilePath() => RunOnMainThread(_setupErrorState.GetLogFilePath);
public ISetupErrorInfo GetRuntimeError() => new VisualStudioSetupErrorInfo(RunOnMainThread(_setupErrorState.GetRuntimeError));
private static T RunOnMainThread<T>(Func<T> function) => Application.Current.Dispatcher.Invoke(function);
}
}