Ejemplo n.º 1
0
        // runCode : true when executing code from runsource, true for CompilerDefaultValues and ProjectDefaultValues, otherwise false
        // includeProject : true reading and include project, false reading the main project
        // set parameters for :
        //   main project : Win32Resource
        //   main project but not run code : Target, Platform, Output, Icon, KeyFile, CopySourceFiles, CopyRunSourceSourceFiles, CopyOutputDirectories
        //   not run code : GenerateInMemory
        //   always : DebugInformation, WarningLevel, CompilerOptions, PreprocessorSymbols, Sources, Files, SourceFiles, Assemblies
        //   always but only once : Language, FrameworkVersion
        public void SetParameters(CompilerProjectReader project, bool runCode = false, bool includeProject = false)
        {
            if (project == null)
                return;

            //if (!includeProject)
            //{
                SetLanguage(project.GetLanguage(), project);
                SetFrameworkVersion(project.GetFrameworkVersion(), project);
            //}

            if (!runCode && !includeProject)
            {
                //s = project.GetTarget();
                //if (s != null)
                //    AddCompilerOption("/target:" + s);
                SetTarget(project.GetTarget(), project);
                SetPlatform(project.GetPlatform(), project);
            }

            bool? b;

            if (!runCode)
            {
                b = project.GetGenerateInMemory();
                if (b != null)
                    _generateInMemory = (bool)b;
            }

            b = project.GetDebugInformation();
            if (b != null)
                _debugInformation = (bool)b;

            int? i = project.GetWarningLevel();
            if (i != null)
                _warningLevel = (int)i;

            AddCompilerOptions(project.GetCompilerOptions());
            AddPreprocessorSymbols(project.GetPreprocessorSymbols());

            string s;

            if (!runCode && !includeProject)
            {
                s = project.GetOutput();
                if (s != null)
                    SetOutputAssembly(s, project);
            }

            if (!includeProject)
            {
                SetWin32Resource(project.GetWin32Resource());
            }

            //if (!includeProject)
            if (!includeProject && !includeProject)
            {
                s = project.GetIcon();
                if (s != null)
                    AddCompilerOption("/win32icon:\"" + s + "\"");
            }

            //if (!includeProject)
            if (!includeProject && !includeProject)
            {
                s = project.GetKeyFile();
                if (s != null)
                    AddCompilerOption("/keyfile:\"" + s + "\"");
            }

            if (!includeProject)
            {
                // GetIncludeProjects() get include project recursively
                foreach (CompilerProjectReader project2 in project.GetIncludeProjects())
                {
                    SetParameters(project2, runCode: runCode, includeProject: true);
                }
            }

            AddSources(project.GetSources());

            AddFiles(project.GetFiles());

            AddSourceFiles(project.GetSourceFiles());

            AddAssemblies(project.GetAssemblies());

            if (!runCode && !includeProject)
            {
                b = project.GetCopySourceFiles();
                if (b != null)
                    _copySourceFiles = (bool)b;

                b = project.GetCopyRunSourceSourceFiles();
                if (b != null)
                    _copyRunSourceSourceFiles = (bool)b;
            }

            if (!runCode && !includeProject)
            {
                AddCopyOutputDirectories(project.GetCopyOutputs());
            }
        }