private static bool IsProjectCapabilityCompliant(EnvDTE.Project envDTEProject) { ThreadHelper.ThrowIfNotOnUIThread(); Debug.Assert(envDTEProject != null); var hierarchy = VsHierarchyUtility.ToVsHierarchy(envDTEProject); return(VsHierarchyUtility.IsProjectCapabilityCompliant(hierarchy)); }
public async Task <NuGetProject> TryCreateNuGetProjectAsync( IVsProjectAdapter vsProject, ProjectProviderContext context, bool forceProjectType) { Assumes.Present(vsProject); Assumes.Present(context); ThreadHelper.ThrowIfNotOnUIThread(); // The project must be an IVsHierarchy. var hierarchy = vsProject.VsHierarchy; if (hierarchy == null) { return(null); } // Check if the project is not CPS capable or if it is CPS capable that its opt'd in PackageReferences if (!VsHierarchyUtility.IsCPSCapabilityCompliant(hierarchy) || !VsHierarchyUtility.IsProjectCapabilityCompliant(hierarchy)) { return(null); } var buildProperties = vsProject.BuildProperties; // read MSBuild property RestoreProjectStyle var restoreProjectStyle = await buildProperties.GetPropertyValueAsync(ProjectBuildProperties.RestoreProjectStyle); // check for RestoreProjectStyle property is set and if not set to PackageReference then return false if (!(string.IsNullOrEmpty(restoreProjectStyle) || restoreProjectStyle.Equals(PackageReference, StringComparison.OrdinalIgnoreCase))) { return(null); } var fullProjectPath = vsProject.FullProjectPath; var unconfiguredProject = GetUnconfiguredProject(vsProject.Project); var projectServices = new NetCoreProjectSystemServices(vsProject, await _componentModel.GetValueAsync()); return(new CpsPackageReferenceProject( vsProject.ProjectName, vsProject.CustomUniqueName, fullProjectPath, _projectSystemCache, unconfiguredProject, projectServices, vsProject.ProjectId)); }
public static async Task <bool> ContainsFileAsync(EnvDTE.Project envDTEProject, string path) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (string.Equals(envDTEProject.Kind, VsProjectTypes.WixProjectTypeGuid, StringComparison.OrdinalIgnoreCase) || string.Equals(envDTEProject.Kind, VsProjectTypes.NemerleProjectTypeGuid, StringComparison.OrdinalIgnoreCase) || string.Equals(envDTEProject.Kind, VsProjectTypes.FsharpProjectTypeGuid, StringComparison.OrdinalIgnoreCase) || string.Equals(envDTEProject.Kind, VsProjectTypes.JsProjectTypeGuid, StringComparison.OrdinalIgnoreCase)) { // For Wix and Nemerle projects, IsDocumentInProject() returns not found // even though the file is in the project. So we use GetProjectItem() // instead. Nemerle is a high-level statically typed programming language for .NET platform // Note that pszMkDocument, the document moniker, passed to IsDocumentInProject(), must be a path to the file // for certain file-based project systems such as F#. And, not just a filename. For these project systems as well, // do the following var item = await GetProjectItemAsync(envDTEProject, path); return(item != null); } await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var hierarchy = await envDTEProject.ToVsHierarchyAsync(); var vsProject = hierarchy as IVsProject; if (vsProject == null) { return(false); } int pFound; if (VsHierarchyUtility.IsProjectCapabilityCompliant(hierarchy)) { // REVIEW: We want to revisit this after RTM - the code in this if statement should be applied to every project type. // We're checking for VSDOCUMENTPRIORITY.DP_Standard here to see if the file is included in the project. // Original check (outside of if) did not have this. var priority = new VSDOCUMENTPRIORITY[1]; var hr = vsProject.IsDocumentInProject(path, out pFound, priority, out _); return(ErrorHandler.Succeeded(hr) && pFound == 1 && priority[0] >= VSDOCUMENTPRIORITY.DP_Standard); } var hres = vsProject.IsDocumentInProject(path, out pFound, Array.Empty <VSDOCUMENTPRIORITY>(), out _); return(ErrorHandler.Succeeded(hres) && pFound == 1); }
public static async Task <bool> IsSupportedAsync(EnvDTE.Project envDTEProject) { Assumes.Present(envDTEProject); await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var hierarchy = await envDTEProject.ToVsHierarchyAsync(); if (VsHierarchyUtility.IsProjectCapabilityCompliant(hierarchy)) { return(true); } return(envDTEProject.Kind != null && ProjectType.IsSupported(envDTEProject.Kind) && !VsHierarchyUtility.HasUnsupportedProjectCapability(hierarchy)); }