Example #1
0
    static bool GeneratePackage(List <string> files)
    {
        if (runtime == null)
        {
            if (IsUnix)
            {
                runtime = Process.GetCurrentProcess().MainModule.FileName;
            }
            else
            {
                Console.Error.WriteLine("You must specify at least one runtime with --runtime or --cross");
                Environment.Exit(1);
            }
        }
        if (!File.Exists(runtime))
        {
            Console.Error.WriteLine($"The specified runtime at {runtime} does not exist");
            Environment.Exit(1);
        }

        if (ctor_func != null)
        {
            Console.Error.WriteLine("--static-ctor not supported with package bundling, you must use native compilation for this");
            return(false);
        }

        var maker = new PackageMaker(output);

        maker.AddFile(runtime);

        foreach (var url in files)
        {
            string fname = LocateFile(new Uri(url).LocalPath);
            string aname = Path.GetFileName(fname);

            maker.Add("assembly:" + aname, fname);
            if (File.Exists(fname + ".config"))
            {
                maker.Add("config:" + aname, fname + ".config");
            }
        }
        if (!MaybeAddFile(maker, "systemconfig:", config_file) || !MaybeAddFile(maker, "machineconfig:", machine_config_file))
        {
            return(false);
        }

        if (config_dir != null)
        {
            maker.Add("config_dir:", config_dir);
        }
        if (embedded_options != null)
        {
            maker.AddString("options:", embedded_options);
        }
        maker.Dump();
        maker.Close();
        return(true);
    }
Example #2
0
    static bool MaybeAddFile(PackageMaker maker, string code, string file)
    {
        if (file == null)
        {
            return(true);
        }

        if (!File.Exists(file))
        {
            Console.Error.WriteLine("The file {0} does not exist", file);
            return(false);
        }
        maker.Add(code, file);
        return(true);
    }
Example #3
0
	static bool GeneratePackage (List<string> files)
	{
		if (runtime == null){
			if (IsUnix)
				runtime = Process.GetCurrentProcess().MainModule.FileName;
			else {
				Error ("You must specify at least one runtime with --runtime or --cross");
				Environment.Exit (1);
			}
		}
		if (!File.Exists (runtime)){
			Error ($"The specified runtime at {runtime} does not exist");
			Environment.Exit (1);
		}
		
		if (ctor_func != null){
			Error ("--static-ctor not supported with package bundling, you must use native compilation for this");
			return false;
		}
		
		var maker = new PackageMaker (output);
		Console.WriteLine ("Using runtime: " + runtime);
		maker.AddFile (runtime);
		
		foreach (var url in files){
			string fname = LocateFile (new Uri (url).LocalPath);
			string aname = MakeBundle.GetAssemblyName (fname);

			maker.Add ("assembly:" + aname, fname);
			Console.WriteLine ("     Assembly: " + fname);
			if (File.Exists (fname + ".config")){
				maker.Add ("config:" + aname, fname + ".config");
				Console.WriteLine ("       Config: " + runtime);
			}
		}
		
		if (!MaybeAddFile (maker, "systemconfig:", config_file) || !MaybeAddFile (maker, "machineconfig:", machine_config_file))
			return false;

		if (config_dir != null)
			maker.Add ("config_dir:", config_dir);
		if (embedded_options != null)
			maker.AddString ("options:", embedded_options);
		if (environment.Count > 0){
			foreach (var key in environment.Keys)
				maker.AddStringPair ("env:" + key, key, environment [key]);
		}
		if (libraries.Count > 0){
			foreach (var alias_and_path in libraries){
				Console.WriteLine ("     Library:  " + alias_and_path.Value);
				maker.Add ("library:" + alias_and_path.Key, alias_and_path.Value);
			}
		}
		maker.Dump ();
		maker.Close ();
		return true;
	}
Example #4
0
	static bool MaybeAddFile (PackageMaker maker, string code, string file)
	{
		if (file == null)
			return true;
		
		if (!File.Exists (file)){
			Error ("The file {0} does not exist", file);
			return false;
		}
		maker.Add (code, file);
		return true;
	}