Exemplo n.º 1
0
        private ErrorCode BuildSolution()
        {
            Solution solution = GetGenerator().Solution;

            try
            {
                string[] properties =
                    File.ReadAllLines(Path.Combine(solution.OutputDir, solution.Name + ".sln.config"));
                Dictionary <string, string> propertiesLookup = properties
                                                               .Select(s => s.Split('='))
                                                               .ToDictionary(arr => arr[0], arr => arr[1]);

                Log.Debug("Loaded solution properties:");
                Log.IndentedCollection(propertiesLookup, kvp => $"{kvp.Key} = {kvp.Value}", Log.Debug);

                if (!propertiesLookup.TryGetValue("MasterConfiguration", out string cfg))
                {
                    Log.Warn("Failed to determine what mast configuration was used to generate the solution. " +
                             "Default master configuration will be used for build.");
                    cfg = MasterConfiguration;
                }

                var builder = new SolutionBuilder(solution, cfg);
                if (string.IsNullOrEmpty(BuildConfiguration))
                {
                    builder.BuildDefaultConfiguration();
                }
                else
                {
                    builder.BuildConfiguration(BuildConfiguration);
                }
            }
            catch (Exception ex)
            {
                // Error message should have been logged by builder already.
                // Just in case, log it at debug level.
                Log.Debug("Builder Exception: {0}", ex);
                return(ErrorCode.GeneratorException);
            }

            return(ErrorCode.Success);
        }