Example #1
0
        /// <summary>
        /// Gets the VisualStudioProjectTypeEnum of the given GUID (Global Unique Identifier)
        /// </summary>
        /// <param name="guid">VisualStudio Project Type GUID</param>
        /// <returns>VisualStudioProjectTypeEnum equivalent of the GUID</returns>
        public static VisualStudioProjectTypeEnum GetVisualStudioProjectType(string guid)
        {
            string strGuid = guid.Replace("{", "");

            strGuid = strGuid.Replace("}", "");


            VisualStudioProjectTypeEnum projectType = 0;

            foreach (string guidItem in strGuid.Split(';'))
            {
                try
                {
                    string upperGuid = guidItem.ToUpper();
                    projectType |= __visualStudioProjectTypes[upperGuid];
                    if (!__visualStudioProjectTypeSupported[upperGuid])
                    {
                        throw new NotSupportedException("NPanday does not support projects with type GUID: " + guidItem);
                    }
                }
                catch
                {
                    throw new NotSupportedException("Unknown project type GUID: " + guidItem);
                }
            }

            return(projectType);
        }
Example #2
0
        public static string GetVisualStudioProjectTypeGuid(VisualStudioProjectTypeEnum visualStudioProjectTypeEnum)
        {
            List <string> list = new List <string>();

            foreach (VisualStudioProjectTypeEnum value in Enum.GetValues(typeof(VisualStudioProjectTypeEnum)))
            {
                if ((visualStudioProjectTypeEnum & value) == value)
                {
                    list.Add("{" + __visualStudioProjectTypeGuids[value] + "}");
                }
            }

            return(string.Join(";", list.ToArray()));
        }
        public static string GetVisualStudioProjectTypeGuid(VisualStudioProjectTypeEnum visualStudioProjectTypeEnum)
        {
            List<string> list = new List<string>();
            foreach (VisualStudioProjectTypeEnum value in Enum.GetValues(typeof(VisualStudioProjectTypeEnum)))
            {
                if ((visualStudioProjectTypeEnum & value) == value)
                {
                    list.Add("{" + __visualStudioProjectTypeGuids[value] + "}");
                }
            }

            return string.Join(";", list.ToArray());
        }
        private static void DigestBuildProperties(Project project, ProjectDigest projectDigest)
        {
            foreach (BuildPropertyGroup buildPropertyGroup in project.PropertyGroups)
            {
                foreach (BuildProperty buildProperty in buildPropertyGroup)
                {
                    if (!buildProperty.IsImported)
                    {
                        if ("RootNameSpace".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.RootNamespace = buildProperty.Value;
                        }
                        else if ("AssemblyName".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.AssemblyName = buildProperty.Value;
                        }
                        else if ("Name".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.Name = buildProperty.Value;
                        }
                        else if ("StartupObject".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.StartupObject = buildProperty.Value;
                        }
                        else if ("OutputType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.OutputType = buildProperty.Value;
                        }
                        else if ("RoleType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.RoleType = buildProperty.Value;
                        }
                        else if ("SignAssembly".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.SignAssembly = buildProperty.Value;
                        }
                        else if ("AssemblyOriginatorKeyFile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.AssemblyOriginatorKeyFile = buildProperty.Value;
                        }
                        else if ("DelaySign".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.DelaySign = buildProperty.Value;
                        }
                        else if ("Optimize".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.Optimize = buildProperty.Value;
                        }
                        else if ("AllowUnsafeBlocks".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.AllowUnsafeBlocks = buildProperty.Value;
                        }
                        else if ("DefineConstants".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.DefineConstants = buildProperty.Value;
                        }
                        else if ("ApplicationIcon".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.ApplicationIcon = buildProperty.Value;
                        }
                        else if ("Win32Resource".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.Win32Resource = buildProperty.Value;
                        }
                        else if ("ProjectGuid".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.ProjectGuid = buildProperty.Value;
                        }
                        else if ("Configuration".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.Configuration = buildProperty.Value;
                        }
                        else if ("BaseIntermediateOutputPath".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.BaseIntermediateOutputPath = buildProperty.Value;
                        }
                        else if ("OutputPath".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.OutputPath = buildProperty.Value;
                        }
                        else if ("TreatWarningsAsErrors".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.TreatWarningsAsErrors = buildProperty.Value;
                        }
                        else if ("Platform".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.Platform = buildProperty.Value;
                        }
                        else if ("ProductVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.ProductVersion = buildProperty.Value;
                        }
                        else if ("SchemaVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.SchemaVersion = buildProperty.Value;
                        }
                        else if ("TargetFrameworkVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            // changed the version to the more specific version
                            string frameworkVersion = buildProperty.Value.Substring(1);

                            if ("2.0".Equals(buildProperty.Value.Substring(1)))
                            {
                                frameworkVersion = "2.0.50727";
                            }

                            projectDigest.TargetFramework = frameworkVersion;
                        }
                        else if ("AppDesignerFolder".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.AppDesignerFolder = buildProperty.Value;
                        }
                        else if ("DebugSymbols".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.DebugSymbols = buildProperty.Value;
                        }
                        else if ("DebugType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.DebugType = buildProperty.Value;
                        }
                        else if ("ErrorReport".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.ErrorReport = buildProperty.Value;
                        }
                        else if ("WarningLevel".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.WarningLevel = buildProperty.Value;
                        }
                        else if ("DocumentationFile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.DocumentationFile = buildProperty.Value;
                        }
                        else if ("PostBuildEvent".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.PostBuildEvent = buildProperty.Value;
                        }
                        else if ("PublishUrl".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.PublishUrl = buildProperty.Value;
                        }
                        else if ("Install".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.Install = buildProperty.Value;
                        }
                        else if ("InstallFrom".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.InstallFrom = buildProperty.Value;
                        }
                        else if ("UpdateEnabled".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.UpdateEnabled = buildProperty.Value;
                        }
                        else if ("UpdateMode".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.UpdateMode = buildProperty.Value;
                        }
                        else if ("UpdateInterval".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.UpdateInterval = buildProperty.Value;
                        }
                        else if ("UpdateIntervalUnits".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.UpdateIntervalUnits = buildProperty.Value;
                        }
                        else if ("UpdatePeriodically".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.UpdatePeriodically = buildProperty.Value;
                        }
                        else if ("UpdateRequired".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.UpdateRequired = buildProperty.Value;
                        }
                        else if ("MapFileExtensions".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.MapFileExtensions = buildProperty.Value;
                        }
                        else if ("ApplicationVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.ApplicationVersion = buildProperty.Value;
                        }
                        else if ("IsWebBootstrapper".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.IsWebBootstrapper = buildProperty.Value;
                        }
                        else if ("BootstrapperEnabled".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.BootstrapperEnabled = buildProperty.Value;
                        }
                        else if ("PreBuildEvent".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.PreBuildEvent = buildProperty.Value;
                        }
                        else if ("MyType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.MyType = buildProperty.Value;
                        }
                        else if ("DefineDebug".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.DefineDebug = buildProperty.Value;
                        }
                        else if ("DefineTrace".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.DefineTrace = buildProperty.Value;
                        }
                        else if ("NoWarn".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.NoWarn = buildProperty.Value;
                        }
                        else if ("WarningsAsErrors".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            projectDigest.WarningsAsErrors = buildProperty.Value;
                        }
                        else if ("ProjectTypeGuids".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            if (!string.IsNullOrEmpty(buildProperty.Value))
                            {
                                try
                                {
                                    VisualStudioProjectTypeEnum t = VisualStudioProjectType.GetVisualStudioProjectType(buildProperty.Value);
                                    projectDigest.ProjectType = t;
                                }
                                catch
                                {
                                    throw;
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Unhandled Property:" + buildProperty.Name);
                        }
                    }
                }
            }
        }