public override void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework)
        {
            if (!Project.ReadOnly)
            {
                lock (Project.SyncRoot) {
                    TargetFramework oldFramework = Project.CurrentTargetFramework;
                    if (newVersion != null && GetAvailableCompilerVersions().Contains(newVersion))
                    {
                        Project.SetToolsVersion(newVersion.MSBuildVersion.Major + "." + newVersion.MSBuildVersion.Minor);
                    }
                    if (newFramework != null)
                    {
                        UpdateAppConfig(newFramework);

                        ClientProfileTargetFramework clientProfile = newFramework as ClientProfileTargetFramework;
                        if (clientProfile != null)
                        {
                            newFramework = clientProfile.FullFramework;
                            ((MSBuildBasedProject)Project).SetProperty(null, null, "TargetFrameworkProfile", "Client", PropertyStorageLocations.Base, true);
                        }
                        else
                        {
                            ((MSBuildBasedProject)Project).SetProperty(null, null, "TargetFrameworkProfile", "", PropertyStorageLocations.Base, true);
                        }
                        ((MSBuildBasedProject)Project).SetProperty(null, null, "TargetFrameworkVersion", newFramework.Name, PropertyStorageLocations.Base, true);

                        if (oldFramework is ClientProfileTargetFramework)
                        {
                            oldFramework = ((ClientProfileTargetFramework)oldFramework).FullFramework;
                        }

                        if (oldFramework != null && !oldFramework.IsBasedOn(TargetFramework.Net35) && newFramework.IsBasedOn(TargetFramework.Net35))
                        {
                            AddDotnet35References();
                        }
                        else if (oldFramework != null && oldFramework.IsBasedOn(TargetFramework.Net35) && !newFramework.IsBasedOn(TargetFramework.Net35))
                        {
                            RemoveDotnet35References();
                        }

                        if (oldFramework != null && !oldFramework.IsBasedOn(TargetFramework.Net40) && newFramework.IsBasedOn(TargetFramework.Net40))
                        {
                            AddDotnet40References();
                        }
                        else if (oldFramework != null && oldFramework.IsBasedOn(TargetFramework.Net40) && !newFramework.IsBasedOn(TargetFramework.Net40))
                        {
                            RemoveDotnet40References();
                        }
                    }
                    AddOrRemoveExtensions();
                    Project.Save();
                    ResXConverter.UpdateResourceFiles(Project);
                }
            }
        }
示例#2
0
        public override void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework)
        {
            if (!Project.IsReadOnly)
            {
                lock (Project.SyncRoot) {
                    TargetFramework oldFramework = Project.CurrentTargetFramework;
                    if (newVersion != null && GetAvailableCompilerVersions().Contains(newVersion))
                    {
                        Project.ToolsVersion = newVersion.MSBuildVersion.Major + "." + newVersion.MSBuildVersion.Minor;
                    }
                    if (newFramework != null)
                    {
                        UpdateAppConfig(newFramework);

                        ((MSBuildBasedProject)Project).SetProperty(null, null, "TargetFrameworkVersion", newFramework.TargetFrameworkVersion, PropertyStorageLocations.Base, true);
                        ((MSBuildBasedProject)Project).SetProperty(null, null, "TargetFrameworkProfile", newFramework.TargetFrameworkProfile, PropertyStorageLocations.Base, true);

                        if (oldFramework != null && oldFramework.Version < Versions.V3_5 && newFramework.Version >= Versions.V3_5)
                        {
                            AddDotnet35References();
                        }
                        else if (oldFramework != null && oldFramework.Version >= Versions.V3_5 && newFramework.Version < Versions.V3_5)
                        {
                            RemoveDotnet35References();
                        }

                        if (oldFramework != null && oldFramework.Version < Versions.V4_0 && newFramework.Version >= Versions.V4_0)
                        {
                            AddDotnet40References();
                        }
                        else if (oldFramework != null && oldFramework.Version >= Versions.V4_0 && newFramework.Version < Versions.V4_0)
                        {
                            RemoveDotnet40References();
                        }
                    }
                    AddOrRemoveExtensions();
                    Project.Save();
                    ResXConverter.UpdateResourceFiles(Project);
                }
            }
        }