コード例 #1
0
        private string GerarDll(Script script)
        {
            string filePath   = EscreverClasse(script);
            string dll        = _PastaVersaoCompilada + script.NomeClasse + ".dll";
            string argumentos = @"/target:library /out:""{0}"" ""{1}"" /reference:""{2}"" /reference:""{3}\Microsoft.Xna.Framework.dll"" /reference:""{3}\Microsoft.Xna.Framework.Game.dll""";

            argumentos = string.Format(argumentos, dll, filePath, _PastaVersaoCompilada + Jogo.RetornarArquivoPadrao(ArquivoPadrao.DLLObjetos), Configuracao.RetornarPastaXNA());
            Process p = new Process();

            p.StartInfo.FileName               = Jogo.RetornarCaminhoCompilador();
            p.StartInfo.Arguments              = argumentos;
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();
            string erro = p.StandardOutput.ReadToEnd();

            p.WaitForExit();
            if (p.ExitCode != 0)
            {
                int i = erro.IndexOf("error ");
                throw new Exception(erro.Substring(i));
            }
            return(script.NomeClasse + ".dll");
        }