コード例 #1
0
ファイル: MsPrjHelper.cs プロジェクト: raj581/Marvin
        protected Mfconsulting.General.Prj2Make.Schema.Prjx.Reference[] GetReferences(Mfconsulting.General.Prj2Make.Schema.Csproj.Reference[] References)
        {
            Mfconsulting.General.Prj2Make.Schema.Prjx.Reference[] theReferences = null;
            int i = 0;

            // Get the GAC path
            string strlibDir = PkgConfigInvoker.GetPkgVariableValue("mono", "libdir");

            if (strlibDir == null)
            {
                strlibDir = "/usr/lib";
            }

            string strBasePathMono1_0 = Path.Combine(
                strlibDir.TrimEnd(),
                "mono/1.0");

            string strBasePathMono2_0 = Path.Combine(
                strlibDir.TrimEnd(),
                "mono/2.0");

            string strBasePathGtkSharp = Path.Combine(
                strlibDir.TrimEnd(),
                "mono/gtk-sharp");

            if (References != null && References.Length > 0)
            {
                theReferences = new Mfconsulting.General.Prj2Make.Schema.Prjx.Reference[References.Length];
            }
            else
            {
                return(null);
            }

            // Iterate through the reference collection of the csproj file
            foreach (Mfconsulting.General.Prj2Make.Schema.Csproj.Reference rf in References)
            {
                Mfconsulting.General.Prj2Make.Schema.Prjx.Reference rfOut = new Mfconsulting.General.Prj2Make.Schema.Prjx.Reference();
                string strRefFileName;

                if (rf.Package == null || rf.Package.CompareTo("") == 0)
                {
                    bool bIsWhereExpected = false;

                    // HACK - under Unix filenames are case sensitive
                    // Under Windows there's no agreement on Xml vs XML ;-)
                    if (Path.GetFileName(rf.HintPath).CompareTo("System.XML.dll") == 0)
                    {
                        strRefFileName = Path.Combine(strBasePathMono1_0, Path.GetFileName("System.Xml.dll"));

                        // Test to see if file exist in GAC location
                        if (System.IO.File.Exists(strRefFileName) == true)
                        {
                            try {
                                rfOut.refto      = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type       = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy  = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                                  strRefFileName,
                                                  exc.Message);
                            }
                        }

                        strRefFileName = Path.Combine(strBasePathMono2_0, Path.GetFileName("System.Xml.dll"));

                        // Test to see if file exist in GAC location
                        if (System.IO.File.Exists(strRefFileName) == true)
                        {
                            try {
                                rfOut.refto      = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type       = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy  = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                                  strRefFileName,
                                                  exc.Message);
                            }
                        }
                    }
                    else
                    {
                        strRefFileName = Path.Combine(strBasePathMono1_0, Path.GetFileName(rf.HintPath));

                        // Test to see if file exist in GAC location
                        if (System.IO.File.Exists(strRefFileName) == true)
                        {
                            try {
                                rfOut.refto      = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type       = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy  = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                                  strRefFileName,
                                                  exc.Message);
                            }
                        }

                        strRefFileName = Path.Combine(strBasePathMono2_0, Path.GetFileName(rf.HintPath));

                        // Test to see if file exist in GAC location
                        if (System.IO.File.Exists(strRefFileName) == true)
                        {
                            try {
                                rfOut.refto      = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type       = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy  = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                                  strRefFileName,
                                                  exc.Message);
                            }
                        }

                        strRefFileName = Path.Combine(strBasePathGtkSharp, Path.GetFileName(rf.HintPath));

                        // Test to see if file exist in GAC location
                        if (System.IO.File.Exists(strRefFileName) == true)
                        {
                            try {
                                rfOut.refto      = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type       = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy  = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                                  strRefFileName,
                                                  exc.Message);
                            }
                        }

                        if (bIsWhereExpected == false)
                        {
                            rfOut.refto     = Path.GetFileName(rf.HintPath);
                            rfOut.type      = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                            rfOut.localcopy = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                        }
                    }

                    // increment the iterator value
                    theReferences[i++] = rfOut;
                }
                else
                {
                    rfOut.type = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Project;

                    rfOut.refto     = Path.GetFileName(rf.Name);
                    rfOut.localcopy = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                    // increment the iterator value
                    theReferences[i++] = rfOut;
                }
            }

            return(theReferences);
        }
