Exemplo n.º 1
0
        /// <summary>
        /// Verifies any publish profiles in the project and returns it as a list of strings
        /// </summary>
        /// <param name="hierarchy">The current project hierarchy</param>
        /// <param name="projectPath">Full path of the current project</param>
        /// <returns>List of publish profile names</returns>
        private IEnumerable<string> GetPublishProfileTransforms(IVsHierarchy hierarchy, string projectPath)
        {
            if (hierarchy == null)
            {
                throw new ArgumentNullException(nameof(hierarchy));
            }

            if (string.IsNullOrEmpty(projectPath))
            {
                throw new ArgumentNullException(nameof(projectPath));
            }

            List<string> result = new List<string>();
            IVsProjectSpecialFiles specialFiles = hierarchy as IVsProjectSpecialFiles;
            if (ErrorHandler.Failed(specialFiles.GetFile((int)__PSFFILEID2.PSFFILEID_AppDesigner, (uint)__PSFFLAGS.PSFF_FullPath, out uint itemid, out string propertiesFolder)))
            {
                this.logger.LogMessage("Exception trying to create IVsProjectSpecialFiles");
            }

            if (!string.IsNullOrEmpty(propertiesFolder))
            {
                // Properties\PublishProfiles
                string publishProfilesFolder = Path.Combine(propertiesFolder, "PublishProfiles");
                if (Directory.Exists(publishProfilesFolder))
                {
                    string[] publishProfiles = Directory.GetFiles(publishProfilesFolder, "*.pubxml");
                    if (publishProfiles != null)
                    {
                        return publishProfiles.Select(profile => Path.GetFileNameWithoutExtension(profile));
                    }
                }
            }

            return null;
        }
Exemplo n.º 2
0
        public async Task <string> GetFileAsync(SpecialFiles fileId, SpecialFileFlags flags)
        {
            await _projectVsServices.ThreadingService.SwitchToUIThread();

            IVsProjectSpecialFiles files = (IVsProjectSpecialFiles)_projectVsServices.VsHierarchy;

            HResult result = files.GetFile((int)fileId, (uint)flags, out uint itemId, out string fileName);

            if (result.IsOK)
            {
                return(fileName);
            }

            if (result.IsNotImplemented)
            {
                return(null);    // Not handled
            }
            throw result.Exception;
        }