public static IMSBuildNuGetProjectSystem CreateMSBuildNuGetProjectSystem(EnvDTEProject envDTEProject, INuGetProjectContext nuGetProjectContext) { if (envDTEProject == null) { throw new ArgumentNullException("project"); } if (String.IsNullOrEmpty(envDTEProject.FullName)) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, Strings.DTE_ProjectUnsupported, EnvDTEProjectUtility.GetName(envDTEProject))); } #if VS14 if (EnvDTEProjectUtility.SupportsINuGetProjectSystem(envDTEProject)) { throw new InvalidOperationException("Does not support INuGetProjectSystem"); } #endif var guids = VsHierarchyUtility.GetProjectTypeGuids(envDTEProject); if (guids.Contains(NuGetVSConstants.CppProjectTypeGuid)) // Got a cpp project { if (!EnvDTEProjectUtility.IsClr(envDTEProject)) { return(new NativeProjectSystem(envDTEProject, nuGetProjectContext)); } } // Try to get a factory for the project type guid foreach (var guid in guids) { IMSBuildNuGetProjectSystemThunk factory; if (_factories.TryGetValue(guid, out factory)) { return(factory(envDTEProject, nuGetProjectContext)); } } // Fall back to the default if we have no special project types return(new VSMSBuildNuGetProjectSystem(envDTEProject, nuGetProjectContext)); }
public static IMSBuildNuGetProjectSystem CreateMSBuildNuGetProjectSystem(EnvDTEProject envDTEProject, INuGetProjectContext nuGetProjectContext) { ThreadHelper.ThrowIfNotOnUIThread(); if (envDTEProject == null) { throw new ArgumentNullException(nameof(envDTEProject)); } if (String.IsNullOrEmpty(envDTEProject.FullName)) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, Strings.DTE_ProjectUnsupported, EnvDTEProjectInfoUtility.GetName(envDTEProject))); } if (EnvDTEProjectUtility.SupportsINuGetProjectSystem(envDTEProject)) { throw new InvalidOperationException( string.Format(CultureInfo.CurrentCulture, Strings.DTE_ProjectUnsupported, typeof(IMSBuildNuGetProjectSystem).FullName)); } var guids = VsHierarchyUtility.GetProjectTypeGuids(envDTEProject); if (guids.Contains(VsProjectTypes.CppProjectTypeGuid)) // Got a cpp project { return(new NativeProjectSystem(envDTEProject, nuGetProjectContext)); } // Try to get a factory for the project type guid foreach (var guid in guids) { IMSBuildNuGetProjectSystemThunk factory; if (_factories.TryGetValue(guid, out factory)) { return(factory(envDTEProject, nuGetProjectContext)); } } // Fall back to the default if we have no special project types return(new VSMSBuildNuGetProjectSystem(envDTEProject, nuGetProjectContext)); }