public virtual int DoUpgradeProject_CheckOnly(string projectFileName, IVsUpgradeLogger upgradeLogger, out __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS upgradeRequired, out Guid newProjectFactory, out uint upgradeCapabilityFlags)
        {
            newProjectFactory = GetType().GUID;
            var project = ProjectRootElement.Open(projectFileName);
            // enable Side-by-Side and CopyBackup support
            upgradeCapabilityFlags = (uint)(__VSPPROJECTUPGRADEVIAFACTORYFLAGS.PUVFF_BACKUPSUPPORTED | __VSPPROJECTUPGRADEVIAFACTORYFLAGS.PUVFF_COPYBACKUP | __VSPPROJECTUPGRADEVIAFACTORYFLAGS.PUVFF_SXSBACKUP);
#if FX_ATLEAST_45

            if (this.buildEngine.GetLoadedProjects(projectFileName).Count > 0)
            {
                // project has already been loaded
                upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
                return VSConstants.S_OK;
            }
            var projectInspector = new ProjectInspector(projectFileName);
            if (projectInspector.IsPoisoned(Site))
            {
                // poisoned project cannot be opened (does not require upgrade)
                upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
                return VSConstants.S_OK;
            }
#endif

            // only upgrade known tool versions.
#if FX_ATLEAST_45
            if (string.Equals("4.0", project.ToolsVersion, StringComparison.Ordinal))
            {
                // For 4.0, we need to take a deeper look.  The logic is in 
                //     vsproject\xmake\XMakeConversion\ProjectFileConverter.cs
                var projectConverter = new Microsoft.Build.Conversion.ProjectFileConverter();
                projectConverter.OldProjectFile = projectFileName;
                projectConverter.NewProjectFile = projectFileName;
                if (projectConverter.FSharpSpecificConversions(false))
                {
                    upgradeRequired = 
                        projectInspector.IsLikeDev10MinusProject() 
                            ? __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_ONEWAYUPGRADE 
                            : __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_SAFEREPAIR;
                    return VSConstants.S_OK;
                }
                else
                {
                    upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
                    return VSConstants.S_OK;
                }
            }
            else 
#endif
            if (string.Equals("3.5", project.ToolsVersion, StringComparison.Ordinal) 
                     || string.Equals("2.0", project.ToolsVersion, StringComparison.Ordinal))

             {
                // For 3.5 or 2.0, we always need to upgrade.
                upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_ONEWAYUPGRADE;
                return VSConstants.S_OK;
             }
            upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
            return VSConstants.S_OK;
        }
Beispiel #2
0
        public virtual int DoUpgradeProject_CheckOnly(string projectFileName, IVsUpgradeLogger upgradeLogger, out __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS upgradeRequired, out Guid newProjectFactory, out uint upgradeCapabilityFlags)
        {
            newProjectFactory = GetType().GUID;
            var project = ProjectRootElement.Open(projectFileName);

            // enable Side-by-Side and CopyBackup support
            upgradeCapabilityFlags = (uint)(__VSPPROJECTUPGRADEVIAFACTORYFLAGS.PUVFF_BACKUPSUPPORTED | __VSPPROJECTUPGRADEVIAFACTORYFLAGS.PUVFF_COPYBACKUP | __VSPPROJECTUPGRADEVIAFACTORYFLAGS.PUVFF_SXSBACKUP);

            if (this.buildEngine.GetLoadedProjects(projectFileName).Count > 0)
            {
                // project has already been loaded
                upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
                return(VSConstants.S_OK);
            }
            var projectInspector = new ProjectInspector(projectFileName);

            if (projectInspector.IsPoisoned(Site))
            {
                // poisoned project cannot be opened (does not require upgrade)
                upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
                return(VSConstants.S_OK);
            }

            // only upgrade known tool versions.
            if (string.Equals("4.0", project.ToolsVersion, StringComparison.Ordinal))
            {
                // For 4.0, we need to take a deeper look.  The logic is in
                //     vsproject\xmake\XMakeConversion\ProjectFileConverter.cs
                var projectConverter = new Microsoft.Build.Conversion.ProjectFileConverter();
                projectConverter.OldProjectFile = projectFileName;
                projectConverter.NewProjectFile = projectFileName;
                if (projectConverter.FSharpSpecificConversions(false))
                {
                    upgradeRequired =
                        projectInspector.IsLikeDev10MinusProject()
                            ? __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_ONEWAYUPGRADE
                            : __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_SAFEREPAIR;
                    return(VSConstants.S_OK);
                }
                else
                {
                    upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
                    return(VSConstants.S_OK);
                }
            }
            else
            if (string.Equals("3.5", project.ToolsVersion, StringComparison.Ordinal) ||
                string.Equals("2.0", project.ToolsVersion, StringComparison.Ordinal))

            {
                // For 3.5 or 2.0, we always need to upgrade.
                upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_ONEWAYUPGRADE;
                return(VSConstants.S_OK);
            }
            upgradeRequired = __VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_NOREPAIR;
            return(VSConstants.S_OK);
        }