コード例 #1
0
        public async Task <bool> ExecuteAsync()
        {
            if (!File.Exists(ConfigFile))
            {
                Log.LogError($"Could not load the korebuild config file from '{ConfigFile}'");
                return(false);
            }

            var settings = KoreBuildSettings.Load(ConfigFile);

            if (settings?.Toolsets == null)
            {
                Log.LogMessage(MessageImportance.Normal, "No recognized toolsets specified.");
                return(true);
            }

            foreach (var toolset in settings.Toolsets)
            {
                switch (toolset)
                {
                case KoreBuildSettings.VisualStudioToolset vs:
                    await InstallVsComponents(vs);

                    break;

                // TODO support NodeJSToolset
                default:
                    Log.LogWarning("Toolset checks not implemented for " + toolset.GetType().Name);
                    break;
                }
            }

            return(!Log.HasLoggedErrors);
        }
コード例 #2
0
        public override bool Execute()
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Log.LogError("Visual Studio cannot be found on non-Windows platforms");
                return(false);
            }

            VsInstallation vs;

            if (!string.IsNullOrEmpty(ConfigFile))
            {
                if (!File.Exists(ConfigFile))
                {
                    Log.LogError($"Could not load the korebuild config file from '{ConfigFile}'");
                    return(false);
                }

                var settings  = KoreBuildSettings.Load(ConfigFile);
                var vsToolset = settings.Toolsets?.OfType <KoreBuildSettings.VisualStudioToolset>().FirstOrDefault();
                if (vsToolset != null)
                {
                    vs = VsWhere.FindLatestCompatibleInstallation(vsToolset, Log);
                    if (vs == null)
                    {
                        Log.LogError($"Could not find an installation of Visual Studio that satisifies the specified requirements in {ConfigFile}. " +
                                     "See https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community for more details on any missing components.");
                        return(false);
                    }
                }
                else
                {
                    vs = VsWhere.FindLatestInstallation(includePrerelease: true, log: Log);
                }
            }
            else
            {
                vs = VsWhere.FindLatestInstallation(includePrerelease: true, log: Log);
            }

            if (vs == null)
            {
                Log.LogError($"Could not find any installation of Visual Studio.");
                return(false);
            }

            Log.LogMessage(MessageImportance.Normal, "Found {0} in {1}", vs.DisplayName, vs.InstallationPath);

            InstallationBasePath = vs.InstallationPath;
            MSBuildx86Path       = vs.GetMSBuildx86SubPath();
            MSBuildx64Path       = vs.GetMSBuildx64SubPath();

            return(!Log.HasLoggedErrors);
        }
コード例 #3
0
        public void ItFailsIfVersionIsNotValid()
        {
            File.WriteAllText(_configFile, @"
{
  ""toolsets"": {
    ""nodejs"": {
      ""minVersion"": ""banana""
    }
  }
}");
            Assert.Throws <JsonSerializationException>(() => KoreBuildSettings.Load(_configFile));
        }
コード例 #4
0
        public void ItDeserializesNodeJSToolsetWithVersion()
        {
            File.WriteAllText(_configFile, @"
{
  ""toolsets"": {
    ""nodejs"": {
      ""minVersion"": ""8.0""
    }
  }
}");
            var settings = KoreBuildSettings.Load(_configFile);
            var toolset  = Assert.Single(settings.Toolsets);

            var node = Assert.IsType <KoreBuildSettings.NodeJSToolset>(toolset);

            Assert.Equal(new Version(8, 0), node.MinVersion);
        }
コード例 #5
0
        internal void ParsesPlatforms(string json, KoreBuildSettings.RequiredPlatforms platforms)
        {
            File.WriteAllText(_configFile, @"
{
  ""toolsets"": {
    ""visualstudio"": {
        ""required"": " + json + @"
    }
  }
}
");

            var settings = KoreBuildSettings.Load(_configFile);
            var toolset  = Assert.Single(settings.Toolsets);

            var vs = Assert.IsType <KoreBuildSettings.VisualStudioToolset>(toolset);

            Assert.Equal(platforms, vs.Required);
        }
コード例 #6
0
        public void ItDeserializesEmptyVisualStudioToolset()
        {
            File.WriteAllText(_configFile, @"
{
  ""toolsets"": {
    ""visualstudio"": {}
  }
}
");

            var settings = KoreBuildSettings.Load(_configFile);
            var toolset  = Assert.Single(settings.Toolsets);

            var vs = Assert.IsType <KoreBuildSettings.VisualStudioToolset>(toolset);

            Assert.NotNull(vs.RequiredWorkloads);
            Assert.Empty(vs.RequiredWorkloads);
            Assert.True(vs.IncludePrerelease);
            Assert.Null(vs.MinVersion);
        }
コード例 #7
0
        public void ItDeserializesVisualStudioToolset()
        {
            File.WriteAllText(_configFile, @"
{
  ""toolsets"": {
    ""visualstudio"": {
      ""requiredWorkloads"": [ ""MyTestWorkload"" ],
      ""minVersion"": ""15.4"",
      ""includePrerelease"": false
    }
  }
}");

            var settings = KoreBuildSettings.Load(_configFile);

            var toolset = Assert.Single(settings.Toolsets);

            var vs = Assert.IsType <KoreBuildSettings.VisualStudioToolset>(toolset);

            Assert.Collection(vs.RequiredWorkloads, w => Assert.Equal("MyTestWorkload", w));
            Assert.False(vs.IncludePrerelease);
            Assert.Equal("15.4", vs.MinVersion);
        }
コード例 #8
0
        public override bool Execute()
        {
            if (!File.Exists(ConfigFile))
            {
                Log.LogError($"Could not load the korebuild config file from '{ConfigFile}'");
                return(false);
            }

            var settings = KoreBuildSettings.Load(ConfigFile);

            if (settings?.Toolsets == null)
            {
                Log.LogMessage(MessageImportance.Normal, "No recognized toolsets specified.");
                return(true);
            }

            foreach (var toolset in settings.Toolsets)
            {
                switch (toolset)
                {
                case KoreBuildSettings.VisualStudioToolset vs:
                    GetVisualStudio(vs);
                    break;

                case KoreBuildSettings.NodeJSToolset node:
                    GetNode(node);
                    break;

                default:
                    Log.LogWarning("Toolset checks not implemented for " + toolset.GetType().Name);
                    break;
                }
            }

            return(!Log.HasLoggedErrors);
        }