Esempio n. 1
0
        private void Build(StartupArgumentInfo argumentInfo, string[] args)
        {
            if (!Program.HasTarget)
            {
                Logger.Log(LogType.Log, "You need to specify a target config");
                return;
            }

            AssemblyDefinition def = AssemblyDefinition.Load(Program.Target);

            AssemblyGeneratorBuildType buildType = AssemblyGeneratorBuildType.Publish;

            if (args.Length == 1 && !Enum.TryParse(args[0], out buildType))
            {
                Logger.Log(LogType.Log, "Can not parse the BuildType. Using Default:" + buildType);
            }

            string path = Path.Combine(Path.GetDirectoryName(Program.Target), $"{def.AssemblyName}_build");

            Logger.Log(LogType.Log, "AAAAAAAAAAAAAA:" + path);
            AssemblyGenerator.GenerateAssembly("dotnet", def, path, buildType, !Program.BuildConsole);
        }
Esempio n. 2
0
        private void Build(string[] args)
        {
            if (!AssemblyGeneratorConsole.HasTarget)
            {
                Logger.Log(LogType.Log, "You need to specify a target config", 1);
                return;
            }

            AssemblyDefinition def = AssemblyDefinition.Load(AssemblyGeneratorConsole.Target);

            AssemblyGeneratorBuildType buildType = AssemblyGeneratorBuildType.Publish;

            if (args.Length == 1 && !Enum.TryParse(args[0], out buildType))
            {
                Logger.Log(LogType.Log, "Can not parse the BuildType. Using Default:" + buildType, 1);
            }

            string path = Path.Combine(Path.GetDirectoryName(AssemblyGeneratorConsole.Target),
                                       $"{AssemblyGeneratorConsole.Output ?? def.AssemblyName}");

            Byt3.AssemblyGenerator.AssemblyGenerator.GenerateAssembly("dotnet", def, path, buildType,
                                                                      !AssemblyGeneratorConsole.BuildConsole);
        }
Esempio n. 3
0
        public static void GenerateAssembly(string msBuildPath, AssemblyDefinition assemblyDefinitions,
                                            string outputFolder, AssemblyGeneratorBuildType buildType, bool lib)
        {
            if (msBuildPath == null)
            {
                throw new ArgumentNullException(nameof(msBuildPath));
            }

            if (assemblyDefinitions == null)
            {
                throw new ArgumentNullException(nameof(assemblyDefinitions));
            }

            if (outputFolder == null)
            {
                throw new ArgumentNullException(nameof(outputFolder));
            }


            Logger.Log(LogType.Log, "Generating Assembly...", 1);
            string tempFolder = GetTempFolder();

            Tuple <string, List <ModuleDefinition> > project =
                GenerateProject(msBuildPath, tempFolder, assemblyDefinitions, lib);


            string projectDir = Path.GetDirectoryName(project.Item1);


            Logger.Log(LogType.Log, $"Copying Files of {project.Item2.Count} Modules", 1);
            for (int i = 0; i < project.Item2.Count; i++)
            {
                string defDir = CreateDirectoryInFolderOrThrow(projectDir, project.Item2[i].Name);
                MoveFiles(defDir, project.Item2[i]);
            }

            string outDir = "";

            if (buildType == AssemblyGeneratorBuildType.Build)
            {
                outDir = DotNetHelper.BuildProject(msBuildPath, project.Item1, assemblyDefinitions, lib);
            }
            else
            {
                outDir = DotNetHelper.PublishProject(msBuildPath, project.Item1, assemblyDefinitions, lib);
            }

            Logger.Log(LogType.Log, "Moving Files to output Directory...", 1);
            if (Directory.Exists(outputFolder))
            {
                Directory.Delete(outputFolder, true);
            }

            Logger.Log(LogType.Log, "Cleaning Output Folder", 1);
            while (Directory.Exists(outputFolder))
            {
            }

            Directory.Move(outDir, outputFolder);


            Logger.Log(LogType.Log, "Cleaning Temp Directory", 1);
            Directory.Delete(tempFolder, true);
            Logger.Log(LogType.Log, "Cleanup Finished.", 1);
        }