internal static void Clean(Settings settings, Log log)
        {
            var previous = log.IsEnabled;

            log.IsEnabled = false;
            var properties = ProjectPropertiesHelpers.InitializeProperties(settings, log);

            log.IsEnabled = previous;
            try
            {
                if (Directory.Exists(properties.ToolsDirectory))
                {
                    Directory.Delete(properties.ToolsDirectory, true);
                }
                if (Directory.Exists(properties.OutputDirectory))
                {
                    Directory.Delete(properties.OutputDirectory, true);
                }
                if (Directory.Exists(properties.PackagesDirectory))
                {
                    Directory.Delete(properties.PackagesDirectory, true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception during cleanup: {0}", e.Message);
            }
        }
Exemple #2
0
        private static void Build(Settings settings, Log log)
        {
            var properties = ProjectPropertiesHelpers.InitializeProperties(settings, log);

            if (properties.Sources.Count == 0)
            {
                Console.WriteLine("no sources found");
                return;
            }

            if (!Directory.Exists(properties.OutputDirectory))
            {
                Directory.CreateDirectory(properties.OutputDirectory);
            }

            if (!Directory.Exists(properties.ToolsDirectory))
            {
                Directory.CreateDirectory(properties.ToolsDirectory);
            }

            if (!Directory.Exists(properties.PackagesDirectory))
            {
                Directory.CreateDirectory(properties.PackagesDirectory);
            }

            if (!NugetAction.GetNugetAndRestore(properties, log))
            {
                return;
            }

            if (!GetDependencies(properties, log))
            {
                log.WriteLine("Unable to get dependencies from the project.lock.json file.");
            }

            if (!CscAction.Execute(properties, Log))
            {
                return;
            }
            if (Settings.Target != "library")
            {
                ConvertToCoreConsoleAction(properties);
            }
            OutputRuntimeDependenciesAction(properties, log);
            Console.WriteLine("bin\\{0} created", properties.AssemblyNameAndExtension);
        }