コード例 #2
0
ファイル: MsPrjHelper.cs プロジェクト: tgiphil/wintools
        protected Mfconsulting.General.Prj2Make.Schema.Prjx.Reference[] GetReferences(Mfconsulting.General.Prj2Make.Schema.Csproj.Reference[] References)
        {
            Mfconsulting.General.Prj2Make.Schema.Prjx.Reference[] theReferences = null;
            int i = 0;

            // Get the GAC path
            string strBasePathMono1_0 = Path.Combine(
                    Mfconsulting.General.PkgConfigInvoker.GetPkgVariableValue("mono", "libdir").TrimEnd(),
                    "mono/1.0");

            string strBasePathGtkSharp = Path.Combine(
                    Mfconsulting.General.PkgConfigInvoker.GetPkgVariableValue("mono", "libdir").TrimEnd(),
                    "mono/gtk-sharp");

            // Little Diagnostics -- remove later
            Console.WriteLine ("Base path: {0}", strBasePathMono1_0);
            Console.WriteLine ("Base path: {0}", strBasePathGtkSharp);

            if(References != null && References.Length > 0)
            {
                theReferences = new Mfconsulting.General.Prj2Make.Schema.Prjx.Reference[References.Length];
            }
            else
            {
                return null;
            }

            // Iterate through the reference collection of the csproj file
            foreach(Mfconsulting.General.Prj2Make.Schema.Csproj.Reference rf in References)
            {
                Mfconsulting.General.Prj2Make.Schema.Prjx.Reference rfOut = new Mfconsulting.General.Prj2Make.Schema.Prjx.Reference();
                string strRefFileName;

                if(rf.Package == null || rf.Package.CompareTo("") == 0)
                {
                    bool bIsWhereExpected = false;

                    // HACK - under Unix filenames are case sensitive
                    // Under Windows there's no agreement on Xml vs XML ;-)
                    if(Path.GetFileName(rf.HintPath).CompareTo("System.XML.dll") == 0)
                    {
                        strRefFileName = Path.Combine (strBasePathMono1_0, Path.GetFileName("System.Xml.dll"));

                        // Test to see if file exist in GAC location
                        if(System.IO.File.Exists(strRefFileName) == true) {
                            try {
                                rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                    strRefFileName,
                                    exc.Message );
                            }
                        }
                    } else {
                        strRefFileName = Path.Combine (strBasePathMono1_0, Path.GetFileName(rf.HintPath));

                        // Little Diagnostics -- remove later
                        Console.WriteLine ("Reference that will be tested for existance: {0}", strRefFileName);						// Test to see if file exist in GAC location

                        // Test to see if file exist in GAC location
                        if(System.IO.File.Exists(strRefFileName) == true) {
                            try {
                                rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                    strRefFileName,
                                    exc.Message );
                            }
                        }

                        strRefFileName = Path.Combine (strBasePathGtkSharp, Path.GetFileName(rf.HintPath));

                        // Little Diagnostics -- remove later
                        Console.WriteLine ("Reference that will be tested for existance: {0}", strRefFileName);						// Test to see if file exist in GAC location

                        // Test to see if file exist in GAC location
                        if(System.IO.File.Exists(strRefFileName) == true) {
                            try {
                                rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
                                rfOut.type = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                                rfOut.localcopy = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                                bIsWhereExpected = true;
                            } catch (Exception exc) {
                                Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
                                    strRefFileName,
                                    exc.Message );
                            }
                        }

                        if(bIsWhereExpected == false)
                        {
                            rfOut.refto = Path.GetFileName(rf.HintPath);
                            rfOut.type = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Gac;
                            rfOut.localcopy = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                        }
                    }

                    // increment the iterator value
                    theReferences[i++] = rfOut;
                }
                else
                {
                    rfOut.type = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceType.Project;

                    rfOut.refto = Path.GetFileName(rf.Name);
                    rfOut.localcopy = Mfconsulting.General.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
                    // increment the iterator value
                    theReferences[i++] = rfOut;
                }
            }

            return theReferences;
        }