Compile() private method

Compiles C# script file.
private Compile ( string scriptFileName ) : string
scriptFileName string
return string
Beispiel #1
0
        /// <summary>
        /// Compiles script file into assembly with CSExecutor
        /// </summary>
        /// <param name="scriptFile">The name of script file to be compiled.</param>
        /// <param name="assemblyFile">The name of compiled assembly. If set to null a temnporary file name will be used.</param>
        /// <param name="debugBuild">'true' if debug information should be included in assembly; otherwise, 'false'.</param>
        /// <param name="cssConfigFile">The name of CS-Script configuration file. If null the default config file will be used (appDir/css_config.xml).</param>
        /// <param name="compilerOptions">The string value to be passed directly to the language compiler.</param>
        /// <returns>Compiled assembly file name.</returns>
        static public string CompileWithConfig(string scriptFile, string assemblyFile, bool debugBuild, string cssConfigFile, string compilerOptions)
        {
            Settings settings = Settings.Load(cssConfigFile != null ? cssConfigFile : Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "css_config.xml"));

            if (settings == null)
            {
                throw new ApplicationException("The configuration file \"" + cssConfigFile + "\" cannot be found");
            }

            CSExecutor exec = new csscript.CSExecutor();

            exec.Rethrow = true;

            CSExecutor.options.altCompiler                = settings.ExpandUseAlternativeCompiler();
            CSExecutor.options.compilerOptions            = compilerOptions != null ? compilerOptions : "";
            CSExecutor.options.apartmentState             = settings.DefaultApartmentState;
            CSExecutor.options.reportDetailedErrorInfo    = settings.ReportDetailedErrorInfo;
            CSExecutor.options.cleanupShellCommand        = settings.CleanupShellCommand;
            CSExecutor.options.doCleanupAfterNumberOfRuns = settings.DoCleanupAfterNumberOfRuns;

            CSExecutor.options.searchDirs = new string[]
            {
                Path.GetDirectoryName(scriptFile),
                settings == null ? "" : settings.ExpandExtraLibDirectory(),
                Environment.GetEnvironmentVariable("CSSCRIPT_DIR") == null ? "" : Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\lib"),
            };

            return(exec.Compile(scriptFile, assemblyFile, debugBuild));
        }
Beispiel #2
0
        /// <summary>
        /// Compiles script file into assembly with CSExecutor and loads it in current AppDomain
        /// </summary>
        /// <param name="scriptFile">The name of script file to be compiled.</param>
        /// <param name="assemblyFile">The name of compiled assembly. If set to null a temnporary file name will be used.</param>
        /// <param name="debugBuild">'true' if debug information should be included in assembly; otherwise, 'false'.</param>
        /// <returns>Compiled assembly.</returns>
        static public Assembly Load(string scriptFile, string assemblyFile, bool debugBuild)
        {
            csscript.CSExecutor exec = new csscript.CSExecutor();
            exec.Rethrow = true;
            string outputFile = exec.Compile(scriptFile, assemblyFile, debugBuild);

            AssemblyName asmName = AssemblyName.GetAssemblyName(outputFile);

            return(AppDomain.CurrentDomain.Load(asmName));
        }
Beispiel #3
0
 /// <summary>
 /// Compiles script file into assembly with CSExecutor
 /// </summary>
 /// <param name="scriptFile">The name of script file to be compiled.</param>
 /// <param name="assemblyFile">The name of compiled assembly. If set to null a temnporary file name will be used.</param>
 /// <param name="debugBuild">'true' if debug information should be included in assembly; otherwise, 'false'.</param>
 /// <returns>Compiled assembly file name.</returns>
 static public string Compile(string scriptFile, string assemblyFile, bool debugBuild)
 {
     csscript.CSExecutor exec = new csscript.CSExecutor();
     exec.Rethrow = true;
     return(exec.Compile(scriptFile, assemblyFile, debugBuild));
 }
Beispiel #4
0
		/// <summary>
		/// Compiles script file into assembly with CSExecutor and loads it in current AppDomain
		/// </summary>
		/// <param name="scriptFile">The name of script file to be compiled.</param>
		/// <param name="assemblyFile">The name of compiled assembly. If set to null a temnporary file name will be used.</param>
		/// <param name="debugBuild">'true' if debug information should be included in assembly; otherwise, 'false'.</param>
		/// <returns>Compiled assembly.</returns>
		static public Assembly Load(string scriptFile, string assemblyFile, bool debugBuild)
		{
			csscript.CSExecutor exec = new csscript.CSExecutor();
			exec.Rethrow = true;
			string outputFile = exec.Compile(scriptFile, assemblyFile, debugBuild);

			AssemblyName asmName = AssemblyName.GetAssemblyName(outputFile);
			return AppDomain.CurrentDomain.Load(asmName);
		}
Beispiel #5
0
		/// <summary>
		/// Compiles script file into assembly with CSExecutor
		/// </summary>
		/// <param name="scriptFile">The name of script file to be compiled.</param>
		/// <param name="assemblyFile">The name of compiled assembly. If set to null a temnporary file name will be used.</param>
		/// <param name="debugBuild">'true' if debug information should be included in assembly; otherwise, 'false'.</param>
		/// <param name="cssConfigFile">The name of CS-Script configuration file. If null the default config file will be used (appDir/css_config.xml).</param>
		/// <param name="compilerOptions">The string value to be passed directly to the language compiler.</param>
		/// <returns>Compiled assembly file name.</returns>
		static public string CompileWithConfig(string scriptFile, string assemblyFile, bool debugBuild, string cssConfigFile, string compilerOptions)
		{
			Settings settings = Settings.Load(cssConfigFile != null ? cssConfigFile : Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "css_config.xml"));
			
			if (settings == null)
				throw new ApplicationException("The configuration file \""+cssConfigFile+"\" cannot be found");
			
			CSExecutor exec = new csscript.CSExecutor();
			exec.Rethrow = true;

			CSExecutor.options.altCompiler = settings.ExpandUseAlternativeCompiler();
			CSExecutor.options.compilerOptions = compilerOptions != null ? compilerOptions : "";
			CSExecutor.options.apartmentState = settings.DefaultApartmentState;
			CSExecutor.options.reportDetailedErrorInfo = settings.ReportDetailedErrorInfo;
			CSExecutor.options.cleanupShellCommand = settings.CleanupShellCommand;
			CSExecutor.options.doCleanupAfterNumberOfRuns = settings.DoCleanupAfterNumberOfRuns;
			
			CSExecutor.options.searchDirs = new string[]	
												{	
													Path.GetDirectoryName(scriptFile),
													settings == null ? "" : settings.ExpandExtraLibDirectory(),
													Environment.GetEnvironmentVariable("CSSCRIPT_DIR") == null ? "" : Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\lib"),
												}; 

			return exec.Compile(scriptFile, assemblyFile, debugBuild);
		}
Beispiel #6
0
		/// <summary>
		/// Compiles script file into assembly with CSExecutor
		/// </summary>
		/// <param name="scriptFile">The name of script file to be compiled.</param>
		/// <param name="assemblyFile">The name of compiled assembly. If set to null a temnporary file name will be used.</param>
		/// <param name="debugBuild">'true' if debug information should be included in assembly; otherwise, 'false'.</param>
		/// <returns>Compiled assembly file name.</returns>
		static public string Compile(string scriptFile, string assemblyFile, bool debugBuild)
		{
			csscript.CSExecutor exec = new csscript.CSExecutor();
			exec.Rethrow = true;
			return exec.Compile(scriptFile, assemblyFile, debugBuild);
		}