diff --git a/Deployment/InstallerConfiguration.xml b/Deployment/InstallerConfiguration.xml index 8ee9f3b5..cffb680a 100644 --- a/Deployment/InstallerConfiguration.xml +++ b/Deployment/InstallerConfiguration.xml @@ -1,7 +1,7 @@  - + @@ -13,8 +13,8 @@ - + @@ -22,7 +22,7 @@ + shfbVersion="2019.11.17.0" installerName="SandcastleHelpFileBuilder.msi"/> diff --git a/Documentation/SandcastleBuilder/CommonTokens.tokens b/Documentation/SandcastleBuilder/CommonTokens.tokens index bf13e918..5386cdbe 100644 --- a/Documentation/SandcastleBuilder/CommonTokens.tokens +++ b/Documentation/SandcastleBuilder/CommonTokens.tokens @@ -1,7 +1,7 @@  {@BuildDate:MMMM d, yyyy} - v2019.9.15.0 + v2019.11.17.0 Sandcastle Help File Builder https://GitHub.com/EWSoftware/SHFB diff --git a/Documentation/SandcastleBuilder/Content/GettingStarted/GeneralPreferences.aml b/Documentation/SandcastleBuilder/Content/GettingStarted/GeneralPreferences.aml index bf386b73..e7e56b11 100644 --- a/Documentation/SandcastleBuilder/Content/GettingStarted/GeneralPreferences.aml +++ b/Documentation/SandcastleBuilder/Content/GettingStarted/GeneralPreferences.aml @@ -91,13 +91,21 @@ website output will be opened in a tabbed document window within Visual Studio.< - Enable extended XML comments completion options - (Visual Studio extension package + Enable extended XML comments completion options - (Visual Studio 2017 extension package only) If checked, extended XML comments completion items specific to the Sandcastle tools will appear as options in the completion pop-up when entering XML comments in C# projects. These can be used to quickly enter Sandcastle-specific elements such as code elements with source and region attributes, see langword elements, inheritdoc extensions, etc. This option can be disabled if you do not wish to use the extended elements or if you think the completion provider is causing issues with Visual Studio. + + For extended XML comments completion support in Visual Studio 2019 and later, install the + +Extended XML Documentation Comments Completion Provider +Extended XML Documentation Comments Completion Provider +https://marketplace.visualstudio.com/items?itemName=EWoodruff.ExtendedDocCommentsProvider +_blank + package which can be downloaded and installed from the Visual Studio Gallery. diff --git a/Documentation/SandcastleBuilder/Content/GettingStarted/Installation.aml b/Documentation/SandcastleBuilder/Content/GettingStarted/Installation.aml index 4e8c66da..a24cc3bd 100644 --- a/Documentation/SandcastleBuilder/Content/GettingStarted/Installation.aml +++ b/Documentation/SandcastleBuilder/Content/GettingStarted/Installation.aml @@ -115,6 +115,18 @@ editor extension that checks the spelling of comments, strings, and plain text a a tool window. Support is included for spell checking source code, XML files, and MAML topic files. + + For extended XML comments completion support in Visual Studio 2019 and later, install the + +Extended XML Documentation Comments Completion Provider +Extended XML Documentation Comments Completion Provider +https://marketplace.visualstudio.com/items?itemName=EWoodruff.ExtendedDocCommentsProvider +_blank + package which can be downloaded and installed from the Visual Studio Gallery. It is an editor +extension that augments the standard XML documentation comments elements with custom elements, attributes, and +attribute values supported by the Sandcastle Help File Builder and other documentation tools. + + For a Visual Studio add-in used to create XML comments automatically, check out SubMain's diff --git a/Documentation/SandcastleBuilder/Content/VersionHistory/VersionHistory.aml b/Documentation/SandcastleBuilder/Content/VersionHistory/VersionHistory.aml index cfe117ea..4b836acb 100644 --- a/Documentation/SandcastleBuilder/Content/VersionHistory/VersionHistory.aml +++ b/Documentation/SandcastleBuilder/Content/VersionHistory/VersionHistory.aml @@ -16,6 +16,11 @@ review the release notes from all releases after it to the latest to find change your project such as modifications to build component and plug-in configurations. + + + + + diff --git a/Documentation/SandcastleBuilder/Content/VersionHistory/v2019.11.17.0.aml b/Documentation/SandcastleBuilder/Content/VersionHistory/v2019.11.17.0.aml new file mode 100644 index 00000000..84dcc4bb --- /dev/null +++ b/Documentation/SandcastleBuilder/Content/VersionHistory/v2019.11.17.0.aml @@ -0,0 +1,81 @@ + + + + + + + + + This will be the last release that supports Visual Studio 2015. The next release will be updated +to use .NET 4.7 and Visual Studio 2017 or later. + + + +
+ Sandcastle Tools + + + + + Updated the Generate Inherited Documentation tool to issue a warning +(GID0010) if it finds the deprecated +select attribute on the inheritdoc element. + + + + Fixed the URL resolver so that the web client connection uses TLS 1.2 which is now required by +the server hosting the service. + + + + +
+ +
+ Sandcastle Help File Builder + + + + + Merged changes into the default project template from Tom Englert to allow the help file +builder NuGet packages to be referenced and restored within the help file project itself. + + + + Fixed the build engine so that it sets the TargetFramework property in +the documentation source project when multi-targeting is being used. This allows other properties that use it to +be resolved correctly. + + + + Fixed documentation assembly determination by checking the TargetExt +property and using it as the target assembly extension when the output type is "Exe". This solves a problem with +web SDK projects that output a native code host runtime assembly alongside the actual DLL. + + + + + +
+ +
+ Documentation + + + + + Updated the XML comments guide inheritdoc documentation to note that +the select attribute has been deprecated in favor of the path +attribute to be consistent with upcoming support for the element in Visual Studio 2019's IntelliSense. + + + + +
+ + + + + +
+
diff --git a/Documentation/SandcastleBuilder/SandcastleBuilder.content b/Documentation/SandcastleBuilder/SandcastleBuilder.content index 059099e4..cd5b51c0 100644 --- a/Documentation/SandcastleBuilder/SandcastleBuilder.content +++ b/Documentation/SandcastleBuilder/SandcastleBuilder.content @@ -616,7 +616,7 @@ - + @@ -1017,7 +1017,7 @@ - + @@ -1388,11 +1388,16 @@ - + + + + + + diff --git a/Documentation/SandcastleBuilder/SandcastleBuilder.shfbproj b/Documentation/SandcastleBuilder/SandcastleBuilder.shfbproj index 959641b0..ca74cfcb 100644 --- a/Documentation/SandcastleBuilder/SandcastleBuilder.shfbproj +++ b/Documentation/SandcastleBuilder/SandcastleBuilder.shfbproj @@ -33,7 +33,7 @@ Eric%40EWoodruff.us VS2013 Standard - 2019.9.15.0 + 2019.11.17.0 @@ -285,6 +285,7 @@ + diff --git a/NuGet/SHFB.nuspec b/NuGet/SHFB.nuspec index 3d7e14ec..bc8ed655 100644 --- a/NuGet/SHFB.nuspec +++ b/NuGet/SHFB.nuspec @@ -6,7 +6,7 @@ EWSoftware.SHFB - 2019.9.15.0 + 2019.11.17.0 Sandcastle Help File Builder Eric Woodruff Eric Woodruff diff --git a/SHFB/Source/BuildAssembler/BuildAssembler/BuildAssembler.csproj b/SHFB/Source/BuildAssembler/BuildAssembler/BuildAssembler.csproj index 8ad1f1d0..5d6dd403 100644 --- a/SHFB/Source/BuildAssembler/BuildAssembler/BuildAssembler.csproj +++ b/SHFB/Source/BuildAssembler/BuildAssembler/BuildAssembler.csproj @@ -57,11 +57,11 @@ - ..\packages\Microsoft.Build.Framework.14.3.0\lib\net45\Microsoft.Build.Framework.dll + ..\..\packages\Microsoft.Build.Framework.14.3.0\lib\net45\Microsoft.Build.Framework.dll False - ..\packages\Microsoft.Build.Utilities.Core.14.3.0\lib\net45\Microsoft.Build.Utilities.Core.dll + ..\..\packages\Microsoft.Build.Utilities.Core.14.3.0\lib\net45\Microsoft.Build.Utilities.Core.dll False diff --git a/SHFB/Source/BuildAssembler/BuildComponents/MicrosoftDocsXRefServiceResolver.cs b/SHFB/Source/BuildAssembler/BuildComponents/MicrosoftDocsXRefServiceResolver.cs index 3c3c78b9..8f7718ec 100644 --- a/SHFB/Source/BuildAssembler/BuildComponents/MicrosoftDocsXRefServiceResolver.cs +++ b/SHFB/Source/BuildAssembler/BuildComponents/MicrosoftDocsXRefServiceResolver.cs @@ -2,7 +2,7 @@ // System : Sandcastle Help File Builder Components // File : MicrosoftDocsXRefServiceResolver.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 08/16/2019 +// Updated : 11/15/2019 // Note : Copyright 2019, Eric Woodruff, All rights reserved // Compiler: Microsoft Visual C# // @@ -73,6 +73,11 @@ public sealed class MicrosoftDocsXRefServiceResolver : IMemberIdUrlResolver /// There are two overloads for the constructor public MicrosoftDocsXRefServiceResolver() { + // .NET 4.5 doesn't use TLS 1.2 by default so we have to manually tell it to use it or the web client + // connections will fail. This can be removed once we upgrade to .NET 4.6.2 or later. + if((ServicePointManager.SecurityProtocol & SecurityProtocolType.Tls12) != SecurityProtocolType.Tls12) + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + client = new WebClient(); this.CrossReferenceUrlFormat = "https://xref.docs.microsoft.com/query?uid={0}"; diff --git a/SHFB/Source/GenerateInheritedDocs/GenerateInheritedDocs.csproj b/SHFB/Source/GenerateInheritedDocs/GenerateInheritedDocs.csproj index 9da23293..cf3ea01d 100644 --- a/SHFB/Source/GenerateInheritedDocs/GenerateInheritedDocs.csproj +++ b/SHFB/Source/GenerateInheritedDocs/GenerateInheritedDocs.csproj @@ -59,11 +59,11 @@ - packages\Microsoft.Build.Framework.14.3.0\lib\net45\Microsoft.Build.Framework.dll + ..\packages\Microsoft.Build.Framework.14.3.0\lib\net45\Microsoft.Build.Framework.dll False - packages\Microsoft.Build.Utilities.Core.14.3.0\lib\net45\Microsoft.Build.Utilities.Core.dll + ..\packages\Microsoft.Build.Utilities.Core.14.3.0\lib\net45\Microsoft.Build.Utilities.Core.dll False diff --git a/SHFB/Source/MRefBuilder/MRefBuilder.csproj b/SHFB/Source/MRefBuilder/MRefBuilder.csproj index 5162bed8..ef31c08d 100644 --- a/SHFB/Source/MRefBuilder/MRefBuilder.csproj +++ b/SHFB/Source/MRefBuilder/MRefBuilder.csproj @@ -60,11 +60,11 @@ - packages\Microsoft.Build.Framework.14.3.0\lib\net45\Microsoft.Build.Framework.dll + ..\packages\Microsoft.Build.Framework.14.3.0\lib\net45\Microsoft.Build.Framework.dll False - packages\Microsoft.Build.Utilities.Core.14.3.0\lib\net45\Microsoft.Build.Utilities.Core.dll + ..\packages\Microsoft.Build.Utilities.Core.14.3.0\lib\net45\Microsoft.Build.Utilities.Core.dll False diff --git a/SHFB/Source/SandcastleBuilderPackage/source.extension.vsixmanifest b/SHFB/Source/SandcastleBuilderPackage/source.extension.vsixmanifest index 90f43e11..14a87802 100644 --- a/SHFB/Source/SandcastleBuilderPackage/source.extension.vsixmanifest +++ b/SHFB/Source/SandcastleBuilderPackage/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + SHFB Visual Studio integration for the Sandcastle Help File Builder. https://ewsoftware.github.io/SHFB/html/bd1ddb51-1c4f-434f-bb1a-ce2135d3a909.htm diff --git a/SHFB/Source/SandcastleBuilderPlugIns/AjaxDocPlugIn.cs b/SHFB/Source/SandcastleBuilderPlugIns/AjaxDocPlugIn.cs index 357af0c0..238bb824 100644 --- a/SHFB/Source/SandcastleBuilderPlugIns/AjaxDocPlugIn.cs +++ b/SHFB/Source/SandcastleBuilderPlugIns/AjaxDocPlugIn.cs @@ -2,8 +2,8 @@ // System : Sandcastle Help File Builder Plug-Ins // File : AjaxDocPlugIn.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 05/25/2015 -// Note : Copyright 2007-2015, Eric Woodruff, All rights reserved +// Updated : 11/15/2019 +// Note : Copyright 2007-2019, Eric Woodruff, All rights reserved // Compiler: Microsoft Visual C# // // This file contains a plug-in designed to generate XML comments and reflection file information for Atlas @@ -285,6 +285,11 @@ public void Execute(SandcastleBuilder.Utils.BuildComponent.ExecutionContext cont // Allow Before step plug-ins to run builder.ExecuteBeforeStepPlugIns(); + // .NET 4.5 doesn't use TLS 1.2 by default so we have to manually tell it to use it or the web client + // connections will fail. This can be removed once we upgrade to .NET 4.6.2 or later. + if((ServicePointManager.SecurityProtocol & SecurityProtocolType.Tls12) != SecurityProtocolType.Tls12) + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + // Download the files using(WebClient webClient = new WebClient()) { diff --git a/SHFB/Source/SandcastleBuilderPlugIns/DeploymentPlugIn.cs b/SHFB/Source/SandcastleBuilderPlugIns/DeploymentPlugIn.cs index a299e7e1..d8f1f474 100644 --- a/SHFB/Source/SandcastleBuilderPlugIns/DeploymentPlugIn.cs +++ b/SHFB/Source/SandcastleBuilderPlugIns/DeploymentPlugIn.cs @@ -2,8 +2,8 @@ // System : Sandcastle Help File Builder Plug-Ins // File : DeploymentPlugIn.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 05/03/2015 -// Note : Copyright 2007-2015, Eric Woodruff, All rights reserved +// Updated : 11/15/2019 +// Note : Copyright 2007-2019, Eric Woodruff, All rights reserved // Compiler: Microsoft Visual C# // // This file contains a plug-in that can be used to deploy the resulting help file output to a location other @@ -264,6 +264,12 @@ private void DeployOutput(Collection files, DeploymentLocation location) rootPath = target.LocalPath; else { + // .NET 4.5 doesn't use TLS 1.2 by default so we have to manually tell it to use it or the + // web client connections will fail. This can be removed once we upgrade to .NET 4.6.2 or + // later. + if((ServicePointManager.SecurityProtocol & SecurityProtocolType.Tls12) != SecurityProtocolType.Tls12) + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + // FTP, HTTP, etc. rootPath = target.ToString(); webClient = new WebClient(); diff --git a/SHFB/Source/SandcastleBuilderUtils/MSBuild/MSBuildProject.cs b/SHFB/Source/SandcastleBuilderUtils/MSBuild/MSBuildProject.cs index c4f9373b..b795ad5f 100644 --- a/SHFB/Source/SandcastleBuilderUtils/MSBuild/MSBuildProject.cs +++ b/SHFB/Source/SandcastleBuilderUtils/MSBuild/MSBuildProject.cs @@ -2,7 +2,7 @@ // System : Sandcastle Help File Builder MSBuild Tasks // File : MSBuildProject.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 03/31/2019 +// Updated : 11/16/2019 // Note : Copyright 2008-2019, Eric Woodruff, All rights reserved // Compiler: Microsoft Visual C# // @@ -66,7 +66,7 @@ public class MSBuildProject : IDisposable private Dictionary properties; private readonly bool removeProjectWhenDisposed; - private static Regex reInvalidAttribute = new Regex( + private static readonly Regex reInvalidAttribute = new Regex( "The attribute \"(.*?)\" in element \\<(.*?)\\> is unrecognized", RegexOptions.IgnoreCase); #endregion @@ -157,7 +157,22 @@ public string AssemblyName String.Compare(outputType, "WinExe", StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(outputType, "AppContainerExe", StringComparison.OrdinalIgnoreCase) == 0) { - assemblyName += ".exe"; + string ext = ".exe"; + + // .NET Core web SDK projects sometimes output a native code runtime host executable + // and compile the code into a separate assembly. In these cases, the output type + // is Exe but the target extension is .dll. When they differ, assume the target + // extension is the correct one to use. + if(properties.TryGetValue("TargetExt", out prop)) + { + if(!String.IsNullOrWhiteSpace(prop.EvaluatedValue) && + !prop.EvaluatedValue.Equals(ext, StringComparison.OrdinalIgnoreCase)) + { + ext = prop.EvaluatedValue; + } + } + + assemblyName += ext; } else if(String.Compare(outputType, "winmdobj", StringComparison.OrdinalIgnoreCase) == 0) @@ -181,14 +196,26 @@ public string AssemblyName if(!File.Exists(assemblyName) && properties.TryGetValue("TargetFrameworks", out prop)) { outputPath = Path.GetDirectoryName(assemblyName); + string targetFramework = null; foreach(string subfolder in prop.EvaluatedValue.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) if(Directory.EnumerateFiles(Path.Combine(outputPath, subfolder), Path.GetFileName(assemblyName)).Any()) { + targetFramework = subfolder; assemblyName = Path.Combine(outputPath, subfolder, Path.GetFileName(assemblyName)); break; } + + // Set TargetFramework if necessary as some people use it to as a variable in other paths + // to references etc. when multi-targeting. + if(!String.IsNullOrWhiteSpace(targetFramework) && !properties.Keys.Contains("TargetFramework")) + { + this.ProjectFile.SetProperty("TargetFramework", targetFramework); + this.ProjectFile.ReevaluateIfNecessary(); + + properties.Add("TargetFramework", this.ProjectFile.GetProperty("TargetFramework")); + } } } @@ -203,7 +230,7 @@ public string XmlCommentsFile { get { - string docFile = null, outputPath = null, origDocFile; + string docFile, outputPath = null, origDocFile; if(properties == null) throw new InvalidOperationException("Configuration has not been set"); @@ -343,7 +370,7 @@ public string TargetFrameworkVersion if(versionValue == null) { // If not found but TargetFrameworks is specified, just assume some version of .NETFramework - if(properties.TryGetValue("TargetFrameworks", out prop)) + if(properties.Keys.Contains("TargetFrameworks")) return "4.5.2"; throw new InvalidOperationException("Unable to determine target framework version for project"); diff --git a/SHFB/Source/SandcastleBuilderUtils/Properties/AssemblyInfoShared.cs b/SHFB/Source/SandcastleBuilderUtils/Properties/AssemblyInfoShared.cs index dfaf9485..cfd2ee07 100644 --- a/SHFB/Source/SandcastleBuilderUtils/Properties/AssemblyInfoShared.cs +++ b/SHFB/Source/SandcastleBuilderUtils/Properties/AssemblyInfoShared.cs @@ -2,7 +2,7 @@ // System : Sandcastle Help File Builder // File : AssemblyInfoShared.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 09/15/2019 +// Updated : 11/17/2019 // Note : Copyright 2006-2019, Eric Woodruff, All rights reserved // Compiler: Microsoft Visual C# // @@ -91,13 +91,13 @@ internal static partial class AssemblyInfo // // This is used to set the assembly file version. This will change with each new release. MSIs only // support a Major value between 0 and 255 so we drop the century from the year on this one. - public const string FileVersion = "19.9.15.0"; + public const string FileVersion = "19.11.17.0"; // Common product version // // This may contain additional text to indicate Alpha or Beta states. The version number will always match // the file version above but includes the century on the year. - public const string ProductVersion = "2019.9.15.0"; + public const string ProductVersion = "2019.11.17.0"; // Assembly copyright information public const string Copyright = "Copyright \xA9 2006-2019, Eric Woodruff, All Rights Reserved"; diff --git a/SHFB/Source/SandcastleCore/Properties/AssemblyInfoShared.cs b/SHFB/Source/SandcastleCore/Properties/AssemblyInfoShared.cs index 88bafb3f..5bade8b5 100644 --- a/SHFB/Source/SandcastleCore/Properties/AssemblyInfoShared.cs +++ b/SHFB/Source/SandcastleCore/Properties/AssemblyInfoShared.cs @@ -1,7 +1,7 @@ //=============================================================================================================== // System : Sandcastle Tools // File : AssemblyInfoShared.cs -// Updated : 09/15/2019 +// Updated : 11/17/2019 // Note : Copyright 2006-2019, Microsoft Corporation, All rights reserved // // Sandcastle tools common assembly attributes. @@ -73,13 +73,13 @@ internal static partial class AssemblyInfo // // This is used to set the assembly file version. This will change with each new release. MSIs only // support a Major value between 0 and 255 so we drop the century from the year on this one. - public const string FileVersion = "19.9.15.0"; + public const string FileVersion = "19.11.17.0"; // Common product version // // This may contain additional text to indicate Alpha or Beta states. The version number will always match // the file version above but includes the century on the year. - public const string ProductVersion = "2019.9.15.0"; + public const string ProductVersion = "2019.11.17.0"; // Assembly copyright information public const string Copyright = "Copyright \xA9 2006-2019, Microsoft Corporation, All Rights Reserved.\r\n" + diff --git a/SHFB/Source/SandcastleInstaller/InstallerConfiguration.xml b/SHFB/Source/SandcastleInstaller/InstallerConfiguration.xml index 42f1c89e..cdf3682b 100644 --- a/SHFB/Source/SandcastleInstaller/InstallerConfiguration.xml +++ b/SHFB/Source/SandcastleInstaller/InstallerConfiguration.xml @@ -4,7 +4,7 @@ - + @@ -16,8 +16,8 @@ - + @@ -25,7 +25,7 @@ + shfbVersion="2019.11.17.0" installerName="SandcastleHelpFileBuilder.msi"/> diff --git a/SHFB/Source/SandcastleInstaller/InstallerPages/RequiredFrameworkPage.xaml b/SHFB/Source/SandcastleInstaller/InstallerPages/RequiredFrameworkPage.xaml deleted file mode 100644 index 4793834d..00000000 --- a/SHFB/Source/SandcastleInstaller/InstallerPages/RequiredFrameworkPage.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - Microsoft .NET Framework - The Sandcastle tools are written using the .NET Framework. As such, it is required that -the proper version be present in order to run all of the necessary tools installed by this package. This -application and most of the existing tools and components will run on .NET 4.5. Some third-party build -tools may require a more recent version of the .NET Framework. - - - - diff --git a/SHFB/Source/SandcastleInstaller/InstallerPages/RequiredFrameworkPage.xaml.cs b/SHFB/Source/SandcastleInstaller/InstallerPages/RequiredFrameworkPage.xaml.cs deleted file mode 100644 index 95c3617c..00000000 --- a/SHFB/Source/SandcastleInstaller/InstallerPages/RequiredFrameworkPage.xaml.cs +++ /dev/null @@ -1,197 +0,0 @@ -//=============================================================================================================== -// System : Sandcastle Guided Installation -// File : RequiredFrameworkPage.cs -// Author : Eric Woodruff -// Updated : 05/09/2015 -// Compiler: Microsoft Visual C# -// -// This file contains a page used to help the user download and install the minimum .NET Framework version -// -// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be -// distributed with the code and can be found at the project website: https://GitHub.com/EWSoftware/SHFB. This -// notice and all copyright notices must remain intact in all applications, documentation, and source files. -// -// Date Who Comments -// ============================================================================================================== -// 02/05/2011 EFW Created the code -// 03/06/2012 EFW Converted to use WPF -//=============================================================================================================== - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Windows; -using System.Windows.Documents; - -namespace Sandcastle.Installer.InstallerPages -{ - /// - /// This page is used to help the user download and install the minimum .NET Framework version. - /// - public partial class RequiredFrameworkPage : BasePage - { - #region Private data members - //===================================================================== - - private Version minVersion, installerVersion; - private List allVersions; - #endregion - - #region Properties - //===================================================================== - - /// - public override string PageTitle - { - get { return ".NET Framework"; } - } - - /// - /// This is overridden to prevent continuing until the required .NET Framework version is installed - /// - public override bool CanContinue - { - get - { - if(!this.IsRequiredVersionPresent) - { - MessageBox.Show("The required .NET Framework version must be present in order to " + - "install all of the required tools. Follow the instructions on this page to " + - "download and install it.", this.PageTitle, MessageBoxButton.OK, - MessageBoxImage.Exclamation); - return false; - } - - return base.CanContinue; - } - } - - /// - /// This is used to see if the required framework version is present - /// - private bool IsRequiredVersionPresent - { - get - { - // We could look at the registry but we'll take the simple approach as most of the time, - // nothing will require a later version than what we are running under. - allVersions.Clear(); - allVersions.AddRange( - Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.System) + - @"\..\Microsoft.NET\Framework").Where(d => - { - string dir = d.Substring(d.LastIndexOf('\\') + 1); - - return dir.Length > 2 && (dir[0] == 'v' || dir[0] == 'V') && - Char.IsDigit(dir[1]); - - }).Select(d => d.Substring(d.LastIndexOf('\\') + 2))); - - minVersion = this.Installer.AllPages.Max(p => p.RequiredFrameworkVersion) ?? minVersion; - - if(minVersion <= installerVersion) - return true; - - string required = minVersion.ToString(); - - return allVersions.Any(v => v == required || v.StartsWith(required, StringComparison.Ordinal)); - } - } - #endregion - - #region Constructor - //===================================================================== - - /// - /// Constructor - /// - public RequiredFrameworkPage() - { - minVersion = installerVersion = new Version(4, 5); - allVersions = new List(); - - InitializeComponent(); - - // Handle hyperlink clicks using the default handler - fdDocument.AddHandler(Hyperlink.ClickEvent, new RoutedEventHandler(Utility.HyperlinkClick)); - } - #endregion - - #region Method overrides - //===================================================================== - - /// - /// This is overridden to figure out the minimum .NET Framework version required by all pages in - /// the installer. - /// - public override void ShowPage() - { - Paragraph para; - - // If already checked, just return - if(allVersions.Count != 0) - return; - - if(this.IsRequiredVersionPresent) - { - fdDocument.Blocks.Add(new Paragraph( - new Bold(new Run("Minimum Required Version Found"))) { FontSize = 13 }); - - fdDocument.Blocks.Add(new Paragraph( - new Run(String.Format(CultureInfo.CurrentCulture, "It has been determined that the " + - "minimum .NET Framework version (v{0}) required by the tools installed by this " + - "package is present. No further action is required in this step.", minVersion)))); - - para = new Paragraph(); - - para.Inlines.AddRange(new Inline[] { - new Run("Click the "), new Bold(new Run("Next")), new Run(" button to continue.") }); - - fdDocument.Blocks.Add(para); - } - else - { - fdDocument.Blocks.Add(new Paragraph(new Run(String.Format(CultureInfo.CurrentCulture, - "The .NET Framework {0} is required by the following tools installed by this package:", - minVersion)))); - - var list = new List(); - - list.ListItems.AddRange(this.Installer.AllPages.Where( - p => p.RequiredFrameworkVersion >= minVersion).Select( - p => new ListItem(new Paragraph(new Run(p.PageTitle))))); - - fdDocument.Blocks.Add(list); - fdDocument.Blocks.Add(new Paragraph(new Run("To install it, do the following:"))); - - list = new List(); - - para = new Paragraph(new Run("Click this link to go to the download page: ")); - para.Inlines.Add(new Hyperlink(new Run(".NET Framework and .NET SDKs")) { - NavigateUri = new Uri("https://dotnet.microsoft.com/") - }); - - list.ListItems.Add(new ListItem(para)); - - para = new Paragraph(); - para.Inlines.AddRange(new Inline[] { - new Run("Once the page opens, download and install the required version.") }); - list.ListItems.Add(new ListItem(para)); - - para = new Paragraph(); - para.Inlines.AddRange(new Inline[] { - new Run("When it has finished, come back to this application and click the "), - new Bold(new Run("Next")), - new Run(" button to continue installing the rest of the tools.") }); - list.ListItems.Add(new ListItem(para)); - - fdDocument.Blocks.Add(list); - } - - base.ShowPage(); - } - #endregion - } -}