Ejemplo n.º 1
0
        public void CreatePrjxFromCsproj(string csprojFileName)
        {
            int           nCnt     = 0;
            FileStream    fsIn     = null;
            XmlSerializer xmlDeSer = null;
            FileStream    fsOut    = null;
            XmlSerializer xmlSer   = null;

            Mfconsulting.General.Prj2Make.Schema.Csproj.VisualStudioProject csprojObj = null;
            Mfconsulting.General.Prj2Make.Schema.Prjx.Project prjxObj = new Mfconsulting.General.Prj2Make.Schema.Prjx.Project();
            string PrjxFileName = String.Format("{0}.prjx",
                                                Path.Combine(Path.GetDirectoryName(csprojFileName),
                                                             Path.GetFileNameWithoutExtension(csprojFileName))
                                                );

            // convert backslashes to slashes
            csprojFileName = csprojFileName.Replace("\\", "/");
            Console.WriteLine(String.Format("Will create project filename:{0}", PrjxFileName));

            // Load the csproj
            fsIn      = new FileStream(csprojFileName, FileMode.Open);
            xmlDeSer  = new XmlSerializer(typeof(VisualStudioProject));
            csprojObj = (VisualStudioProject)xmlDeSer.Deserialize(fsIn);
            fsIn.Close();

            // Begin prjxObj population
            prjxObj.name            = Path.GetFileNameWithoutExtension(csprojFileName);
            prjxObj.description     = "";
            prjxObj.newfilesearch   = "None";
            prjxObj.enableviewstate = "True";
            prjxObj.version         = (decimal)1.1;
            prjxObj.projecttype     = "C#";

            prjxObj.Contents                       = GetContents(csprojObj.CSHARP.Files.Include);
            prjxObj.References                     = GetReferences(csprojObj.CSHARP.Build.References);
            prjxObj.DeploymentInformation          = new Mfconsulting.General.Prj2Make.Schema.Prjx.DeploymentInformation();
            prjxObj.DeploymentInformation.target   = "";
            prjxObj.DeploymentInformation.script   = "";
            prjxObj.DeploymentInformation.strategy = "File";

            nCnt = csprojObj.CSHARP.Build.Settings.Config.Length;
            prjxObj.Configurations = new Configurations();
            prjxObj.Configurations.Configuration = new Configuration[nCnt];
            for (int i = 0; i < nCnt; i++)
            {
                prjxObj.Configurations.Configuration[i] = CreateConfigurationBlock(
                    csprojObj.CSHARP.Build.Settings.Config[i],
                    csprojObj.CSHARP.Build.Settings.AssemblyName,
                    csprojObj.CSHARP.Build.Settings.OutputType
                    );
            }
            prjxObj.Configurations.active = prjxObj.Configurations.Configuration[0].name;

            prjxObj.Configuration = prjxObj.Configurations.Configuration[0];

            // Serialize
            fsOut  = new FileStream(PrjxFileName, FileMode.Create);
            xmlSer = new XmlSerializer(typeof(Project));
            xmlSer.Serialize(fsOut, prjxObj);
            fsOut.Close();

            return;
        }
Ejemplo n.º 2
0
        public void CreatePrjxFromCsproj(string csprojFileName)
        {
            int nCnt = 0;
            FileStream fsIn = null;
            XmlSerializer xmlDeSer = null;
            FileStream fsOut = null;
            XmlSerializer xmlSer = null;
            Mfconsulting.General.Prj2Make.Schema.Csproj.VisualStudioProject csprojObj = null;
            Mfconsulting.General.Prj2Make.Schema.Prjx.Project prjxObj = new Mfconsulting.General.Prj2Make.Schema.Prjx.Project();
            string PrjxFileName = String.Format ("{0}.prjx",
                Path.Combine(Path.GetDirectoryName(csprojFileName),
                Path.GetFileNameWithoutExtension(csprojFileName))
                );

            // convert backslashes to slashes
            csprojFileName = csprojFileName.Replace("\\", "/");
            Console.WriteLine(String.Format("Will create project filename:{0}", PrjxFileName));

            // Load the csproj
            fsIn = new FileStream (csprojFileName, FileMode.Open);
            xmlDeSer = new XmlSerializer (typeof(VisualStudioProject));
            csprojObj = (VisualStudioProject) xmlDeSer.Deserialize (fsIn);
            fsIn.Close();

            // Begin prjxObj population
            prjxObj.name = Path.GetFileNameWithoutExtension(csprojFileName);
            prjxObj.description = "";
            prjxObj.newfilesearch = "None";
            prjxObj.enableviewstate = "True";
            prjxObj.version = (decimal)1.1;
            prjxObj.projecttype = "C#";

            prjxObj.Contents = GetContents (csprojObj.CSHARP.Files.Include);
            prjxObj.References = GetReferences(csprojObj.CSHARP.Build.References);
            prjxObj.DeploymentInformation = new Mfconsulting.General.Prj2Make.Schema.Prjx.DeploymentInformation();
            prjxObj.DeploymentInformation.target = "";
            prjxObj.DeploymentInformation.script = "";
            prjxObj.DeploymentInformation.strategy = "File";

            nCnt = csprojObj.CSHARP.Build.Settings.Config.Length;
            prjxObj.Configurations = new Configurations();
            prjxObj.Configurations.Configuration = new Configuration[nCnt];
            for(int i = 0; i < nCnt; i++)
            {
                prjxObj.Configurations.Configuration[i] = CreateConfigurationBlock(
                    csprojObj.CSHARP.Build.Settings.Config[i],
                    csprojObj.CSHARP.Build.Settings.AssemblyName,
                    csprojObj.CSHARP.Build.Settings.OutputType
                    );
            }
            prjxObj.Configurations.active = prjxObj.Configurations.Configuration[0].name;

            prjxObj.Configuration = prjxObj.Configurations.Configuration[0];

            // Serialize
            fsOut = new FileStream (PrjxFileName, FileMode.Create);
            xmlSer = new XmlSerializer (typeof(Project));
            xmlSer.Serialize(fsOut, prjxObj);
            fsOut.Close();

            return;
        }