diff --git a/assets/files.wxs b/assets/files.wxs
index dc3496021a8..dee0720a3d0 100644
--- a/assets/files.wxs
+++ b/assets/files.wxs
@@ -2023,6 +2023,169 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2672,6 +2835,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/System.Management.Automation/help/UpdatableHelpSystem.cs b/src/System.Management.Automation/help/UpdatableHelpSystem.cs
index f190f7bc8f5..63b4d1336af 100644
--- a/src/System.Management.Automation/help/UpdatableHelpSystem.cs
+++ b/src/System.Management.Automation/help/UpdatableHelpSystem.cs
@@ -1,29 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-using System.Globalization;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Net;
using System.ComponentModel;
-using System.Management.Automation.Configuration;
-using System.Management.Automation.Internal;
using System.Diagnostics;
-using System.Threading;
+using System.Globalization;
using System.IO;
-using System.Xml;
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-using System.Text;
-using Microsoft.PowerShell.Commands;
-using Microsoft.Win32;
-using System.Security;
-#if CORECLR
using System.IO.Compression;
+using System.Management.Automation.Configuration;
+using System.Management.Automation.Internal;
+using System.Net;
using System.Net.Http;
+using System.Runtime.Serialization;
+using System.Security;
+using System.Text;
+using System.Threading;
using System.Threading.Tasks;
-#else
+using System.Xml;
using System.Xml.Schema;
-#endif
+
+using Microsoft.PowerShell.Commands;
+using Microsoft.Win32;
namespace System.Management.Automation.Help
{
@@ -235,12 +233,7 @@ internal UpdatableHelpProgressEventArgs(string moduleName, UpdatableHelpCommandT
///
internal class UpdatableHelpSystem : IDisposable
{
-#if CORECLR
private TimeSpan _defaultTimeout;
-#else
- private AutoResetEvent _completionEvent;
- private bool _completed;
-#endif
private Collection _progressEvents;
private bool _stopping;
private object _syncObject;
@@ -257,12 +250,7 @@ internal class UpdatableHelpSystem : IDisposable
internal UpdatableHelpSystem(UpdatableHelpCommandBase cmdlet, bool useDefaultCredentials)
{
WebClient = new WebClient();
-#if CORECLR
_defaultTimeout = new TimeSpan(0, 0, 30);
-#else
- _completionEvent = new AutoResetEvent(false);
- _completed = false;
-#endif
_progressEvents = new Collection();
Errors = new Collection();
_stopping = false;
@@ -348,7 +336,6 @@ internal UpdatableHelpInfo GetHelpInfo(UpdatableHelpCommandType commandType, str
OnProgressChanged(this, new UpdatableHelpProgressEventArgs(CurrentModule, commandType, StringUtil.Format(
HelpDisplayStrings.UpdateProgressLocating), 0));
-#if CORECLR
string xml;
using (HttpClientHandler handler = new HttpClientHandler())
{
@@ -364,9 +351,7 @@ internal UpdatableHelpInfo GetHelpInfo(UpdatableHelpCommandType commandType, str
}
}
}
-#else
- string xml = WebClient.DownloadString(uri);
-#endif
+
UpdatableHelpInfo helpInfo = CreateHelpInfo(xml, moduleName, moduleGuid,
currentCulture: culture, pathOverride: null, verbose: true,
shouldResolveUri: true, ignoreValidationException: false);
@@ -432,7 +417,6 @@ private string ResolveUri(string baseUri, bool verbose)
return uri;
}
-#if CORECLR
using (HttpClientHandler handler = new HttpClientHandler())
{
handler.AllowAutoRedirect = false;
@@ -487,64 +471,6 @@ private string ResolveUri(string baseUri, bool verbose)
}
}
}
-#else
- HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
-
- request.AllowAutoRedirect = false;
- request.Timeout = 30000;
-
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
-
- WebHeaderCollection headers = response.Headers;
-
- try
- {
- if (response.StatusCode == HttpStatusCode.Found ||
- response.StatusCode == HttpStatusCode.Redirect ||
- response.StatusCode == HttpStatusCode.Moved ||
- response.StatusCode == HttpStatusCode.MovedPermanently)
- {
- Uri responseUri = new Uri(headers["Location"], UriKind.RelativeOrAbsolute);
-
- if (responseUri.IsAbsoluteUri)
- {
- uri = responseUri.ToString();
- }
- else
- {
- uri = uri.Replace(request.Address.AbsolutePath, responseUri.ToString());
- }
-
- uri = uri.Trim();
-
- if (verbose)
- {
- _cmdlet.WriteVerbose(StringUtil.Format(RemotingErrorIdStrings.URIRedirectWarningToHost, uri));
- }
-
- if (uri.EndsWith("/", StringComparison.OrdinalIgnoreCase))
- {
- return uri;
- }
- }
- else if (response.StatusCode == HttpStatusCode.OK)
- {
- if (uri.EndsWith("/", StringComparison.OrdinalIgnoreCase))
- {
- return uri;
- }
- else
- {
- throw new UpdatableHelpSystemException("InvalidHelpInfoUri", StringUtil.Format(HelpDisplayStrings.InvalidHelpInfoUri, uri),
- ErrorCategory.InvalidOperation, null, null);
- }
- }
- }
- finally
- {
- response.Close();
- }
-#endif
}
}
catch (UriFormatException e)
@@ -609,9 +535,7 @@ internal UpdatableHelpInfo CreateHelpInfo(string xml, string moduleName, Guid mo
try
{
document = CreateValidXmlDocument(xml, HelpInfoXmlNamespace, HelpInfoXmlSchema,
-#if !CORECLR
new ValidationEventHandler(HelpInfoValidationHandler),
-#endif
true);
}
catch (UpdatableHelpSystemException e)
@@ -684,46 +608,6 @@ internal UpdatableHelpInfo CreateHelpInfo(string xml, string moduleName, Guid mo
return helpInfo;
}
-#if CORECLR
-
- ///
- /// Creates a valid xml document
- ///
- /// input xml
- /// schema namespace
- /// xml schema
- /// HelpInfo or HelpContent?
- private XmlDocument CreateValidXmlDocument(string xml, string ns, string schema, bool helpInfo)
- {
- XmlReaderSettings settings = new XmlReaderSettings();
-
- XmlReader reader = XmlReader.Create(new StringReader(xml), settings);
- XmlDocument document = new XmlDocument();
-
- try
- {
- document.Load(reader);
- }
- catch (XmlException e)
- {
- if (helpInfo)
- {
- throw new UpdatableHelpSystemException(HelpInfoXmlValidationFailure,
- StringUtil.Format(HelpDisplayStrings.HelpInfoXmlValidationFailure, e.Message),
- ErrorCategory.InvalidData, null, e);
- }
- else
- {
- throw new UpdatableHelpSystemException("HelpContentXmlValidationFailure",
- StringUtil.Format(HelpDisplayStrings.HelpContentXmlValidationFailure, e.Message),
- ErrorCategory.InvalidData, null, e);
- }
- }
- return document;
- }
-
-#else
-
///
/// Creates a valid xml document
///
@@ -806,8 +690,6 @@ private void HelpContentValidationHandler(object sender, ValidationEventArgs arg
}
}
-#endif
-
#endregion
#region Help Content Retrieval
@@ -817,16 +699,7 @@ private void HelpContentValidationHandler(object sender, ValidationEventArgs arg
///
internal void CancelDownload()
{
-#if CORECLR
_cancelTokenSource.Cancel();
-#else
- if (WebClient.IsBusy)
- {
- WebClient.CancelAsync();
- _completed = true;
- _completionEvent.Set();
- }
-#endif
_stopping = true;
}
@@ -890,17 +763,11 @@ internal bool DownloadHelpContent(UpdatableHelpCommandType commandType, string p
string uri = helpContentUri + fileName;
-#if CORECLR
return DownloadHelpContentHttpClient(uri, Path.Combine(path, fileName), commandType);
-#else
- return DownloadHelpContentWebClient(uri, Path.Combine(path, fileName), culture, commandType);
-#endif
}
-#if CORECLR
///
- /// Downloads the help content and saves it to a directory. The goal is to achieve
- /// functional parity with WebClient.DownloadFileAsync() using CoreCLR-compatible APIs.
+ /// Downloads the help content and saves it to a directory.
///
///
///
@@ -981,34 +848,6 @@ private void WriteResponseToFile(HttpResponseMessage response, string fileName)
}
}
-#else
-
- ///
- /// Downloads help content and saves it in the specified file.
- ///
- ///
- ///
- ///
- ///
- ///
- private bool DownloadHelpContentWebClient(string uri, string fileName, string culture, UpdatableHelpCommandType commandType)
- {
- WebClient.DownloadFileAsync(new Uri(uri), fileName, culture);
-
- OnProgressChanged(this, new UpdatableHelpProgressEventArgs(CurrentModule, commandType, StringUtil.Format(
- HelpDisplayStrings.UpdateProgressConnecting), 100));
-
- while (!_completed || WebClient.IsBusy)
- {
- _completionEvent.WaitOne();
-
- SendProgressEvents(commandType);
- }
-
- return (Errors.Count == 0);
- }
-#endif
-
private void SendProgressEvents(UpdatableHelpCommandType commandType)
{
// Send progress events
@@ -1384,11 +1223,7 @@ private void ValidateAndCopyHelpContent(string sourcePath, Collection de
{
installed = new Collection();
-#if CORECLR // TODO:CORECLR Disabling this because XML Schemas are not supported for CoreCLR
- string xsd = "Remove this when adding schema support";
-#else
string xsd = LoadStringFromPath(_cmdlet, xsdPath, null);
-#endif
// We only accept txt files and xml files
foreach (string file in Directory.GetFiles(sourcePath))
@@ -1498,9 +1333,7 @@ private void ValidateAndCopyHelpContent(string sourcePath, Collection de
}
CreateValidXmlDocument(node.OuterXml, targetNamespace, xsd,
-#if !CORECLR
new ValidationEventHandler(HelpContentValidationHandler),
-#endif
false);
}
}
diff --git a/src/powershell-unix/powershell-unix.csproj b/src/powershell-unix/powershell-unix.csproj
index f6b16e80d70..f9ccc3451d6 100644
--- a/src/powershell-unix/powershell-unix.csproj
+++ b/src/powershell-unix/powershell-unix.csproj
@@ -16,6 +16,11 @@
PreserveNewest
PreserveNewest
+
+ Schemas\PSMaml\%(FileName)%(Extension)
+ PreserveNewest
+ PreserveNewest
+
PreserveNewest
PreserveNewest
diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj
index 49e815b2e21..63486744e9a 100644
--- a/src/powershell-win-core/powershell-win-core.csproj
+++ b/src/powershell-win-core/powershell-win-core.csproj
@@ -20,6 +20,11 @@
PreserveNewest
PreserveNewest
+
+ Schemas\PSMaml\%(FileName)%(Extension)
+ PreserveNewest
+ PreserveNewest
+
PreserveNewest
PreserveNewest