public virtual void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework) { if (this.next != null) next.UpgradeProject(newVersion, newFramework); }
public ClientProfileTargetFramework(TargetFramework fullFramework) : base(fullFramework.Name + "Client", fullFramework.DisplayName + " Client Profile") { this.FullFramework = fullFramework; this.SupportedRuntimeVersion = fullFramework.SupportedRuntimeVersion; this.MinimumMSBuildVersion = fullFramework.MinimumMSBuildVersion; if (fullFramework.SupportedSku != null) this.SupportedSku = fullFramework.SupportedSku + ",Profile=Client"; else this.SupportedSku = "Client"; }
public bool IsBasedOn(TargetFramework potentialBase) { TargetFramework tmp = this; while (tmp != null) { if (tmp == potentialBase) return true; tmp = tmp.BasedOn; } return false; }
void UpdateAppConfig(TargetFramework newFramework) { // When changing the target framework, update any existing app.config // Also, for applications (not libraries), create an app.config is it is required for the target framework bool createAppConfig = newFramework.RequiresAppConfigEntry && (Project.OutputType != OutputType.Library && Project.OutputType != OutputType.Module); string appConfigFileName = CompilableProject.GetAppConfigFile(Project, createAppConfig); if (appConfigFileName == null) return; using (FakeXmlViewContent xml = new FakeXmlViewContent(appConfigFileName)) { if (xml.Document != null) { XElement configuration = xml.Document.Root; XElement startup = configuration.Element("startup"); if (startup == null) { startup = new XElement("startup"); if (configuration.HasElements && configuration.Elements().First().Name == "configSections") { // <configSections> must be first element configuration.Elements().First().AddAfterSelf(startup); } else { startup = configuration.AddFirstWithIndentation(startup); } } XElement supportedRuntime = startup.Element("supportedRuntime"); if (supportedRuntime == null) { supportedRuntime = startup.AddFirstWithIndentation(new XElement("supportedRuntime")); } supportedRuntime.SetAttributeValue("version", newFramework.SupportedRuntimeVersion); supportedRuntime.SetAttributeValue("sku", newFramework.SupportedSku); } } }
public virtual void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework) { GetOrCreateBehavior().UpgradeProject(newVersion, newFramework); }
public override void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework) { throw new NotSupportedException(); }
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); } } }
/// <summary> /// Gets whether this target framework in an "improved version" of the specified framework. /// This should usually return whether this framework is (mostly) backward-compatible with the specified framework. /// </summary> /// <remarks>The 'IsBasedOn' relation should be reflexive and transitive.</remarks> public virtual bool IsBasedOn(TargetFramework fx) { return fx == this; }
public override bool IsBasedOn(TargetFramework fx) { // This implementation is used for all non-client versions of .NET 4.x return fx != null && fx.IsDesktopFramework && fx.TargetFrameworkProfile == "Client" && fx.Version <= this.Version; }
static string GetMscorlibPath(TargetFramework tf) { while (tf != null) { string path = Path.Combine(Util.ToolLocationHelper.GetPathToDotNetFramework(VersionForString(tf.Name)), "mscorlib.dll"); if (File.Exists(path)) return path; tf = tf.BasedOn; } return null; }
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); } } }