DXperience demo编译工具

来源:互联网 发布:农场复利系统源码 编辑:程序博客网 时间:2024/04/29 00:22

编译了源码后可以使用,但是demo看不起来。为了解决大家后顾之忧,我写了生成编译编译demo命令的程序,放在demo目录后可以自动生成编译的命令,手工调整参数后直接运行能编译所有demo(不出意外的情况,哈哈)。

程序可以在我的网络硬盘上下载,

说明,只支持编译C#工程,可以自己改。

附源码,请引用system.windows.form.dll:

void main()
{
CreateCSCmd();
}

StringCollection FileSearch(string sDir, string sFile)
        {
            try
            {
                foreach (string d in Directory.GetDirectories(sDir))
                {
                    foreach (string f in Directory.GetFiles(d, sFile))
                    {
                        lstFilesFound.Add(f);
                    }
                    FileSearch(d, sFile);
                }
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }

            return lstFilesFound;
        }

        void WriteS(System.IO.FileStream f, string str)
        {
            byte[] ar = System.Text.Encoding.ASCII.GetBytes(str);
            f.Write(ar, 0, ar.Length);
        }

        private void CreateCSCmd()
        {
            lstFilesFound.Clear();
            string dir = AppDomain.CurrentDomain.BaseDirectory;
            StringCollection p = FileSearch(dir, "*.csproj");

            System.IO.FileStream bproj = new FileStream("buildproject.cmd", FileMode.OpenOrCreate);
            WriteS(bproj, "if not exist %1 goto end");
            WriteS(bproj, "/r/necho Building %1...");
            WriteS(bproj, "/r/n%msbuild% /nologo /t:Rebuild /verbosity:quiet /p:Configuration=%configuration% %1");
            WriteS(bproj, "/r/necho Done %1");
            WriteS(bproj, "/r/n:end");
            bproj.Close();


            System.IO.FileStream pp = new FileStream("buildall.cmd", FileMode.OpenOrCreate);
            WriteS(pp, "@echo off");
            WriteS(pp, "/r/nSET sn=/"d://Program Files//Microsoft Visual Studio 8//SDK//v2.0//Bin//sn.exe/"");
            WriteS(pp, "/r/nset gacutil=/"d://Program Files//Microsoft Visual Studio 8//SDK//v2.0//Bin//gacutil.exe/"");
            WriteS(pp, "/r/nset msbuild=c://windows//Microsoft.NET//Framework//v2.0.50727//MSBuild.exe");
            WriteS(pp, "/r/nset dxver=v7.1");
            WriteS(pp, "/r/nset configuration=Release");

            for (int i = 0; i < p.Count; i++)
            {
                string cmd = "/r/ncall buildproject.cmd " + "/".//" + p[i].Substring(dir.Length) + "/"";
                WriteS(pp, cmd);

                //try{
                System.IO.FileInfo finfo = new FileInfo(p[i]);
                if(finfo.Exists)
                {
                    string demoname = finfo.Name.Replace(".csproj", ".exe");
                    string sfile = "/r/ncopy /"" + finfo.DirectoryName + @"/obj/%configuration%/" +demoname + "/"";
                    string tfile = "/"" + finfo.DirectoryName + @"/../../bin/"+demoname + "/"";
                    WriteS(pp, sfile+" " +tfile);
                }
                   
            }
            pp.Close();

            MessageBox.Show("生成Demo编译命令完成。");
        }
    } 

原创粉丝点击