Compare commits
1 commit
master
...
source-dep
Author | SHA1 | Date | |
---|---|---|---|
c748652c34 |
|
@ -79,8 +79,6 @@ namespace Microsoft.PackageManagement.Providers.Internal.Bootstrap {
|
||||||
return Enumerable.Empty<Feed>();
|
return Enumerable.Empty<Feed>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !PORTABLE
|
|
||||||
// we don't do bootstrap on core powershell
|
|
||||||
if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {
|
if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {
|
||||||
Warning(Constants.Messages.NetworkNotAvailable);
|
Warning(Constants.Messages.NetworkNotAvailable);
|
||||||
Warning(string.Format(CultureInfo.CurrentCulture, Resources.Messages.ProviderBootstrapFailed));
|
Warning(string.Format(CultureInfo.CurrentCulture, Resources.Messages.ProviderBootstrapFailed));
|
||||||
|
@ -96,7 +94,6 @@ namespace Microsoft.PackageManagement.Providers.Internal.Bootstrap {
|
||||||
Warning(Constants.Messages.ProviderSwidtagUnavailable);
|
Warning(Constants.Messages.ProviderSwidtagUnavailable);
|
||||||
return Enumerable.Empty<Feed>();
|
return Enumerable.Empty<Feed>();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return _feeds;
|
return _feeds;
|
||||||
}
|
}
|
||||||
|
@ -507,10 +504,6 @@ namespace Microsoft.PackageManagement.Providers.Internal.Bootstrap {
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal Package GetProviderFromFile(string filePath, bool copyFileToTemp = false, bool suppressErrorsAndWarnings = false) {
|
internal Package GetProviderFromFile(string filePath, bool copyFileToTemp = false, bool suppressErrorsAndWarnings = false) {
|
||||||
|
|
||||||
#if PORTABLE
|
|
||||||
// not supported on core powershell
|
|
||||||
return null;
|
|
||||||
#else
|
|
||||||
if (string.IsNullOrWhiteSpace(filePath) && !System.IO.File.Exists(filePath)) {
|
if (string.IsNullOrWhiteSpace(filePath) && !System.IO.File.Exists(filePath)) {
|
||||||
Warning(Constants.Messages.FileNotFound, filePath);
|
Warning(Constants.Messages.FileNotFound, filePath);
|
||||||
return null;
|
return null;
|
||||||
|
@ -571,7 +564,6 @@ namespace Microsoft.PackageManagement.Providers.Internal.Bootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -700,4 +692,4 @@ namespace Microsoft.PackageManagement.Providers.Internal.Bootstrap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -134,8 +134,6 @@ namespace Microsoft.PackageManagement.MetaProvider.PowerShell.Internal {
|
||||||
if (_baseFolder == null || !Directory.Exists(_baseFolder)) {
|
if (_baseFolder == null || !Directory.Exists(_baseFolder)) {
|
||||||
throw new Exception(Resources.Messages.CantFindBasePowerShellModuleFolder);
|
throw new Exception(Resources.Messages.CantFindBasePowerShellModuleFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
_baseFolder = Path.Combine(_baseFolder, "Modules", "PackageManagement");
|
|
||||||
}
|
}
|
||||||
return _baseFolder;
|
return _baseFolder;
|
||||||
}
|
}
|
||||||
|
@ -829,4 +827,4 @@ namespace Microsoft.PackageManagement.MetaProvider.PowerShell.Internal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -480,7 +480,7 @@
|
||||||
HashSet<PackageItem> temporarilyMarked = new HashSet<PackageItem>(new PackageItemComparer());
|
HashSet<PackageItem> temporarilyMarked = new HashSet<PackageItem>(new PackageItemComparer());
|
||||||
|
|
||||||
// checks that there are no dependency loop
|
// checks that there are no dependency loop
|
||||||
hasDependencyLoop = !DepthFirstVisit(packageItem, temporarilyMarked, permanentlyMarked, dependencyToBeInstalled, new HashSet<string>(), request);
|
hasDependencyLoop = !DepthFirstVisit(packageItem, temporarilyMarked, permanentlyMarked, dependencyToBeInstalled, request);
|
||||||
|
|
||||||
if (!hasDependencyLoop)
|
if (!hasDependencyLoop)
|
||||||
{
|
{
|
||||||
|
@ -502,10 +502,9 @@
|
||||||
/// <param name="dependencyToBeInstalled"></param>
|
/// <param name="dependencyToBeInstalled"></param>
|
||||||
/// <param name="permanentlyMarked"></param>
|
/// <param name="permanentlyMarked"></param>
|
||||||
/// <param name="temporarilyMarked"></param>
|
/// <param name="temporarilyMarked"></param>
|
||||||
/// <param name="processedDependencies"></param>
|
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static bool DepthFirstVisit(PackageItem packageItem, HashSet<PackageItem> temporarilyMarked, HashSet<PackageItem> permanentlyMarked, List<PackageItem> dependencyToBeInstalled, HashSet<string> processedDependencies, NuGetRequest request)
|
internal static bool DepthFirstVisit(PackageItem packageItem, HashSet<PackageItem> temporarilyMarked, HashSet<PackageItem> permanentlyMarked, List<PackageItem> dependencyToBeInstalled, NuGetRequest request)
|
||||||
{
|
{
|
||||||
// dependency loop detected because the element is temporarily marked
|
// dependency loop detected because the element is temporarily marked
|
||||||
if (temporarilyMarked.Contains(packageItem))
|
if (temporarilyMarked.Contains(packageItem))
|
||||||
|
@ -524,9 +523,9 @@
|
||||||
temporarilyMarked.Add(packageItem);
|
temporarilyMarked.Add(packageItem);
|
||||||
|
|
||||||
// Visit the dependency
|
// Visit the dependency
|
||||||
foreach (var dependency in GetPackageDependenciesHelper(packageItem, processedDependencies, request))
|
foreach (var dependency in GetPackageDependenciesHelper(packageItem, request))
|
||||||
{
|
{
|
||||||
if (!DepthFirstVisit(dependency, temporarilyMarked, permanentlyMarked, dependencyToBeInstalled, processedDependencies, request))
|
if (!DepthFirstVisit(dependency, temporarilyMarked, permanentlyMarked, dependencyToBeInstalled, request))
|
||||||
{
|
{
|
||||||
// if dfs returns false then we have encountered a loop
|
// if dfs returns false then we have encountered a loop
|
||||||
return false;
|
return false;
|
||||||
|
@ -550,9 +549,8 @@
|
||||||
/// Returns the package dependencies of packageItem. We only return the dependencies that are not installed in the destination folder of request
|
/// Returns the package dependencies of packageItem. We only return the dependencies that are not installed in the destination folder of request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageItem"></param>
|
/// <param name="packageItem"></param>
|
||||||
/// <param name="processedDependencies"></param>
|
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
private static IEnumerable<PackageItem> GetPackageDependenciesHelper(PackageItem packageItem, HashSet<string> processedDependencies, NuGetRequest request)
|
private static IEnumerable<PackageItem> GetPackageDependenciesHelper(PackageItem packageItem, NuGetRequest request)
|
||||||
{
|
{
|
||||||
if (packageItem.Package.DependencySetList == null)
|
if (packageItem.Package.DependencySetList == null)
|
||||||
{
|
{
|
||||||
|
@ -569,13 +567,6 @@
|
||||||
|
|
||||||
foreach (var dep in depSet.Dependencies)
|
foreach (var dep in depSet.Dependencies)
|
||||||
{
|
{
|
||||||
var depKey = string.Format(CultureInfo.InvariantCulture, "{0}!#!{1}", dep.Id, dep.DependencyVersion.ToStringSafe());
|
|
||||||
|
|
||||||
if (processedDependencies.Contains(depKey))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the min dependencies version
|
// Get the min dependencies version
|
||||||
string minVersion = dep.DependencyVersion.MinVersion.ToStringSafe();
|
string minVersion = dep.DependencyVersion.MinVersion.ToStringSafe();
|
||||||
|
|
||||||
|
@ -626,8 +617,6 @@
|
||||||
|
|
||||||
if (installed)
|
if (installed)
|
||||||
{
|
{
|
||||||
// already processed this so don't need to do this next time
|
|
||||||
processedDependencies.Add(dep.Id);
|
|
||||||
request.Verbose(String.Format(CultureInfo.CurrentCulture, Messages.AlreadyInstalled, dep.Id));
|
request.Verbose(String.Format(CultureInfo.CurrentCulture, Messages.AlreadyInstalled, dep.Id));
|
||||||
// already have a dependency so move on
|
// already have a dependency so move on
|
||||||
continue;
|
continue;
|
||||||
|
@ -645,9 +634,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the package that is the latest version
|
// Get the package that is the latest version
|
||||||
yield return dependentPackageItem.OrderByDescending(each => each.Version).FirstOrDefault();
|
yield return dependentPackageItem.OrderByDescending(each => each.Version).FirstOrDefault();
|
||||||
|
|
||||||
processedDependencies.Add(depKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Microsoft.PackageManagement.Provider.Utility;
|
using Microsoft.PackageManagement.Provider.Utility;
|
||||||
|
|
||||||
using SemanticVersion = Microsoft.PackageManagement.Provider.Utility.SemanticVersion;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class drives the Request class that is an interface exposed from the PackageManagement Platform to the provider to use.
|
/// This class drives the Request class that is an interface exposed from the PackageManagement Platform to the provider to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -173,10 +171,6 @@
|
||||||
// or $env:programfiles\NuGet\Packages\ if you are an admin.
|
// or $env:programfiles\NuGet\Packages\ if you are an admin.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if UNIX
|
|
||||||
// there is only 1 installation location by default for linux ("HOME/.local/share/powershell/PackageManagement/NuGet/Packages")
|
|
||||||
string basePath = CurrentUserDefaultInstallLocation;
|
|
||||||
#else
|
|
||||||
var scope = (Scope == null) ? null : Scope.Value;
|
var scope = (Scope == null) ? null : Scope.Value;
|
||||||
scope = string.IsNullOrWhiteSpace(scope) ? Constants.AllUsers : scope;
|
scope = string.IsNullOrWhiteSpace(scope) ? Constants.AllUsers : scope;
|
||||||
string basePath;
|
string basePath;
|
||||||
|
@ -198,7 +192,6 @@
|
||||||
Constants.Messages.InstallRequiresCurrentUserScopeParameterForNonAdminUser, AllUserDefaultInstallLocation, CurrentUserDefaultInstallLocation);
|
Constants.Messages.InstallRequiresCurrentUserScopeParameterForNonAdminUser, AllUserDefaultInstallLocation, CurrentUserDefaultInstallLocation);
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!Directory.Exists(basePath))
|
if (!Directory.Exists(basePath))
|
||||||
{
|
{
|
||||||
|
@ -222,11 +215,7 @@
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if CORECLR
|
#if CORECLR
|
||||||
#if UNIX
|
|
||||||
return Path.Combine(Path.GetDirectoryName(Platform.SelectProductNameForDirectory(Platform.XDG_Type.DATA)), "PackageManagement", "NuGet", "Packages");
|
|
||||||
#else
|
|
||||||
return Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "PackageManagement", "NuGet", "Packages");
|
return Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "PackageManagement", "NuGet", "Packages");
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PackageManagement", "NuGet", "Packages");
|
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PackageManagement", "NuGet", "Packages");
|
||||||
#endif
|
#endif
|
||||||
|
@ -239,11 +228,7 @@
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if CORECLR
|
#if CORECLR
|
||||||
#if UNIX
|
|
||||||
return Path.Combine(Path.GetDirectoryName(Platform.SelectProductNameForDirectory(Platform.XDG_Type.DATA)), "PackageManagement", "NuGet", "Packages");
|
|
||||||
#else
|
|
||||||
return Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "NuGet", "Packages");
|
return Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "NuGet", "Packages");
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "NuGet", "Packages");
|
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "NuGet", "Packages");
|
||||||
#endif
|
#endif
|
||||||
|
@ -1304,11 +1289,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#if UNIX
|
|
||||||
var appdataFolder = Path.GetDirectoryName(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CONFIG));
|
|
||||||
#else
|
|
||||||
var appdataFolder = Environment.GetEnvironmentVariable("appdata");
|
var appdataFolder = Environment.GetEnvironmentVariable("appdata");
|
||||||
#endif
|
|
||||||
_configurationFileLocation = Path.Combine(appdataFolder, "NuGet", NuGetConstant.SettingsFileName);
|
_configurationFileLocation = Path.Combine(appdataFolder, "NuGet", NuGetConstant.SettingsFileName);
|
||||||
|
|
||||||
//create directory if does not exist
|
//create directory if does not exist
|
||||||
|
|
|
@ -19,12 +19,6 @@
|
||||||
throw new ArgumentNullException("packageSource");
|
throw new ArgumentNullException("packageSource");
|
||||||
}
|
}
|
||||||
|
|
||||||
// we cannot call new uri on file path on linux because it will error out
|
|
||||||
if (System.IO.Directory.Exists(packageSource))
|
|
||||||
{
|
|
||||||
return new LocalPackageRepository(packageSource, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
Uri uri = new Uri(packageSource);
|
Uri uri = new Uri(packageSource);
|
||||||
|
|
||||||
if (uri.IsFile)
|
if (uri.IsFile)
|
||||||
|
|
|
@ -11,8 +11,6 @@ namespace Microsoft.PackageManagement.NuGetProvider
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
|
|
||||||
using SemanticVersion = Microsoft.PackageManagement.Provider.Utility.SemanticVersion;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Package provider to the PackageManagement Platform.
|
/// A Package provider to the PackageManagement Platform.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -92,5 +90,3 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -29,7 +27,6 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
using Microsoft.PackageManagement.Provider.Utility;
|
using Microsoft.PackageManagement.Provider.Utility;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using ErrorCategory = PackageManagement.Internal.ErrorCategory;
|
using ErrorCategory = PackageManagement.Internal.ErrorCategory;
|
||||||
using SemanticVersion = Microsoft.PackageManagement.Provider.Utility.SemanticVersion;
|
|
||||||
|
|
||||||
internal static class ExePackageInstaller
|
internal static class ExePackageInstaller
|
||||||
{
|
{
|
||||||
|
@ -592,6 +589,4 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
// TODO do we need to support save-package for executable packages?
|
// TODO do we need to support save-package for executable packages?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -27,7 +25,6 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
using Microsoft.PackageManagement.Provider.Utility;
|
using Microsoft.PackageManagement.Provider.Utility;
|
||||||
using ErrorCategory = PackageManagement.Internal.ErrorCategory;
|
using ErrorCategory = PackageManagement.Internal.ErrorCategory;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using SemanticVersion = Microsoft.PackageManagement.Provider.Utility.SemanticVersion;
|
|
||||||
|
|
||||||
internal static class NupkgInstaller {
|
internal static class NupkgInstaller {
|
||||||
|
|
||||||
|
@ -235,6 +232,4 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
using System;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -9,8 +7,6 @@ using Microsoft.PackageManagement.Provider.Utility;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
using SemanticVersion = Microsoft.PackageManagement.Provider.Utility.SemanticVersion;
|
|
||||||
|
|
||||||
namespace Microsoft.PackageManagement.PackageSourceListProvider
|
namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
{
|
{
|
||||||
internal static class JsonParser
|
internal static class JsonParser
|
||||||
|
@ -140,7 +136,7 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException(string.Format("'{0}' is not referencd but not defined in the file '{1}'", dep.Name, package.FilePath));
|
throw new FileFormatException(string.Format("'{0}' is not referencd but not defined in the file '{1}'", dep.Name, package.FilePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -347,9 +343,9 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
|
|
||||||
if (!uri.IsFile)
|
if (!uri.IsFile)
|
||||||
{
|
{
|
||||||
if (uri.Scheme != "https")
|
if (uri.Scheme != Uri.UriSchemeHttps)
|
||||||
{
|
{
|
||||||
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Messages.UriSchemeNotSupported, uri.Scheme, "https"));
|
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Messages.UriSchemeNotSupported, uri.Scheme, Uri.UriSchemeHttps));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,5 +490,3 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -940,6 +938,4 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,5 +1,3 @@
|
||||||
#if !UNIX
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -34,7 +32,6 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
using Microsoft.PackageManagement.Implementation;
|
using Microsoft.PackageManagement.Implementation;
|
||||||
using Microsoft.PackageManagement.Internal.Api;
|
using Microsoft.PackageManagement.Internal.Api;
|
||||||
using Microsoft.PackageManagement.Provider.Utility;
|
using Microsoft.PackageManagement.Provider.Utility;
|
||||||
using SemanticVersion = Microsoft.PackageManagement.Provider.Utility.SemanticVersion;
|
|
||||||
|
|
||||||
public abstract class PackageSourceListRequest : Request {
|
public abstract class PackageSourceListRequest : Request {
|
||||||
|
|
||||||
|
@ -1076,6 +1073,4 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -172,5 +170,3 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -43,5 +41,3 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -199,6 +197,4 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -53,5 +51,3 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -301,5 +299,3 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#if !UNIX
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -212,6 +210,4 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,4 +1,3 @@
|
||||||
#if !UNIX
|
|
||||||
|
|
||||||
namespace Microsoft.PackageManagement.PackageSourceListProvider
|
namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
{
|
{
|
||||||
|
@ -160,5 +159,3 @@ namespace Microsoft.PackageManagement.PackageSourceListProvider
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -857,11 +857,6 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
Version maximumVersion,
|
Version maximumVersion,
|
||||||
ProviderOption providerOption = ProviderOption.LatestVersion) {
|
ProviderOption providerOption = ProviderOption.LatestVersion) {
|
||||||
|
|
||||||
#if PORTABLE
|
|
||||||
return Enumerable.Empty<string>();
|
|
||||||
#else
|
|
||||||
//We don't need to scan provider assemblies on corepowershell.
|
|
||||||
|
|
||||||
//if provider is installed in providername\version format
|
//if provider is installed in providername\version format
|
||||||
var providerFolder = ProviderAssembliesLocation.Distinct(new PathEqualityComparer(PathCompareOption.Full)).SelectMany(Directory.EnumerateDirectories);
|
var providerFolder = ProviderAssembliesLocation.Distinct(new PathEqualityComparer(PathCompareOption.Full)).SelectMany(Directory.EnumerateDirectories);
|
||||||
|
|
||||||
|
@ -967,20 +962,16 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return all providers under the providerAssemblies folder
|
//Return all providers under the providerAssemblies folder
|
||||||
internal IEnumerable<string> AllProvidersFromProviderAssembliesLocation(IHostApi request) {
|
internal IEnumerable<string> AllProvidersFromProviderAssembliesLocation(IHostApi request) {
|
||||||
#if !PORTABLE
|
|
||||||
// don't need this for core powershell
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
return ScanAllProvidersFromProviderAssembliesLocation(request, null, null, null, null, ProviderOption.AllProvider).WhereNotNull().ToArray();
|
return ScanAllProvidersFromProviderAssembliesLocation(request, null, null, null, null, ProviderOption.AllProvider).WhereNotNull().ToArray();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
request.Debug(ex.Message);
|
request.Debug(ex.Message);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return Enumerable.Empty<string>();
|
return Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,8 +979,6 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
//return the providers with latest version under the providerAssemblies folder
|
//return the providers with latest version under the providerAssemblies folder
|
||||||
//This method only gets called during the initialization, i.e. LoadProviders().
|
//This method only gets called during the initialization, i.e. LoadProviders().
|
||||||
private IEnumerable<string> ProvidersWithLatestVersionFromProviderAssembliesLocation(IHostApi request) {
|
private IEnumerable<string> ProvidersWithLatestVersionFromProviderAssembliesLocation(IHostApi request) {
|
||||||
#if !PORTABLE
|
|
||||||
// don't need this for core powershell
|
|
||||||
try {
|
try {
|
||||||
var providerPaths = ScanAllProvidersFromProviderAssembliesLocation(request, null, null, null, null, ProviderOption.LatestVersion).WhereNotNull().ToArray();
|
var providerPaths = ScanAllProvidersFromProviderAssembliesLocation(request, null, null, null, null, ProviderOption.LatestVersion).WhereNotNull().ToArray();
|
||||||
|
|
||||||
|
@ -1022,8 +1011,6 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
{
|
{
|
||||||
request.Debug(ex.Message);
|
request.Debug(ex.Message);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return Enumerable.Empty<string>();
|
return Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,14 +1029,28 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
.Concat(GetProvidersFromRegistry(Registry.LocalMachine, "SOFTWARE\\MICROSOFT\\PACKAGEMANAGEMENT"))
|
.Concat(GetProvidersFromRegistry(Registry.LocalMachine, "SOFTWARE\\MICROSOFT\\PACKAGEMANAGEMENT"))
|
||||||
.Concat(GetProvidersFromRegistry(Registry.CurrentUser, "SOFTWARE\\MICROSOFT\\PACKAGEMANAGEMENT"));
|
.Concat(GetProvidersFromRegistry(Registry.CurrentUser, "SOFTWARE\\MICROSOFT\\PACKAGEMANAGEMENT"));
|
||||||
|
|
||||||
|
providerAssemblies = providerAssemblies.Concat(ProvidersWithLatestVersionFromProviderAssembliesLocation(request));
|
||||||
|
|
||||||
|
#if DEEP_DEBUG
|
||||||
|
providerAssemblies = providerAssemblies.ToArray();
|
||||||
|
|
||||||
|
foreach (var each in providerAssemblies) {
|
||||||
|
request.Debug("possible assembly: {0}".format(each));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// find modules that have manifests
|
||||||
|
// todo: expand this out to validate the assembly is ok for this instance of PackageManagement.
|
||||||
|
providerAssemblies = providerAssemblies.Where(each => Manifest.LoadFrom(each).Any(manifest => Swidtag.IsSwidtag(manifest) && new Swidtag(manifest).IsApplicable(new Hashtable())));
|
||||||
|
|
||||||
|
// add inbox assemblies (don't require manifests, because they are versioned with the core)
|
||||||
|
|
||||||
#if !COMMUNITY_BUILD
|
#if !COMMUNITY_BUILD
|
||||||
// todo: these should just be strong-named references. for now, just load them from the same directory.
|
// todo: these should just be strong-named references. for now, just load them from the same directory.
|
||||||
providerAssemblies = providerAssemblies.Concat(new[] {
|
providerAssemblies = providerAssemblies.Concat(new[] {
|
||||||
Path.Combine(BaseDir, "Microsoft.PackageManagement.MetaProvider.PowerShell.dll"),
|
Path.Combine(BaseDir, "Microsoft.PackageManagement.MetaProvider.PowerShell.dll"),
|
||||||
Path.Combine(BaseDir, "Microsoft.PackageManagement.ArchiverProviders.dll"),
|
Path.Combine(BaseDir, "Microsoft.PackageManagement.ArchiverProviders.dll"),
|
||||||
Path.Combine(BaseDir, "Microsoft.PackageManagement.CoreProviders.dll"),
|
Path.Combine(BaseDir, "Microsoft.PackageManagement.CoreProviders.dll"),
|
||||||
Path.Combine(BaseDir, "Microsoft.PackageManagement.NuGetProvider.dll"),
|
|
||||||
Path.Combine(BaseDir, "Microsoft.PackageManagement.PackageSourceListProvider.dll"),
|
|
||||||
#if !CORECLR
|
#if !CORECLR
|
||||||
Path.Combine(BaseDir, "Microsoft.PackageManagement.MsuProvider.dll"),
|
Path.Combine(BaseDir, "Microsoft.PackageManagement.MsuProvider.dll"),
|
||||||
Path.Combine(BaseDir, "Microsoft.PackageManagement.MsiProvider.dll")
|
Path.Combine(BaseDir, "Microsoft.PackageManagement.MsiProvider.dll")
|
||||||
|
@ -1057,6 +1058,14 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if DEEP_DEBUG
|
||||||
|
providerAssemblies = providerAssemblies.ToArray();
|
||||||
|
|
||||||
|
foreach (var each in providerAssemblies) {
|
||||||
|
request.Debug("possible assembly with manifest: {0}".format(each));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
providerAssemblies = providerAssemblies.OrderByDescending(each => {
|
providerAssemblies = providerAssemblies.OrderByDescending(each => {
|
||||||
try {
|
try {
|
||||||
// try to get a version from the file first
|
// try to get a version from the file first
|
||||||
|
@ -1602,4 +1611,4 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -81,7 +81,6 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
/// <param name="providerPath"></param>
|
/// <param name="providerPath"></param>
|
||||||
public void SetSwidTag(string providerPath)
|
public void SetSwidTag(string providerPath)
|
||||||
{
|
{
|
||||||
#if !UNIX
|
|
||||||
if (!string.IsNullOrWhiteSpace(providerPath))
|
if (!string.IsNullOrWhiteSpace(providerPath))
|
||||||
{
|
{
|
||||||
// check whether there is swidtag attached to the provider path
|
// check whether there is swidtag attached to the provider path
|
||||||
|
@ -93,7 +92,6 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
SetSwidTag(new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), swid));
|
SetSwidTag(new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), swid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> SupportedFileExtensions {
|
public IEnumerable<string> SupportedFileExtensions {
|
||||||
|
@ -209,4 +207,4 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
return new DynamicOptionRequestObject(this, requestObject, request => Provider.GetDynamicOptions(category.ToString(), request), category);
|
return new DynamicOptionRequestObject(this, requestObject, request => Provider.GetDynamicOptions(category.ToString(), request), category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -176,13 +176,9 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
|
|
||||||
Debug(request, "Calling 'ProviderService::IsSignedAndTrusted, '{0}'", filename);
|
Debug(request, "Calling 'ProviderService::IsSignedAndTrusted, '{0}'", filename);
|
||||||
|
|
||||||
// we are not using this function anywhere
|
|
||||||
#if !UNIX
|
|
||||||
var wtd = new WinTrustData(filename);
|
var wtd = new WinTrustData(filename);
|
||||||
|
|
||||||
var result = NativeMethods.WinVerifyTrust(new IntPtr(-1), new Guid("{00AAC56B-CD44-11d0-8CC2-00C04FC295EE}"), wtd);
|
var result = NativeMethods.WinVerifyTrust(new IntPtr(-1), new Guid("{00AAC56B-CD44-11d0-8CC2-00C04FC295EE}"), wtd);
|
||||||
return result == WinVerifyTrustResult.Success;
|
return result == WinVerifyTrustResult.Success;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -190,14 +186,9 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
public int StartProcess(string filename, string arguments, bool requiresElevation, out string standardOutput, IRequest requestObject) {
|
public int StartProcess(string filename, string arguments, bool requiresElevation, out string standardOutput, IRequest requestObject) {
|
||||||
Process p = new Process();
|
Process p = new Process();
|
||||||
|
|
||||||
#if !CORECLR
|
if (requiresElevation) {
|
||||||
if (requiresElevation)
|
|
||||||
{
|
|
||||||
p.StartInfo.UseShellExecute = true;
|
p.StartInfo.UseShellExecute = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
p.StartInfo.UseShellExecute = false;
|
p.StartInfo.UseShellExecute = false;
|
||||||
p.StartInfo.RedirectStandardOutput = true;
|
p.StartInfo.RedirectStandardOutput = true;
|
||||||
}
|
}
|
||||||
|
@ -242,4 +233,4 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
|
||||||
return request.Debug(request.FormatMessageString(messageText, args));
|
return request.Debug(request.FormatMessageString(messageText, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,11 +19,9 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
|
|
||||||
internal static class ExceptionExtensions {
|
internal static class ExceptionExtensions {
|
||||||
public static void Dump(this Exception e) {
|
public static void Dump(this Exception e) {
|
||||||
#if !UNIX
|
|
||||||
var text = string.Format(CultureInfo.CurrentCulture, "{0}/{1}\r\n{2}", e.GetType().Name, e.Message, e.StackTrace);
|
var text = string.Format(CultureInfo.CurrentCulture, "{0}/{1}\r\n{2}", e.GetType().Name, e.Message, e.StackTrace);
|
||||||
// for now, this is the only way we'll see exceptions in the wild.
|
// for now, this is the only way we'll see exceptions in the wild.
|
||||||
NativeMethods.OutputDebugString(text);
|
NativeMethods.OutputDebugString(text);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DETAILED_DEBUG
|
#if DETAILED_DEBUG
|
||||||
|
@ -37,4 +35,4 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -74,14 +74,14 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
// move the file to the tmp file
|
// move the file to the tmp file
|
||||||
// and tell the OS to remove it next reboot.
|
// and tell the OS to remove it next reboot.
|
||||||
var tmpFilename = GenerateTemporaryFileOrDirectoryNameInTempDirectory() + ".delete_me"; // generates a unique filename but not a file!
|
var tmpFilename = GenerateTemporaryFileOrDirectoryNameInTempDirectory() + ".delete_me"; // generates a unique filename but not a file!
|
||||||
File.Move(location, tmpFilename);
|
MoveFileOverwrite(location, tmpFilename);
|
||||||
|
|
||||||
if (File.Exists(location) || Directory.Exists(location)) {
|
if (File.Exists(location) || Directory.Exists(location)) {
|
||||||
// of course, if the tmpFile isn't on the same volume as the location, this doesn't work.
|
// of course, if the tmpFile isn't on the same volume as the location, this doesn't work.
|
||||||
// then, last ditch effort, let's rename it in the current directory
|
// then, last ditch effort, let's rename it in the current directory
|
||||||
// and then we can hide it and mark it for cleanup .
|
// and then we can hide it and mark it for cleanup .
|
||||||
tmpFilename = Path.Combine(Path.GetDirectoryName(location), "tmp." + CounterHex + "." + Path.GetFileName(location) + ".delete_me");
|
tmpFilename = Path.Combine(Path.GetDirectoryName(location), "tmp." + CounterHex + "." + Path.GetFileName(location) + ".delete_me");
|
||||||
File.Move(location, tmpFilename);
|
MoveFileOverwrite(location, tmpFilename);
|
||||||
if (File.Exists(tmpFilename) || Directory.Exists(location)) {
|
if (File.Exists(tmpFilename) || Directory.Exists(location)) {
|
||||||
// hide the file for convenience.
|
// hide the file for convenience.
|
||||||
File.SetAttributes(tmpFilename, File.GetAttributes(tmpFilename) | FileAttributes.Hidden);
|
File.SetAttributes(tmpFilename, File.GetAttributes(tmpFilename) | FileAttributes.Hidden);
|
||||||
|
@ -89,7 +89,7 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we mark the locked file to be deleted upon next reboot (or until another coapp app gets there)
|
// Now we mark the locked file to be deleted upon next reboot (or until another coapp app gets there)
|
||||||
File.Move(File.Exists(tmpFilename) ? tmpFilename : location, null);
|
MoveFileOverwrite(File.Exists(tmpFilename) ? tmpFilename : location, null);
|
||||||
} catch {
|
} catch {
|
||||||
// really. Hmmm.
|
// really. Hmmm.
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,19 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// File move abstraction that can be implemented to handle non-windows platforms
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceFile"></param>
|
||||||
|
/// <param name="destinationFile"></param>
|
||||||
|
public static void MoveFileOverwrite(string sourceFile, string destinationFile) {
|
||||||
|
NativeMethods.MoveFileEx(sourceFile, destinationFile, MoveFileFlags.ReplaceExisting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MoveFileAtNextBoot(string sourceFile, string destinationFile) {
|
||||||
|
NativeMethods.MoveFileEx(sourceFile, destinationFile, MoveFileFlags.DelayUntilReboot);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a temporary file name in the temp directory so we can move file that we cannot delete over
|
/// Create a temporary file name in the temp directory so we can move file that we cannot delete over
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -186,7 +199,6 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
|
|
||||||
// is this a unc path?
|
// is this a unc path?
|
||||||
if (string.IsNullOrWhiteSpace(pathUri.Host)) {
|
if (string.IsNullOrWhiteSpace(pathUri.Host)) {
|
||||||
#if !UNIX
|
|
||||||
// no, this is a drive:\path path
|
// no, this is a drive:\path path
|
||||||
// use API to resolve out the drive letter to see if it is a remote
|
// use API to resolve out the drive letter to see if it is a remote
|
||||||
var drive = pathUri.Segments[1].Replace('/', '\\'); // the zero segment is always just '/'
|
var drive = pathUri.Segments[1].Replace('/', '\\'); // the zero segment is always just '/'
|
||||||
|
@ -200,7 +212,6 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
return pathUri.Segments.Skip(2).Aggregate(sb.ToString().Trim(), (current, item) => current + item);
|
return pathUri.Segments.Skip(2).Aggregate(sb.ToString().Trim(), (current, item) => current + item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// not a remote (or resovably-remote) path or
|
// not a remote (or resovably-remote) path or
|
||||||
// it is already a path that is in it's correct form (via localpath)
|
// it is already a path that is in it's correct form (via localpath)
|
||||||
|
@ -254,4 +265,4 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
|
||||||
return new Regex(@"-+").Replace(new Regex(@"[^\d\w\[\]_\-\.\ ]").Replace(input, "-"), "-").Replace(" ", "");
|
return new Regex(@"-+").Replace(new Regex(@"[^\d\w\[\]_\-\.\ ]").Replace(input, "-"), "-").Replace(" ", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,14 +27,10 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool IsElevated {
|
public static bool IsElevated {
|
||||||
get {
|
get {
|
||||||
#if UNIX
|
|
||||||
return string.Equals(System.Environment.GetEnvironmentVariable("SUDO_UID"), "1000");
|
|
||||||
#else
|
|
||||||
var id = WindowsIdentity.GetCurrent();
|
var id = WindowsIdentity.GetCurrent();
|
||||||
var principal = new WindowsPrincipal(id);
|
var principal = new WindowsPrincipal(id);
|
||||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,6 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
|
||||||
internal static class Manifest {
|
internal static class Manifest {
|
||||||
private static readonly byte[] _utf = {0xef, 0xbb, 0xbf};
|
private static readonly byte[] _utf = {0xef, 0xbb, 0xbf};
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
public static IEnumerable<XElement> LoadFrom(string filename) {
|
public static IEnumerable<XElement> LoadFrom(string filename) {
|
||||||
var manifests = new List<XElement>();
|
var manifests = new List<XElement>();
|
||||||
|
|
||||||
|
@ -69,7 +68,5 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
|
||||||
}
|
}
|
||||||
return manifests;
|
return manifests;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,6 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
namespace Microsoft.PackageManagement.Internal.Utility.Platform {
|
namespace Microsoft.PackageManagement.Internal.Utility.Platform {
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
@ -335,6 +334,4 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
|
||||||
public static extern void OutputDebugString(string debugMessageText);
|
public static extern void OutputDebugString(string debugMessageText);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ namespace Microsoft.PackageManagement.Provider.Utility
|
||||||
#if !CORECLR
|
#if !CORECLR
|
||||||
Marshal.ZeroFreeGlobalAllocUnicode(value);
|
Marshal.ZeroFreeGlobalAllocUnicode(value);
|
||||||
#else
|
#else
|
||||||
Marshal.ZeroFreeCoTaskMemUnicode(value);
|
SecureStringMarshal.ZeroFreeCoTaskMemUnicode(value);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,4 +250,4 @@ namespace Microsoft.PackageManagement.Provider.Utility
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:s="clr-namespace:System;assembly=mscorlib"
|
xmlns:s="clr-namespace:System;assembly=mscorlib"
|
||||||
xmlns:conv="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
|
xmlns:conv="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
|
||||||
xmlns:sap="clr-namespace:System.Activities.Presentation"
|
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
|
||||||
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
|
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<swd:ActivityDesigner x:Class="Microsoft.PowerShell.Activities.PipelineDesigner"
|
<swd:ActivityDesigner x:Class="Microsoft.PowerShell.Activities.PipelineDesigner"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:swd="clr-namespace:System.Activities.Presentation">
|
xmlns:swd="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|
|
@ -3,15 +3,19 @@ using System.Collections;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Resources;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Microsoft.PowerShell.Commands.Diagnostics.Common
|
namespace Microsoft.PowerShell.Commands.Diagnostics.Common
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static class CommonUtilities
|
internal class CommonUtilities
|
||||||
{
|
{
|
||||||
#if !CORECLR
|
//
|
||||||
|
// No-op private ctor to prevent the default ctor from getting generated.
|
||||||
|
// This class is intended to only have static members.
|
||||||
|
//
|
||||||
|
private CommonUtilities() {
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// StringArrayToString helper converts a string array into a comma-separated string.
|
// StringArrayToString helper converts a string array into a comma-separated string.
|
||||||
// Note this has only limited use, individual strings cannot have commas.
|
// Note this has only limited use, individual strings cannot have commas.
|
||||||
|
@ -112,13 +116,7 @@ namespace Microsoft.PowerShell.Commands.Diagnostics.Common
|
||||||
}
|
}
|
||||||
return formatError;
|
return formatError;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
public static ResourceManager GetResourceManager()
|
|
||||||
{
|
|
||||||
// this naming pattern is dictated by the dotnet cli
|
|
||||||
return new ResourceManager("Microsoft.PowerShell.Commands.Diagnostics.resources.GetEventResources", typeof(CommonUtilities).GetTypeInfo().Assembly);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace Microsoft.PowerShell.Commands.GetCounter
|
||||||
{
|
{
|
||||||
internal PerformanceCounterSampleSet()
|
internal PerformanceCounterSampleSet()
|
||||||
{
|
{
|
||||||
_resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
|
_resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal PerformanceCounterSampleSet (DateTime timeStamp,
|
internal PerformanceCounterSampleSet (DateTime timeStamp,
|
||||||
|
|
|
@ -152,7 +152,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
protected override void BeginProcessing()
|
protected override void BeginProcessing()
|
||||||
{
|
{
|
||||||
|
|
||||||
_resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
|
_resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Determine the OS version: this cmdlet requires Windows 7
|
// Determine the OS version: this cmdlet requires Windows 7
|
||||||
|
|
|
@ -203,7 +203,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
//
|
//
|
||||||
protected override void BeginProcessing()
|
protected override void BeginProcessing()
|
||||||
{
|
{
|
||||||
_resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
|
_resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
_pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6);
|
_pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6);
|
||||||
uint res = _pdhHelper.ConnectToDataSource();
|
uint res = _pdhHelper.ConnectToDataSource();
|
||||||
|
|
|
@ -27,9 +27,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
[Cmdlet(VerbsCommon.Get, "WinEvent" , DefaultParameterSetName = "GetLogSet", HelpUri = "http://go.microsoft.com/fwlink/?LinkID=138336")]
|
[Cmdlet(VerbsCommon.Get, "WinEvent" , DefaultParameterSetName = "GetLogSet", HelpUri = "http://go.microsoft.com/fwlink/?LinkID=138336")]
|
||||||
public sealed class GetWinEventCommand : PSCmdlet
|
public sealed class GetWinEventCommand : PSCmdlet
|
||||||
{
|
{
|
||||||
/// <summary>
|
//
|
||||||
/// ListLog parameter
|
// ListLog parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Position = 0,
|
Position = 0,
|
||||||
Mandatory = true,
|
Mandatory = true,
|
||||||
|
@ -51,9 +51,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
private string[] _listLog = {"*"};
|
private string[] _listLog = {"*"};
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// GetLog parameter
|
// GetLog parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Position = 0,
|
Position = 0,
|
||||||
ParameterSetName="GetLogSet",
|
ParameterSetName="GetLogSet",
|
||||||
|
@ -73,9 +73,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private string[] _logName = {"*"};
|
private string[] _logName = {"*"};
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// ListProvider parameter
|
// ListProvider parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Position = 0,
|
Position = 0,
|
||||||
Mandatory = true,
|
Mandatory = true,
|
||||||
|
@ -99,9 +99,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private string[] _listProvider = {"*"};
|
private string[] _listProvider = {"*"};
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// ProviderName parameter
|
// ProviderName parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Position = 0,
|
Position = 0,
|
||||||
Mandatory = true,
|
Mandatory = true,
|
||||||
|
@ -123,9 +123,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private string[] _providerName;
|
private string[] _providerName;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// Path parameter
|
// Path parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Position = 0,
|
Position = 0,
|
||||||
Mandatory = true,
|
Mandatory = true,
|
||||||
|
@ -147,9 +147,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private string[] _path;
|
private string[] _path;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// MaxEvents parameter
|
// MaxEvents parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName="FileSet",
|
ParameterSetName="FileSet",
|
||||||
ValueFromPipeline = false,
|
ValueFromPipeline = false,
|
||||||
|
@ -188,9 +188,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
private Int64 _maxEvents = -1;
|
private Int64 _maxEvents = -1;
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// ComputerName parameter
|
// ComputerName parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName="ListProviderSet",
|
ParameterSetName="ListProviderSet",
|
||||||
HelpMessageBaseName = "GetEventResources",
|
HelpMessageBaseName = "GetEventResources",
|
||||||
|
@ -225,9 +225,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
private string _computerName = string.Empty;
|
private string _computerName = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// Credential parameter
|
// Credential parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(ParameterSetName="ListProviderSet")]
|
[Parameter(ParameterSetName="ListProviderSet")]
|
||||||
[Parameter(ParameterSetName="GetProviderSet")]
|
[Parameter(ParameterSetName="GetProviderSet")]
|
||||||
[Parameter(ParameterSetName="ListLogSet")]
|
[Parameter(ParameterSetName="ListLogSet")]
|
||||||
|
@ -244,9 +244,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private PSCredential _credential = PSCredential.Empty;
|
private PSCredential _credential = PSCredential.Empty;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// FilterXPath parameter
|
// FilterXPath parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName="FileSet",
|
ParameterSetName="FileSet",
|
||||||
ValueFromPipeline = false,
|
ValueFromPipeline = false,
|
||||||
|
@ -270,9 +270,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
private string _filter = "*";
|
private string _filter = "*";
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// FilterXml parameter
|
// FilterXml parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Position = 0,
|
Position = 0,
|
||||||
Mandatory = true,
|
Mandatory = true,
|
||||||
|
@ -294,9 +294,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private XmlDocument _xmlQuery = null;
|
private XmlDocument _xmlQuery = null;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// FilterHashtable parameter
|
// FilterHashtable parameter
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Position = 0,
|
Position = 0,
|
||||||
Mandatory = true,
|
Mandatory = true,
|
||||||
|
@ -317,9 +317,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
private Hashtable[] _selector;
|
private Hashtable[] _selector;
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// Force switch
|
// Force switch
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(ParameterSetName="ListLogSet")]
|
[Parameter(ParameterSetName="ListLogSet")]
|
||||||
[Parameter(ParameterSetName="GetProviderSet")]
|
[Parameter(ParameterSetName="GetProviderSet")]
|
||||||
[Parameter(ParameterSetName="GetLogSet")]
|
[Parameter(ParameterSetName="GetLogSet")]
|
||||||
|
@ -332,9 +332,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
private SwitchParameter _force;
|
private SwitchParameter _force;
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// Oldest switch
|
// Oldest switch
|
||||||
/// </summary>
|
//
|
||||||
[Parameter(ParameterSetName="FileSet")]
|
[Parameter(ParameterSetName="FileSet")]
|
||||||
[Parameter(ParameterSetName="GetProviderSet")]
|
[Parameter(ParameterSetName="GetProviderSet")]
|
||||||
[Parameter(ParameterSetName="GetLogSet")]
|
[Parameter(ParameterSetName="GetLogSet")]
|
||||||
|
@ -391,18 +391,18 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private const string hashkey_data_lc="data";
|
private const string hashkey_data_lc="data";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// BeginProcessing() is invoked once per pipeline: we will load System.Core.dll here
|
// BeginProcessing() is invoked once per pipeline: we will load System.Core.dll here
|
||||||
/// </summary>
|
//
|
||||||
protected override void BeginProcessing()
|
protected override void BeginProcessing()
|
||||||
{
|
{
|
||||||
_resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
|
_resourceMgr = new ResourceManager("GetEventResources", typeof(GetWinEventCommand).GetTypeInfo().Assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// EndProcessing() is invoked once per pipeline
|
// EndProcessing() is invoked once per pipeline
|
||||||
/// </summary>
|
//
|
||||||
protected override void EndProcessing()
|
protected override void EndProcessing()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -426,10 +426,10 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
//
|
||||||
/// ProcessRecord() override.
|
// ProcessRecord() override.
|
||||||
/// This is the main entry point for the cmdlet.
|
// This is the main entry point for the cmdlet.
|
||||||
/// </summary>
|
//
|
||||||
protected override void ProcessRecord()
|
protected override void ProcessRecord()
|
||||||
{
|
{
|
||||||
switch (ParameterSetName)
|
switch (ParameterSetName)
|
||||||
|
|
|
@ -189,7 +189,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
//
|
//
|
||||||
protected override void BeginProcessing()
|
protected override void BeginProcessing()
|
||||||
{
|
{
|
||||||
_resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
|
_resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly());
|
||||||
_pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6);
|
_pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Microsoft.PowerShell.Commands
|
namespace Microsoft.PowerShell.Commands
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
|
@ -28,7 +28,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
private const string TemplateTag = "template";
|
private const string TemplateTag = "template";
|
||||||
private const string DataTag = "data";
|
private const string DataTag = "data";
|
||||||
private ResourceManager _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
|
private ResourceManager _resourceMgr = new ResourceManager("GetEventResources", typeof(NewWinEventCommand).GetTypeInfo().Assembly);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -479,7 +479,6 @@ namespace Microsoft.Powershell.Commands.GetCounter.PdhNative
|
||||||
/// A helper reading in a Unicode string with embedded NULLs and splitting it into a StringCollection.
|
/// A helper reading in a Unicode string with embedded NULLs and splitting it into a StringCollection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="strNative"></param>
|
/// <param name="strNative"></param>
|
||||||
/// <param name="strSize"></param>
|
|
||||||
/// <param name="strColl"></param>
|
/// <param name="strColl"></param>
|
||||||
|
|
||||||
private void ReadPdhMultiString(ref IntPtr strNative, Int32 strSize, ref StringCollection strColl)
|
private void ReadPdhMultiString(ref IntPtr strNative, Int32 strSize, ref StringCollection strColl)
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace Microsoft.PowerShell.Cim
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Marshal.ZeroFreeCoTaskMemUnicode(plainTextString);
|
ClrFacade.ZeroFreeCoTaskMemUnicode(plainTextString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#if !UNIX
|
|
||||||
|
|
||||||
/********************************************************************++
|
/********************************************************************++
|
||||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
--********************************************************************/
|
--********************************************************************/
|
||||||
|
@ -7386,5 +7384,3 @@ $result
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}//End namespace
|
}//End namespace
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -996,12 +996,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Change the current working directory
|
// Change the current working directory
|
||||||
if (string.IsNullOrEmpty(Path))
|
|
||||||
{
|
|
||||||
// If user just typed 'cd', go to FileSystem provider home directory
|
|
||||||
Path = SessionState.Internal.GetSingleProvider(Commands.FileSystemProvider.ProviderName).Home;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = SessionState.Path.SetLocation(Path, CmdletProviderContext);
|
result = SessionState.Path.SetLocation(Path, CmdletProviderContext);
|
||||||
}
|
}
|
||||||
catch (PSNotSupportedException notSupported)
|
catch (PSNotSupportedException notSupported)
|
||||||
|
@ -3568,22 +3562,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldRecurse = Recurse;
|
bool shouldRecurse = Recurse;
|
||||||
bool treatAsFile = false;
|
if (!Recurse && hasChildren)
|
||||||
try
|
|
||||||
{
|
|
||||||
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(providerPath);
|
|
||||||
if (!Platform.IsWindows && di != null && (di.Attributes & System.IO.FileAttributes.ReparsePoint) != 0)
|
|
||||||
{
|
|
||||||
shouldRecurse = false;
|
|
||||||
treatAsFile = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (System.IO.FileNotFoundException)
|
|
||||||
{
|
|
||||||
// not a directory
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!treatAsFile && !Recurse && hasChildren)
|
|
||||||
{
|
{
|
||||||
// Get the localized prompt string
|
// Get the localized prompt string
|
||||||
|
|
||||||
|
|
|
@ -540,7 +540,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
if (SessionState.Path.IsProviderQualified(path))
|
if (SessionState.Path.IsProviderQualified(path))
|
||||||
{
|
{
|
||||||
int index = path.IndexOf("::", StringComparison.CurrentCulture);
|
int index = path.IndexOf("::", StringComparison.CurrentCulture);
|
||||||
|
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
// remove the qualifier
|
// remove the qualifier
|
||||||
|
@ -553,12 +553,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
if (SessionState.Path.IsPSAbsolute(path, out driveName))
|
if (SessionState.Path.IsPSAbsolute(path, out driveName))
|
||||||
{
|
{
|
||||||
var driveNameLength = driveName.Length;
|
// Remove the drive name and colon
|
||||||
if (path.Length > (driveNameLength + 1) && path[driveNameLength] == ':')
|
|
||||||
{
|
result = path.Substring(driveName.Length + 1);
|
||||||
// Remove the drive name and colon
|
|
||||||
result = path.Substring(driveNameLength + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -866,9 +866,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private static string RetrieveProcessUserName(Process process, Cmdlet cmdlet)
|
private static string RetrieveProcessUserName(Process process, Cmdlet cmdlet)
|
||||||
{
|
{
|
||||||
string userName = null;
|
string userName = null;
|
||||||
#if UNIX
|
|
||||||
userName = Platform.NonWindowsGetUserFromPid(process.Id);
|
|
||||||
#else
|
|
||||||
IntPtr tokenUserInfo = IntPtr.Zero;
|
IntPtr tokenUserInfo = IntPtr.Zero;
|
||||||
IntPtr processTokenHandler = IntPtr.Zero;
|
IntPtr processTokenHandler = IntPtr.Zero;
|
||||||
|
|
||||||
|
@ -958,7 +955,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,7 +1362,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Platform.IsWindows && !Force)
|
if (!Force)
|
||||||
{
|
{
|
||||||
// Check if the process is owned by current user
|
// Check if the process is owned by current user
|
||||||
if (!IsProcessOwnedByCurrentUser(process))
|
if (!IsProcessOwnedByCurrentUser(process))
|
||||||
|
@ -2005,9 +2001,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
private SwitchParameter _UseNewEnvironment;
|
private SwitchParameter _UseNewEnvironment;
|
||||||
|
|
||||||
private StreamWriter OutputWriter;
|
|
||||||
private StreamWriter ErrorWriter;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region overrides
|
#region overrides
|
||||||
|
@ -2101,10 +2094,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
//LoadUserProfile.
|
//LoadUserProfile.
|
||||||
if (Platform.IsWindows)
|
startInfo.LoadUserProfile = _loaduserprofile;
|
||||||
{
|
|
||||||
startInfo.LoadUserProfile = _loaduserprofile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_credential != null)
|
if (_credential != null)
|
||||||
{
|
{
|
||||||
|
@ -2196,30 +2186,8 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//Starts the Process
|
//Starts the Process
|
||||||
Process process;
|
Process process = start(startInfo);
|
||||||
if (Platform.IsWindows)
|
|
||||||
{
|
|
||||||
process = start(startInfo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
process = new Process();
|
|
||||||
process.StartInfo = startInfo;
|
|
||||||
SetupInputOutputRedirection(process);
|
|
||||||
process.Start();
|
|
||||||
if (process.StartInfo.RedirectStandardOutput)
|
|
||||||
{
|
|
||||||
process.BeginOutputReadLine();
|
|
||||||
}
|
|
||||||
if (process.StartInfo.RedirectStandardError)
|
|
||||||
{
|
|
||||||
process.BeginErrorReadLine();
|
|
||||||
}
|
|
||||||
if (process.StartInfo.RedirectStandardInput)
|
|
||||||
{
|
|
||||||
WriteToStandardInput(process);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Wait and Passthru Implementation.
|
//Wait and Passthru Implementation.
|
||||||
|
|
||||||
if (_passthru.IsPresent)
|
if (_passthru.IsPresent)
|
||||||
|
@ -2242,27 +2210,20 @@ namespace Microsoft.PowerShell.Commands
|
||||||
{
|
{
|
||||||
if (!process.HasExited)
|
if (!process.HasExited)
|
||||||
{
|
{
|
||||||
if (Platform.IsWindows)
|
waithandle = new ManualResetEvent(false);
|
||||||
|
|
||||||
|
// Create and start the job object
|
||||||
|
ProcessCollection jobObject = new ProcessCollection();
|
||||||
|
if (jobObject.AssignProcessToJobObject(process))
|
||||||
{
|
{
|
||||||
waithandle = new ManualResetEvent(false);
|
// Wait for the job object to finish
|
||||||
|
jobObject.WaitOne(waithandle);
|
||||||
// Create and start the job object
|
|
||||||
ProcessCollection jobObject = new ProcessCollection();
|
|
||||||
if (jobObject.AssignProcessToJobObject(process))
|
|
||||||
{
|
|
||||||
// Wait for the job object to finish
|
|
||||||
jobObject.WaitOne(waithandle);
|
|
||||||
}
|
|
||||||
else if (!process.HasExited)
|
|
||||||
{
|
|
||||||
// WinBlue: 27537 Start-Process -Wait doesn't work in a remote session on Windows 7 or lower.
|
|
||||||
process.Exited += new EventHandler(myProcess_Exited);
|
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
process.WaitForExit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (!process.HasExited)
|
||||||
{
|
{
|
||||||
|
// WinBlue: 27537 Start-Process -Wait doesn't work in a remote session on Windows 7 or lower.
|
||||||
|
process.Exited += new EventHandler(myProcess_Exited);
|
||||||
|
process.EnableRaisingEvents = true;
|
||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2321,104 +2282,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StdOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
|
|
||||||
{
|
|
||||||
if (!String.IsNullOrEmpty(outLine.Data))
|
|
||||||
{
|
|
||||||
OutputWriter.WriteLine(outLine.Data);
|
|
||||||
OutputWriter.Flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StdErrorHandler(object sendingProcess, DataReceivedEventArgs outLine)
|
|
||||||
{
|
|
||||||
if (!String.IsNullOrEmpty(outLine.Data))
|
|
||||||
{
|
|
||||||
ErrorWriter.WriteLine(outLine.Data);
|
|
||||||
ErrorWriter.Flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ExitHandler(object sendingProcess, System.EventArgs e)
|
|
||||||
{
|
|
||||||
// To avoid a race condition with Std*Handler, let's wait a bit before closing the streams
|
|
||||||
// System.Timer is not supported in CoreCLR, so let's spawn a new thread to do the wait
|
|
||||||
|
|
||||||
Thread delayedStreamClosing = new Thread(StreamClosing);
|
|
||||||
delayedStreamClosing.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StreamClosing()
|
|
||||||
{
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
if (OutputWriter != null)
|
|
||||||
{
|
|
||||||
OutputWriter.Dispose();
|
|
||||||
}
|
|
||||||
if (ErrorWriter != null)
|
|
||||||
{
|
|
||||||
ErrorWriter.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupInputOutputRedirection(Process p)
|
|
||||||
{
|
|
||||||
if (_redirectstandardinput != null)
|
|
||||||
{
|
|
||||||
p.StartInfo.RedirectStandardInput = true;
|
|
||||||
_redirectstandardinput = ResolveFilePath(_redirectstandardinput);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p.StartInfo.RedirectStandardInput = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_redirectstandardoutput != null)
|
|
||||||
{
|
|
||||||
p.StartInfo.RedirectStandardOutput = true;
|
|
||||||
_redirectstandardoutput = ResolveFilePath(_redirectstandardoutput);
|
|
||||||
p.OutputDataReceived += new DataReceivedEventHandler(StdOutputHandler);
|
|
||||||
|
|
||||||
// Can't do StreamWriter(string) in coreCLR
|
|
||||||
OutputWriter = new StreamWriter(new FileStream(_redirectstandardoutput, FileMode.Create));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p.StartInfo.RedirectStandardOutput = false;
|
|
||||||
OutputWriter = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_redirectstandarderror != null)
|
|
||||||
{
|
|
||||||
p.StartInfo.RedirectStandardError = true;
|
|
||||||
_redirectstandarderror = ResolveFilePath(_redirectstandarderror);
|
|
||||||
p.ErrorDataReceived += new DataReceivedEventHandler(StdErrorHandler);
|
|
||||||
|
|
||||||
// Can't do StreamWriter(string) in coreCLR
|
|
||||||
ErrorWriter = new StreamWriter(new FileStream(_redirectstandarderror, FileMode.Create));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p.StartInfo.RedirectStandardError = false;
|
|
||||||
ErrorWriter = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.EnableRaisingEvents = true;
|
|
||||||
p.Exited += new EventHandler(ExitHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WriteToStandardInput(Process p)
|
|
||||||
{
|
|
||||||
StreamWriter writer = p.StandardInput;
|
|
||||||
using (StreamReader reader = new StreamReader(new FileStream(_redirectstandardinput, FileMode.Open)))
|
|
||||||
{
|
|
||||||
string line = reader.ReadToEnd();
|
|
||||||
writer.WriteLine(line);
|
|
||||||
}
|
|
||||||
writer.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Process StartWithCreateProcess(ProcessStartInfo startinfo)
|
private Process StartWithCreateProcess(ProcessStartInfo startinfo)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2578,7 +2441,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
{
|
{
|
||||||
if (password != IntPtr.Zero)
|
if (password != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Marshal.ZeroFreeCoTaskMemUnicode(password);
|
ClrFacade.ZeroFreeCoTaskMemUnicode(password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//end of if
|
}//end of if
|
||||||
|
|
|
@ -2230,7 +2230,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
{
|
{
|
||||||
if (IntPtr.Zero != password)
|
if (IntPtr.Zero != password)
|
||||||
{
|
{
|
||||||
Marshal.ZeroFreeCoTaskMemUnicode(password);
|
ClrFacade.ZeroFreeCoTaskMemUnicode(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IntPtr.Zero != hService)
|
if (IntPtr.Zero != hService)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#if !UNIX
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
@ -862,5 +860,3 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1059,37 +1059,23 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private static PortableExecutableReference ObjectImplementationAssemblyReference =
|
private static PortableExecutableReference ObjectImplementationAssemblyReference =
|
||||||
MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location);
|
MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location);
|
||||||
|
|
||||||
private static PortableExecutableReference MscorlibAssemblyReference =
|
private static PortableExecutableReference ObjectDeclaredAssemblyReference =
|
||||||
MetadataReference.CreateFromFile(Assembly.Load(new AssemblyName("mscorlib")).Location);
|
MetadataReference.CreateFromFile(System.IO.Path.Combine(FrameworkFolder, "System.Runtime.dll"));
|
||||||
|
|
||||||
// This assembly should be System.Runtime.dll
|
// CoreCLR RC2 bits don't have SecureString. We are using a separate assembly with SecureString implementation.
|
||||||
private static PortableExecutableReference SystemRuntimeAssemblyReference =
|
|
||||||
MetadataReference.CreateFromFile(ClrFacade.GetAssemblies(typeof(object).FullName).First().Location);
|
|
||||||
|
|
||||||
// SecureString is defined in a separate assembly.
|
|
||||||
// This fact is an implementation detail and should not require the user to specify one more assembly,
|
// This fact is an implementation detail and should not require the user to specify one more assembly,
|
||||||
// if they want to use SecureString in Add-Type -TypeDefinition.
|
// if they want to use SecureString in Add-Type -TypeDefinition.
|
||||||
// So this assembly should be in the default assemblies list to provide the best experience.
|
// So this assembly should be in the default assemblies list to provide the best experience.
|
||||||
|
//
|
||||||
|
// TODO: This reference should be removed, if we take CoreCLR version that has SecureString implementation.
|
||||||
private static PortableExecutableReference SecureStringAssemblyReference =
|
private static PortableExecutableReference SecureStringAssemblyReference =
|
||||||
MetadataReference.CreateFromFile(typeof(System.Security.SecureString).GetTypeInfo().Assembly.Location);
|
MetadataReference.CreateFromFile(typeof(System.Security.SecureString).GetTypeInfo().Assembly.Location);
|
||||||
|
|
||||||
|
private static MetadataReference[] defaultAssemblies = new MetadataReference[]
|
||||||
// These assemlbies are always automatically added to ReferencedAssemblies.
|
|
||||||
private static PortableExecutableReference[] autoReferencedAssemblies = new PortableExecutableReference[]
|
|
||||||
{
|
{
|
||||||
MscorlibAssemblyReference,
|
|
||||||
SystemRuntimeAssemblyReference,
|
|
||||||
SecureStringAssemblyReference,
|
|
||||||
ObjectImplementationAssemblyReference
|
|
||||||
};
|
|
||||||
|
|
||||||
// These assemlbies are used, when ReferencedAssemblies parameter is not specified.
|
|
||||||
private static PortableExecutableReference[] defaultAssemblies = new PortableExecutableReference[]
|
|
||||||
{
|
|
||||||
MscorlibAssemblyReference,
|
|
||||||
SystemRuntimeAssemblyReference,
|
|
||||||
SecureStringAssemblyReference,
|
|
||||||
ObjectImplementationAssemblyReference,
|
ObjectImplementationAssemblyReference,
|
||||||
|
ObjectDeclaredAssemblyReference,
|
||||||
|
SecureStringAssemblyReference,
|
||||||
MetadataReference.CreateFromFile(typeof(PSObject).GetTypeInfo().Assembly.Location)
|
MetadataReference.CreateFromFile(typeof(PSObject).GetTypeInfo().Assembly.Location)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1161,7 +1147,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
// First try by strong name
|
// First try by strong name
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
loadedAssembly = Assembly.Load(new AssemblyName(assemblyName));
|
loadedAssembly = System.Reflection.Assembly.Load(new AssemblyName(assemblyName));
|
||||||
}
|
}
|
||||||
// Generates a FileNotFoundException if you can't load the strong type.
|
// Generates a FileNotFoundException if you can't load the strong type.
|
||||||
// So we'll try from the short name.
|
// So we'll try from the short name.
|
||||||
|
@ -1231,8 +1217,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
if (referencedAssembliesSpecified)
|
if (referencedAssembliesSpecified)
|
||||||
{
|
{
|
||||||
var tempReferences = ReferencedAssemblies.Select(a => MetadataReference.CreateFromFile(ResolveReferencedAssembly(a))).ToList();
|
var tempReferences = ReferencedAssemblies.Select(a => MetadataReference.CreateFromFile(ResolveReferencedAssembly(a))).ToList();
|
||||||
tempReferences.AddRange(autoReferencedAssemblies);
|
tempReferences.Add(ObjectImplementationAssemblyReference);
|
||||||
|
tempReferences.Add(ObjectDeclaredAssemblyReference);
|
||||||
|
tempReferences.Add(SecureStringAssemblyReference);
|
||||||
references = tempReferences.ToArray();
|
references = tempReferences.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1944,7 +1931,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
{
|
{
|
||||||
foreach(string path in paths)
|
foreach(string path in paths)
|
||||||
{
|
{
|
||||||
generatedTypes.AddRange(ClrFacade.LoadFrom(path).GetTypes());
|
generatedTypes.AddRange(System.Reflection.Assembly.LoadFrom(path).GetTypes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Load the assembly by name
|
// Load the assembly by name
|
||||||
|
@ -2062,7 +2049,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
// First try by strong name
|
// First try by strong name
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
loadedAssembly = Assembly.Load(assemblyName);
|
loadedAssembly = System.Reflection.Assembly.Load(assemblyName);
|
||||||
}
|
}
|
||||||
// Generates a FileNotFoundException if you can't load the strong type.
|
// Generates a FileNotFoundException if you can't load the strong type.
|
||||||
// So we'll try from the short name.
|
// So we'll try from the short name.
|
||||||
|
@ -2074,7 +2061,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
// Next, try an exact match
|
// Next, try an exact match
|
||||||
if (StrongNames.Value.ContainsKey(assemblyName))
|
if (StrongNames.Value.ContainsKey(assemblyName))
|
||||||
{
|
{
|
||||||
return Assembly.Load(StrongNames.Value[assemblyName]);
|
return System.Reflection.Assembly.Load(StrongNames.Value[assemblyName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the assembly name doesn't contain wildcards, return null. The caller generates an error here.
|
// If the assembly name doesn't contain wildcards, return null. The caller generates an error here.
|
||||||
|
@ -2117,7 +2104,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Otherwise, load the assembly.
|
// Otherwise, load the assembly.
|
||||||
return Assembly.Load(matchedStrongName);
|
return System.Reflection.Assembly.Load(matchedStrongName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ConcurrentDictionary<string, string> InitializeStrongNameDictionary()
|
private static ConcurrentDictionary<string, string> InitializeStrongNameDictionary()
|
||||||
|
|
|
@ -294,11 +294,18 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
CultureInfo currentCulture = culture;
|
CultureInfo currentCulture = culture;
|
||||||
|
StringBuilder stringBuilder;
|
||||||
string filePath;
|
string filePath;
|
||||||
string fullFileName = fileName + ".psd1";
|
|
||||||
while (currentCulture != null && !String.IsNullOrEmpty(currentCulture.Name))
|
while (currentCulture != null && !String.IsNullOrEmpty(currentCulture.Name))
|
||||||
{
|
{
|
||||||
filePath = Path.Combine(dir, currentCulture.Name, fullFileName);
|
stringBuilder = new StringBuilder(dir);
|
||||||
|
stringBuilder.Append("\\");
|
||||||
|
stringBuilder.Append(currentCulture.Name);
|
||||||
|
stringBuilder.Append("\\");
|
||||||
|
stringBuilder.Append(fileName);
|
||||||
|
stringBuilder.Append(".psd1");
|
||||||
|
|
||||||
|
filePath = stringBuilder.ToString();
|
||||||
|
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
|
@ -308,7 +315,12 @@ namespace Microsoft.PowerShell.Commands
|
||||||
currentCulture = currentCulture.Parent;
|
currentCulture = currentCulture.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath = Path.Combine(dir, fullFileName);
|
stringBuilder = new StringBuilder(dir);
|
||||||
|
stringBuilder.Append("\\");
|
||||||
|
stringBuilder.Append(fileName);
|
||||||
|
stringBuilder.Append(".psd1");
|
||||||
|
|
||||||
|
filePath = stringBuilder.ToString();
|
||||||
|
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
|
@ -318,11 +330,11 @@ namespace Microsoft.PowerShell.Commands
|
||||||
InvalidOperationException ioe =
|
InvalidOperationException ioe =
|
||||||
PSTraceSource.NewInvalidOperationException(
|
PSTraceSource.NewInvalidOperationException(
|
||||||
ImportLocalizedDataStrings.CannotFindPsd1File,
|
ImportLocalizedDataStrings.CannotFindPsd1File,
|
||||||
fullFileName,
|
fileName + ".psd1",
|
||||||
Path.Combine(dir, culture.Name)
|
dir + "\\" + culture.Name + "\\"
|
||||||
);
|
);
|
||||||
WriteError(new ErrorRecord(ioe, "ImportLocalizedData", ErrorCategory.ObjectNotFound,
|
WriteError(new ErrorRecord(ioe, "ImportLocalizedData", ErrorCategory.ObjectNotFound,
|
||||||
Path.Combine(dir, culture.Name, fullFileName)));
|
dir + "\\" + culture.Name + "\\" + fileName + ".psd1"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
/// Returns the base name of the file containing the matching line.
|
/// Returns the base name of the file containing the matching line.
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// It will be the string "InputStream" if the object came from the input stream.
|
/// It will be the string "InputStream" if the object came from the input stream.
|
||||||
/// This is a readonly property calculated from the path. <see cref="Path"/>
|
/// This is a readonly propery calculated from <paramref name="Path"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The file name</value>
|
/// <value>The file name</value>
|
||||||
|
|
|
@ -261,7 +261,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private SwitchParameter usessl;
|
private SwitchParameter usessl;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the Port to be used on the server. <see cref="SmtpServer"/>
|
/// Specifies the Port to be used on <paramref name="SmtpServer"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Value must be greater than zero.
|
/// Value must be greater than zero.
|
||||||
|
|
|
@ -117,28 +117,21 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
if ( ShouldProcess( dateToUse.ToString() ) )
|
if ( ShouldProcess( dateToUse.ToString() ) )
|
||||||
{
|
{
|
||||||
if (Platform.IsWindows)
|
#pragma warning disable 56523
|
||||||
|
|
||||||
|
if (!NativeMethods.SetLocalTime(ref systemTime))
|
||||||
{
|
{
|
||||||
#pragma warning disable 56523
|
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||||
|
|
||||||
if (!NativeMethods.SetLocalTime(ref systemTime))
|
|
||||||
{
|
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
||||||
}
|
|
||||||
|
|
||||||
// MSDN says to call this twice to account for changes
|
|
||||||
// between DST
|
|
||||||
if (!NativeMethods.SetLocalTime(ref systemTime))
|
|
||||||
{
|
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 56523
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// MSDN says to call this twice to account for changes
|
||||||
|
// between DST
|
||||||
|
if (!NativeMethods.SetLocalTime(ref systemTime))
|
||||||
{
|
{
|
||||||
Platform.NonWindowsSetDate(dateToUse);
|
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning restore 56523
|
||||||
}
|
}
|
||||||
|
|
||||||
//output DateTime object wrapped in an PSObject with DisplayHint attached
|
//output DateTime object wrapped in an PSObject with DisplayHint attached
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#if !CORECLR
|
|
||||||
|
|
||||||
/********************************************************************++
|
/********************************************************************++
|
||||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
--********************************************************************/
|
--********************************************************************/
|
||||||
|
@ -508,4 +506,3 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
|
@ -12,9 +12,7 @@ using System.Collections;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
#if !CORECLR
|
|
||||||
using mshtml;
|
using mshtml;
|
||||||
#endif
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace Microsoft.PowerShell.Commands
|
namespace Microsoft.PowerShell.Commands
|
||||||
|
@ -465,12 +463,9 @@ namespace Microsoft.PowerShell.Commands
|
||||||
/// needed if an HtmlDocument will be created shortly.</param>
|
/// needed if an HtmlDocument will be created shortly.</param>
|
||||||
protected bool VerifyInternetExplorerAvailable(bool checkComObject)
|
protected bool VerifyInternetExplorerAvailable(bool checkComObject)
|
||||||
{
|
{
|
||||||
// TODO: Remove this code once the dependecy on mshtml has been resolved.
|
|
||||||
#if CORECLR
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
bool isInternetExplorerConfigurationComplete = false;
|
bool isInternetExplorerConfigurationComplete = false;
|
||||||
// Check for IE for both PS Full and PS Core on windows.
|
|
||||||
|
#if !LINUX // Check for IE for both PS Full and PS Core on windows.
|
||||||
// The registry key DisableFirstRunCustomize can exits at one of the following path.
|
// The registry key DisableFirstRunCustomize can exits at one of the following path.
|
||||||
// IE uses the same decending orider (as mentioned) to check for the presence of this key.
|
// IE uses the same decending orider (as mentioned) to check for the presence of this key.
|
||||||
// If the value of DisableFirstRunCustomize key is set to greater than zero then Run first
|
// If the value of DisableFirstRunCustomize key is set to greater than zero then Run first
|
||||||
|
@ -524,12 +519,15 @@ namespace Microsoft.PowerShell.Commands
|
||||||
isInternetExplorerConfigurationComplete = false;
|
isInternetExplorerConfigurationComplete = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !CORECLR
|
||||||
// Throw exception in PS Full only
|
// Throw exception in PS Full only
|
||||||
if (!isInternetExplorerConfigurationComplete)
|
if (!isInternetExplorerConfigurationComplete)
|
||||||
throw new NotSupportedException(WebCmdletStrings.IEDomNotSupported);
|
throw new NotSupportedException(WebCmdletStrings.IEDomNotSupported);
|
||||||
return isInternetExplorerConfigurationComplete;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return isInternetExplorerConfigurationComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Uri PrepareUri(Uri uri)
|
private Uri PrepareUri(Uri uri)
|
||||||
|
|
|
@ -93,12 +93,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
// The first input string does not represent a complete Json Syntax.
|
// The first input string does not represent a complete Json Syntax.
|
||||||
// Hence consider the the entire input as a single Json content.
|
// Hence consider the the entire input as a single Json content.
|
||||||
}
|
}
|
||||||
#if CORECLR
|
|
||||||
catch (Newtonsoft.Json.JsonSerializationException)
|
|
||||||
{
|
|
||||||
// we use another serializer for CORECLR implementation
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (successfullyConverted)
|
if (successfullyConverted)
|
||||||
{
|
{
|
||||||
for (int index = 1; index < inputObjectBuffer.Count; index++)
|
for (int index = 1; index < inputObjectBuffer.Count; index++)
|
||||||
|
|
|
@ -60,13 +60,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
this.RawContent = raw.ToString();
|
this.RawContent = raw.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Dispose the the instance of the class.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
content = psBody.BaseObject;
|
content = psBody.BaseObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: This needs to be enable after the dependency on mshtml is resolved.
|
|
||||||
var html = content as HtmlWebResponseObject;
|
var html = content as HtmlWebResponseObject;
|
||||||
if (html != null)
|
if (html != null)
|
||||||
{
|
{
|
||||||
|
@ -237,9 +236,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (content is FormObject)
|
else if (content is FormObject)
|
||||||
*/
|
|
||||||
|
|
||||||
if (content is FormObject)
|
|
||||||
{
|
{
|
||||||
FormObject form = content as FormObject;
|
FormObject form = content as FormObject;
|
||||||
SetRequestContent(request, form.Fields);
|
SetRequestContent(request, form.Fields);
|
||||||
|
@ -535,7 +531,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Helper Methods
|
#endregion Helper Methods
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -17,17 +17,14 @@ namespace Microsoft.PowerShell.Commands
|
||||||
WebResponseObject output;
|
WebResponseObject output;
|
||||||
if (WebResponseHelper.IsText(response))
|
if (WebResponseHelper.IsText(response))
|
||||||
{
|
{
|
||||||
output = new BasicHtmlWebResponseObject(response, responseStream);
|
if (useBasicParsing)
|
||||||
|
{
|
||||||
// TODO: This code needs to be enable after the dependency on mshtml is resolved.
|
output = new BasicHtmlWebResponseObject(response, responseStream);
|
||||||
//if (useBasicParsing)
|
}
|
||||||
//{
|
else
|
||||||
// output = new BasicHtmlWebResponseObject(response, responseStream);
|
{
|
||||||
//}
|
output = new HtmlWebResponseObject(response, responseStream, executionContext);
|
||||||
//else
|
}
|
||||||
//{
|
|
||||||
// output = new HtmlWebResponseObject(response, responseStream, executionContext);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
set { DescendingOrder = value; }
|
set { DescendingOrder = value; }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This param specifies if only unique objects are filtered.
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
[Parameter]
|
[Parameter]
|
||||||
|
@ -37,7 +37,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove duplicates.
|
/// Remove Duplicated from <paramref name="sortedList"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void RemoveDuplicates(OrderByProperty orderByProperty)
|
private static void RemoveDuplicates(OrderByProperty orderByProperty)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,3 +58,4 @@ namespace Microsoft.PowerShell.Commands
|
||||||
#endregion Cmdlet code
|
#endregion Cmdlet code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,12 @@ Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
--********************************************************************/
|
--********************************************************************/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Security.Permissions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System.Management.Automation.Host;
|
using System.Management.Automation.Host;
|
||||||
using System.Management.Automation.Internal.Host;
|
using System.Management.Automation.Internal.Host;
|
||||||
|
|
||||||
#if CORECLR
|
|
||||||
using Microsoft.PowerShell.CoreClr.Stubs;
|
|
||||||
#else
|
|
||||||
using System.Security.Permissions;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Microsoft.PowerShell.Commands
|
namespace Microsoft.PowerShell.Commands
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -68,9 +63,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
[SecurityPermission(SecurityAction.LinkDemand)]
|
[SecurityPermission(SecurityAction.LinkDemand)]
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
#if CORECLR
|
|
||||||
base.Dispose(disposing);
|
|
||||||
#else
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
@ -82,10 +74,8 @@ namespace Microsoft.PowerShell.Commands
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !CORECLR
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Closes the dialog and then calls the base class Close
|
/// Closes the dialog and then calls the base class Close
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -96,7 +86,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
base.Close();
|
base.Close();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endregion TraceListener constructors and disposer
|
#endregion TraceListener constructors and disposer
|
||||||
|
|
||||||
|
@ -154,3 +143,4 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
} // class PSHostTraceListener
|
} // class PSHostTraceListener
|
||||||
} // namespace System.Management.Automation
|
} // namespace System.Management.Automation
|
||||||
|
|
||||||
|
|
|
@ -185,3 +185,4 @@ namespace Microsoft.PowerShell.Commands
|
||||||
#endregion Cmdlet code
|
#endregion Cmdlet code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,3 +133,4 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
foreach (FileStream fileStream in this.FileStreams)
|
foreach (FileStream fileStream in this.FileStreams)
|
||||||
{
|
{
|
||||||
fileStream.Flush();
|
fileStream.Flush();
|
||||||
fileStream.Dispose();
|
fileStream.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
@ -572,3 +572,4 @@ namespace Microsoft.PowerShell.Commands
|
||||||
private Collection<PSTraceSource> matchingSources = new Collection<PSTraceSource>();
|
private Collection<PSTraceSource> matchingSources = new Collection<PSTraceSource>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
true))
|
true))
|
||||||
{
|
{
|
||||||
listenerToRemove.Flush();
|
listenerToRemove.Flush();
|
||||||
listenerToRemove.Dispose();
|
listenerToRemove.Close();
|
||||||
source.Listeners.RemoveAt(index);
|
source.Listeners.RemoveAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
foreach (TraceListener listener in pair.Value)
|
foreach (TraceListener listener in pair.Value)
|
||||||
{
|
{
|
||||||
listener.Flush();
|
listener.Flush();
|
||||||
listener.Dispose();
|
listener.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storedTraceSourceState.Clear ();
|
storedTraceSourceState.Clear ();
|
||||||
|
@ -631,3 +631,4 @@ namespace Microsoft.PowerShell.Commands
|
||||||
#endregion stored state
|
#endregion stored state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,12 +353,6 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
switchKey = switchKey.Substring(1);
|
switchKey = switchKey.Substring(1);
|
||||||
|
|
||||||
// chop off the second dash so we're agnostic wrt specifying - or --
|
|
||||||
if (!String.IsNullOrEmpty(switchKey) && SpecialCharacters.IsDash(switchKey[0]))
|
|
||||||
{
|
|
||||||
switchKey = switchKey.Substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?"))
|
if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?"))
|
||||||
{
|
{
|
||||||
showHelp = true;
|
showHelp = true;
|
||||||
|
@ -483,10 +477,7 @@ namespace Microsoft.PowerShell
|
||||||
string exceptionMessage = null;
|
string exceptionMessage = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Normalize slashes
|
file = Path.GetFullPath(args[i]);
|
||||||
file = args[i].Replace(StringLiterals.AlternatePathSeparator,
|
|
||||||
StringLiterals.DefaultPathSeparator);
|
|
||||||
file = Path.GetFullPath(file);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#if !UNIX
|
|
||||||
/********************************************************************++
|
/********************************************************************++
|
||||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
--********************************************************************/
|
--********************************************************************/
|
||||||
|
@ -3608,4 +3607,4 @@ namespace Microsoft.PowerShell
|
||||||
private static PSTraceSource tracer = PSTraceSource.GetTracer("ConsoleControl", "Console control methods");
|
private static PSTraceSource tracer = PSTraceSource.GetTracer("ConsoleControl", "Console control methods");
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
#endif
|
|
||||||
|
|
|
@ -180,22 +180,13 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string profileDir;
|
var profileDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
|
||||||
if (Platform.IsWindows)
|
@"\Microsoft\Windows\PowerShell";
|
||||||
{
|
|
||||||
profileDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
|
|
||||||
@"\Microsoft\Windows\PowerShell";
|
|
||||||
|
|
||||||
if (!Directory.Exists(profileDir))
|
if (!Directory.Exists(profileDir))
|
||||||
{
|
|
||||||
Directory.CreateDirectory(profileDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
profileDir = Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE);
|
Directory.CreateDirectory(profileDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClrFacade.SetProfileOptimizationRoot(profileDir);
|
ClrFacade.SetProfileOptimizationRoot(profileDir);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -270,6 +261,7 @@ namespace Microsoft.PowerShell
|
||||||
: "StartupProfileData-NonInteractive");
|
: "StartupProfileData-NonInteractive");
|
||||||
exitCode = theConsoleHost.Run(cpp, !string.IsNullOrEmpty(preStartWarning));
|
exitCode = theConsoleHost.Run(cpp, !string.IsNullOrEmpty(preStartWarning));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -286,32 +278,10 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if UNIX
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// The break handler for the program. Dispatches a break event to the current Executor.
|
/// The break handler for the program. Dispatches a break event to the current Executor.
|
||||||
///
|
///
|
||||||
/// </summary>
|
|
||||||
private static void MyBreakHandler(object sender, ConsoleCancelEventArgs args)
|
|
||||||
{
|
|
||||||
// Set the Cancel property to true to prevent the process from terminating.
|
|
||||||
args.Cancel = true;
|
|
||||||
switch (args.SpecialKey)
|
|
||||||
{
|
|
||||||
case ConsoleSpecialKey.ControlC:
|
|
||||||
SpinUpBreakHandlerThread(false);
|
|
||||||
return;
|
|
||||||
case ConsoleSpecialKey.ControlBreak:
|
|
||||||
// Break into script debugger.
|
|
||||||
BreakIntoDebugger();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// The break handler for the program. Dispatches a break event to the current Executor.
|
|
||||||
///
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="signal"></param>
|
/// <param name="signal"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
@ -347,7 +317,6 @@ namespace Microsoft.PowerShell
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
private static bool BreakIntoDebugger()
|
private static bool BreakIntoDebugger()
|
||||||
{
|
{
|
||||||
|
@ -466,10 +435,8 @@ namespace Microsoft.PowerShell
|
||||||
// call the console APIs directly, instead of ui.rawui.FlushInputHandle, as ui may be finalized
|
// call the console APIs directly, instead of ui.rawui.FlushInputHandle, as ui may be finalized
|
||||||
// already if this thread is lagging behind the main thread.
|
// already if this thread is lagging behind the main thread.
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||||
ConsoleControl.FlushConsoleInputBuffer(handle);
|
ConsoleControl.FlushConsoleInputBuffer(handle);
|
||||||
#endif
|
|
||||||
|
|
||||||
ConsoleHost.SingletonInstance.breakHandlerThread = null;
|
ConsoleHost.SingletonInstance.breakHandlerThread = null;
|
||||||
}
|
}
|
||||||
|
@ -1064,12 +1031,8 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
private void BindBreakHandler()
|
private void BindBreakHandler()
|
||||||
{
|
{
|
||||||
#if UNIX
|
|
||||||
Console.CancelKeyPress += new ConsoleCancelEventHandler(MyBreakHandler);
|
|
||||||
#else
|
|
||||||
breakHandlerGcHandle = GCHandle.Alloc(new ConsoleControl.BreakHandler(MyBreakHandler));
|
breakHandlerGcHandle = GCHandle.Alloc(new ConsoleControl.BreakHandler(MyBreakHandler));
|
||||||
ConsoleControl.AddBreakHandler((ConsoleControl.BreakHandler)breakHandlerGcHandle.Target);
|
ConsoleControl.AddBreakHandler((ConsoleControl.BreakHandler)breakHandlerGcHandle.Target);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !CORECLR // Not used on NanoServer: CurrentDomain.UnhandledException not supported on CoreCLR
|
#if !CORECLR // Not used on NanoServer: CurrentDomain.UnhandledException not supported on CoreCLR
|
||||||
|
@ -1123,11 +1086,9 @@ namespace Microsoft.PowerShell
|
||||||
{
|
{
|
||||||
if (!isDisposed)
|
if (!isDisposed)
|
||||||
{
|
{
|
||||||
#if !UNIX
|
|
||||||
Dbg.Assert(breakHandlerGcHandle != null, "break handler should be set");
|
Dbg.Assert(breakHandlerGcHandle != null, "break handler should be set");
|
||||||
ConsoleControl.RemoveBreakHandler();
|
ConsoleControl.RemoveBreakHandler();
|
||||||
breakHandlerGcHandle.Free();
|
breakHandlerGcHandle.Free();
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isDisposingNotFinalizing)
|
if (isDisposingNotFinalizing)
|
||||||
{
|
{
|
||||||
|
@ -1570,7 +1531,7 @@ namespace Microsoft.PowerShell
|
||||||
{
|
{
|
||||||
// Create and open Runspace with PSReadline.
|
// Create and open Runspace with PSReadline.
|
||||||
defaultImportModulesList = DefaultInitialSessionState.Modules;
|
defaultImportModulesList = DefaultInitialSessionState.Modules;
|
||||||
DefaultInitialSessionState.ImportPSModule(new[] { "PSReadLine" });
|
DefaultInitialSessionState.ImportPSModule(new[] { "PSReadline" });
|
||||||
consoleRunspace = RunspaceFactory.CreateRunspace(this, DefaultInitialSessionState);
|
consoleRunspace = RunspaceFactory.CreateRunspace(this, DefaultInitialSessionState);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2872,9 +2833,7 @@ namespace Microsoft.PowerShell
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private RunspaceRef runspaceRef;
|
private RunspaceRef runspaceRef;
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
private GCHandle breakHandlerGcHandle;
|
private GCHandle breakHandlerGcHandle;
|
||||||
#endif
|
|
||||||
private System.Threading.Thread breakHandlerThread;
|
private System.Threading.Thread breakHandlerThread;
|
||||||
private bool isDisposed;
|
private bool isDisposed;
|
||||||
internal ConsoleHostUserInterface ui;
|
internal ConsoleHostUserInterface ui;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#if !UNIX
|
|
||||||
/********************************************************************++
|
/********************************************************************++
|
||||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
--********************************************************************/
|
--********************************************************************/
|
||||||
|
@ -1500,359 +1499,3 @@ namespace Microsoft.PowerShell
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Managed code only implementation for portability
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Management.Automation;
|
|
||||||
using System.Management.Automation.Runspaces;
|
|
||||||
using System.Management.Automation.Host;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Microsoft.PowerShell
|
|
||||||
{
|
|
||||||
// this is all originally from https://msdn.microsoft.com/en-us/library/ee706570%28v=vs.85%29.aspx
|
|
||||||
|
|
||||||
internal sealed class ConsoleHostRawUserInterface : PSHostRawUserInterface
|
|
||||||
{
|
|
||||||
private ConsoleColor defaultForeground = ConsoleColor.Gray;
|
|
||||||
|
|
||||||
private ConsoleColor defaultBackground = ConsoleColor.Black;
|
|
||||||
|
|
||||||
private ConsoleHostUserInterface parent = null;
|
|
||||||
|
|
||||||
internal ConsoleHostRawUserInterface(ConsoleHostUserInterface mshConsole) : base()
|
|
||||||
{
|
|
||||||
defaultForeground = ForegroundColor;
|
|
||||||
defaultBackground = BackgroundColor;
|
|
||||||
parent = mshConsole;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the background color of the displayed text.
|
|
||||||
/// This maps to the corresponding Console.Background property.
|
|
||||||
/// </summary>
|
|
||||||
public override ConsoleColor BackgroundColor
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Console can return UnknownColor, a private enum, equivalent
|
|
||||||
// to -1. When this is a case, map it instead to our default.
|
|
||||||
return Console.BackgroundColor == (ConsoleColor)(-1)
|
|
||||||
? defaultBackground
|
|
||||||
: Console.BackgroundColor;
|
|
||||||
}
|
|
||||||
set { Console.BackgroundColor = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Make wrap width user-customizable.
|
|
||||||
private static Size WrapSize = new Size(80, 40);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the size of the host buffer.
|
|
||||||
/// </summary>
|
|
||||||
public override Size BufferSize
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Console can return zero when a pseduo-TTY is allocated, which
|
|
||||||
// is useless for us. Instead, map to the wrap size.
|
|
||||||
return Console.BufferWidth == 0 || Console.BufferHeight == 0
|
|
||||||
? WrapSize
|
|
||||||
: new Size(Console.BufferWidth, Console.BufferHeight);
|
|
||||||
}
|
|
||||||
set { Console.SetBufferSize(value.Width, value.Height); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the cursor position.
|
|
||||||
/// </summary>
|
|
||||||
public override Coordinates CursorPosition
|
|
||||||
{
|
|
||||||
get { return new Coordinates(Console.CursorLeft, Console.CursorTop); }
|
|
||||||
set { Console.SetCursorPosition(value.X < 0 ? 0 : value.X,
|
|
||||||
value.Y < 0 ? 0 : value.Y); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the size of the displayed cursor.
|
|
||||||
/// This maps to the corresponding Console.CursorSize property.
|
|
||||||
/// </summary>
|
|
||||||
public override int CursorSize
|
|
||||||
{
|
|
||||||
// Future porting note: this API throws on Windows when output is
|
|
||||||
// redirected, but never throws on Unix because it's fake.
|
|
||||||
get { return Console.CursorSize; }
|
|
||||||
set { Console.CursorSize = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the foreground color of the displayed text.
|
|
||||||
/// This maps to the corresponding Console.ForegroundColor property.
|
|
||||||
/// </summary>
|
|
||||||
public override ConsoleColor ForegroundColor
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Console can return UnknownColor, a private enum, equivalent
|
|
||||||
// to -1. When this is a case, map it instead to our default.
|
|
||||||
return Console.ForegroundColor == (ConsoleColor)(-1)
|
|
||||||
? defaultForeground
|
|
||||||
: Console.ForegroundColor;
|
|
||||||
}
|
|
||||||
set { Console.ForegroundColor = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a value indicating whether the user has pressed a key. This maps
|
|
||||||
/// to the corresponding Console.KeyAvailable property.
|
|
||||||
/// </summary>
|
|
||||||
public override bool KeyAvailable
|
|
||||||
{
|
|
||||||
get { return Console.KeyAvailable; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the dimensions of the largest window that could be rendered in
|
|
||||||
/// the current display, if the buffer was at the least that large.
|
|
||||||
/// This maps to the MaxWindowSize.
|
|
||||||
/// </summary>
|
|
||||||
public override Size MaxPhysicalWindowSize
|
|
||||||
{
|
|
||||||
get { return MaxWindowSize; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the dimensions of the largest window size that can be
|
|
||||||
/// displayed. This maps to the Console.LargestWindowWidth and
|
|
||||||
/// Console.LargestWindowHeight properties to determine the returned
|
|
||||||
/// value of this property.
|
|
||||||
/// </summary>
|
|
||||||
public override Size MaxWindowSize
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Console can return zero when a pseduo-TTY is allocated, which
|
|
||||||
// is useless for us. Instead, map to the wrap size.
|
|
||||||
return Console.LargestWindowWidth == 0 || Console.LargestWindowHeight == 0
|
|
||||||
? WrapSize
|
|
||||||
: new Size(Console.LargestWindowWidth, Console.LargestWindowHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the position of the displayed window. This maps to the
|
|
||||||
/// Console window position APIs to determine the returned value of this
|
|
||||||
/// property.
|
|
||||||
/// </summary>
|
|
||||||
public override Coordinates WindowPosition
|
|
||||||
{
|
|
||||||
get { return new Coordinates(Console.WindowLeft, Console.WindowTop); }
|
|
||||||
set { Console.SetWindowPosition(value.X, value.Y); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the size of the displayed window. This example
|
|
||||||
/// uses the corresponding Console window size APIs to determine the
|
|
||||||
/// returned value of this property.
|
|
||||||
/// </summary>
|
|
||||||
public override Size WindowSize
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Console can return zero when a pseduo-TTY is allocated, which
|
|
||||||
// is useless for us. Instead, map to the wrap size.
|
|
||||||
return Console.WindowWidth == 0 || Console.WindowHeight == 0
|
|
||||||
? WrapSize
|
|
||||||
: new Size(Console.WindowWidth, Console.WindowHeight);
|
|
||||||
}
|
|
||||||
set { Console.SetWindowSize(value.Width, value.Height); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Cached Window Title, for systems that needs it
|
|
||||||
/// </summary>
|
|
||||||
private string title = String.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the title of the displayed window. The example
|
|
||||||
/// maps the Console.Title property to the value of this property.
|
|
||||||
/// </summary>
|
|
||||||
public override string WindowTitle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Console throws an exception on Unix platforms, so we handle
|
|
||||||
// caching and returning the Window title ourselves.
|
|
||||||
return Platform.IsWindows ? Console.Title : title;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Console.Title = value;
|
|
||||||
title = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This API resets the input buffer.
|
|
||||||
/// </summary>
|
|
||||||
public override void FlushInputBuffer()
|
|
||||||
{
|
|
||||||
if (!Console.IsInputRedirected)
|
|
||||||
{
|
|
||||||
Console.OpenStandardInput().Flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ScrollBuffer(int lines)
|
|
||||||
{
|
|
||||||
for (int i=0; i<lines; ++i)
|
|
||||||
{
|
|
||||||
Console.Out.Write('\n');
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal struct COORD
|
|
||||||
{
|
|
||||||
internal short X;
|
|
||||||
|
|
||||||
internal short Y;
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", X, Y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal struct SMALL_RECT
|
|
||||||
{
|
|
||||||
internal short Left;
|
|
||||||
|
|
||||||
internal short Top;
|
|
||||||
|
|
||||||
internal short Right;
|
|
||||||
|
|
||||||
internal short Bottom;
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return String.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", Left, Top, Right, Bottom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This API returns a rectangular region of the screen buffer. In
|
|
||||||
/// this example this functionality is not needed so the method throws
|
|
||||||
/// a NotImplementException exception.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rectangle">Defines the size of the rectangle.</param>
|
|
||||||
/// <returns>Throws a NotImplementedException exception.</returns>
|
|
||||||
public override BufferCell[,] GetBufferContents(Rectangle rectangle)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("The method or operation is not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This API reads a pressed, released, or pressed and released keystroke
|
|
||||||
/// from the keyboard device, blocking processing until a keystroke is
|
|
||||||
/// typed that matches the specified keystroke options.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="options">Unused</param>
|
|
||||||
public override KeyInfo ReadKey(ReadKeyOptions options)
|
|
||||||
{
|
|
||||||
ConsoleKeyInfo key = Console.ReadKey();
|
|
||||||
return new KeyInfo((int)key.Key, key.KeyChar, new ControlKeyStates(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This API crops a region of the screen buffer. In this example
|
|
||||||
/// this functionality is not needed so the method throws a
|
|
||||||
/// NotImplementException exception.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source">The region of the screen to be scrolled.</param>
|
|
||||||
/// <param name="destination">The region of the screen to receive the
|
|
||||||
/// source region contents.</param>
|
|
||||||
/// <param name="clip">The region of the screen to include in the operation.</param>
|
|
||||||
/// <param name="fill">The character and attributes to be used to fill all cell.</param>
|
|
||||||
public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("The method or operation is not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method copies an array of buffer cells into the screen buffer
|
|
||||||
/// at a specified location.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="origin">The parameter used to set the origin where the buffer where begin writing to.</param>
|
|
||||||
/// <param name="contents">The parameter used to contain the contents to be written to the buffer.</param>
|
|
||||||
public override void SetBufferContents(Coordinates origin,
|
|
||||||
BufferCell[,] contents)
|
|
||||||
{
|
|
||||||
//if there are no contents, there is nothing to set the buffer to
|
|
||||||
if (contents == null)
|
|
||||||
{
|
|
||||||
PSTraceSource.NewArgumentNullException("contents");
|
|
||||||
}
|
|
||||||
|
|
||||||
//if the cursor is on the last line, we need to make more space to print the specified buffer
|
|
||||||
if (origin.Y == BufferSize.Height - 1 && origin.X >= BufferSize.Width)
|
|
||||||
{
|
|
||||||
//for each row in the buffer, create a new line
|
|
||||||
int rows = contents.GetLength(0);
|
|
||||||
ScrollBuffer(rows);
|
|
||||||
// for each row in the buffer, move the cursor y up to the beginning of the created blank space
|
|
||||||
// but not above zero
|
|
||||||
if (origin.Y >= rows)
|
|
||||||
{
|
|
||||||
origin.Y -= rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//iterate through the buffer to set
|
|
||||||
foreach (var charitem in contents)
|
|
||||||
{
|
|
||||||
//set the cursor to false to prevent cursor flicker
|
|
||||||
Console.CursorVisible = false;
|
|
||||||
|
|
||||||
//if x is exceeding buffer width, reset to the next line
|
|
||||||
if (origin.X >= BufferSize.Width)
|
|
||||||
{
|
|
||||||
origin.X = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//write the character from contents
|
|
||||||
Console.Out.Write(charitem.Character);
|
|
||||||
|
|
||||||
//advance the character one position
|
|
||||||
origin.X++;
|
|
||||||
}
|
|
||||||
|
|
||||||
//reset the cursor to the original position
|
|
||||||
CursorPosition = origin;
|
|
||||||
//reset the cursor to visible
|
|
||||||
Console.CursorVisible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method copies a given character, foreground color, and background
|
|
||||||
/// color to a region of the screen buffer. In this example this
|
|
||||||
/// functionality is not needed so the method throws a
|
|
||||||
/// NotImplementException exception./// </summary>
|
|
||||||
/// <param name="rectangle">Defines the area to be filled. </param>
|
|
||||||
/// <param name="fill">Defines the fill character.</param>
|
|
||||||
public override void SetBufferContents(Rectangle rectangle, BufferCell fill)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("The method or operation is not implemented.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -14,9 +14,7 @@ using System.Management.Automation.Internal;
|
||||||
using System.Management.Automation.Host;
|
using System.Management.Automation.Host;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
using Dbg = System.Management.Automation.Diagnostics;
|
using Dbg = System.Management.Automation.Diagnostics;
|
||||||
#if !UNIX
|
|
||||||
using ConsoleHandle = Microsoft.Win32.SafeHandles.SafeFileHandle;
|
using ConsoleHandle = Microsoft.Win32.SafeHandles.SafeFileHandle;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Microsoft.PowerShell
|
namespace Microsoft.PowerShell
|
||||||
{
|
{
|
||||||
|
@ -61,15 +59,13 @@ namespace Microsoft.PowerShell
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.rawui = new ConsoleHostRawUserInterface(this);
|
this.rawui = new ConsoleHostRawUserInterface(this);
|
||||||
|
|
||||||
#if UNIX
|
|
||||||
this._supportsVirtualTerminal = true;
|
|
||||||
#else
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Turn on virtual terminal if possible.
|
// Turn on virtual terminal if possible.
|
||||||
|
|
||||||
// This might throw - not sure how exactly (no console), but if it does, we shouldn't fail to start.
|
// This might throw - not sure how exactly (no console), but if it does, we shouldn't fail to start.
|
||||||
var handle = ConsoleControl.GetActiveScreenBufferHandle();
|
var handle = ConsoleControl.GetActiveScreenBufferHandle();
|
||||||
|
|
||||||
var m = ConsoleControl.GetMode(handle);
|
var m = ConsoleControl.GetMode(handle);
|
||||||
if (ConsoleControl.NativeMethods.SetConsoleMode(handle.DangerousGetHandle(), (uint) (m | ConsoleControl.ConsoleModes.VirtualTerminal)))
|
if (ConsoleControl.NativeMethods.SetConsoleMode(handle.DangerousGetHandle(), (uint) (m | ConsoleControl.ConsoleModes.VirtualTerminal)))
|
||||||
{
|
{
|
||||||
|
@ -82,7 +78,6 @@ namespace Microsoft.PowerShell
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
isInteractiveTestToolListening = false;
|
isInteractiveTestToolListening = false;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +233,7 @@ namespace Microsoft.PowerShell
|
||||||
result = ReadLineSafe(true, printToken);
|
result = ReadLineSafe(true, printToken);
|
||||||
}
|
}
|
||||||
SecureString secureResult = result as SecureString;
|
SecureString secureResult = result as SecureString;
|
||||||
System.Management.Automation.Diagnostics.Assert(secureResult != null, "ReadLineSafe did not return a SecureString");
|
Diagnostics.Assert(secureResult != null, "ReadLineSafe did not return a SecureString");
|
||||||
|
|
||||||
return secureResult;
|
return secureResult;
|
||||||
}
|
}
|
||||||
|
@ -251,10 +246,6 @@ namespace Microsoft.PowerShell
|
||||||
/// It also manages the cursor as keys are entered and "backspaced". However, it is possible that
|
/// It also manages the cursor as keys are entered and "backspaced". However, it is possible that
|
||||||
/// while this method is running, the console buffer contents could change. Then, its cursor mgmt
|
/// while this method is running, the console buffer contents could change. Then, its cursor mgmt
|
||||||
/// will likely be messed up.
|
/// will likely be messed up.
|
||||||
///
|
|
||||||
/// Secondary implementation for Unix based on Console.ReadKey(), where
|
|
||||||
/// the advantage is portability through abstraction. Does not support
|
|
||||||
/// arrow key movement, but supports backspace.
|
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///<param name="isSecureString">
|
///<param name="isSecureString">
|
||||||
|
@ -297,21 +288,13 @@ namespace Microsoft.PowerShell
|
||||||
null;
|
null;
|
||||||
SecureString secureResult = new SecureString();
|
SecureString secureResult = new SecureString();
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
#if UNIX
|
|
||||||
bool treatControlCAsInput = Console.TreatControlCAsInput;
|
|
||||||
#else
|
|
||||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||||
ConsoleControl.ConsoleModes originalMode = ConsoleControl.GetMode(handle);
|
ConsoleControl.ConsoleModes originalMode = ConsoleControl.GetMode(handle);
|
||||||
bool isModeChanged = true; // assume ConsoleMode is changed so that if ReadLineSetMode
|
bool isModeChanged = true; // assume ConsoleMode is changed so that if ReadLineSetMode
|
||||||
// fails to return the value correctly, the original mode is
|
// fails to return the value correctly, the original mode is
|
||||||
// restored.
|
// restored.
|
||||||
#endif
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if UNIX
|
|
||||||
Console.TreatControlCAsInput = true;
|
|
||||||
#else
|
|
||||||
// Ensure that we're in the proper line-input mode.
|
// Ensure that we're in the proper line-input mode.
|
||||||
|
|
||||||
ConsoleControl.ConsoleModes desiredMode =
|
ConsoleControl.ConsoleModes desiredMode =
|
||||||
|
@ -338,7 +321,6 @@ namespace Microsoft.PowerShell
|
||||||
isModeChanged = false;
|
isModeChanged = false;
|
||||||
}
|
}
|
||||||
rawui.ClearKeyCache();
|
rawui.ClearKeyCache();
|
||||||
#endif
|
|
||||||
|
|
||||||
Coordinates originalCursorPos = rawui.CursorPosition;
|
Coordinates originalCursorPos = rawui.CursorPosition;
|
||||||
|
|
||||||
|
@ -349,39 +331,22 @@ namespace Microsoft.PowerShell
|
||||||
// end up having a immutable string holding the
|
// end up having a immutable string holding the
|
||||||
// secret in memory.
|
// secret in memory.
|
||||||
//
|
//
|
||||||
#if UNIX
|
|
||||||
ConsoleKeyInfo keyInfo = Console.ReadKey(true);
|
|
||||||
#else
|
|
||||||
uint unused = 0;
|
uint unused = 0;
|
||||||
string key = ConsoleControl.ReadConsole(handle, string.Empty, 1, false, out unused);
|
string key = ConsoleControl.ReadConsole(handle, string.Empty, 1, false, out unused);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNIX
|
|
||||||
// Handle Ctrl-C ending input
|
|
||||||
if (keyInfo.Key == ConsoleKey.C && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control))
|
|
||||||
#else
|
|
||||||
if (string.IsNullOrEmpty(key) || (char)3 == key[0])
|
if (string.IsNullOrEmpty(key) || (char)3 == key[0])
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PipelineStoppedException e = new PipelineStoppedException();
|
PipelineStoppedException e = new PipelineStoppedException();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
#if UNIX
|
|
||||||
if (keyInfo.Key == ConsoleKey.Enter)
|
|
||||||
#else
|
|
||||||
if ((char)13 == key[0])
|
if ((char)13 == key[0])
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// we are done if user presses ENTER key
|
// we are done if user presses ENTER key
|
||||||
//
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if UNIX
|
|
||||||
if (keyInfo.Key == ConsoleKey.Backspace)
|
|
||||||
#else
|
|
||||||
if ((char)8 == key[0])
|
if ((char)8 == key[0])
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// for backspace, remove last char appended
|
// for backspace, remove last char appended
|
||||||
|
@ -397,13 +362,6 @@ namespace Microsoft.PowerShell
|
||||||
WriteBackSpace(originalCursorPos);
|
WriteBackSpace(originalCursorPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if UNIX
|
|
||||||
else if (Char.IsControl(keyInfo.KeyChar))
|
|
||||||
{
|
|
||||||
// blacklist control characters
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -411,19 +369,11 @@ namespace Microsoft.PowerShell
|
||||||
//
|
//
|
||||||
if (isSecureString)
|
if (isSecureString)
|
||||||
{
|
{
|
||||||
#if UNIX
|
|
||||||
secureResult.AppendChar(keyInfo.KeyChar);
|
|
||||||
#else
|
|
||||||
secureResult.AppendChar(key[0]);
|
secureResult.AppendChar(key[0]);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if UNIX
|
|
||||||
result.Append(keyInfo.KeyChar);
|
|
||||||
#else
|
|
||||||
result.Append(key);
|
result.Append(key);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(printTokenString))
|
if (!string.IsNullOrEmpty(printTokenString))
|
||||||
{
|
{
|
||||||
|
@ -433,23 +383,12 @@ namespace Microsoft.PowerShell
|
||||||
}
|
}
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
#if UNIX
|
|
||||||
catch (InvalidOperationException)
|
|
||||||
{
|
|
||||||
// ReadKey() failed so we stop
|
|
||||||
throw new PipelineStoppedException();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
#if UNIX
|
|
||||||
Console.TreatControlCAsInput = treatControlCAsInput;
|
|
||||||
#else
|
|
||||||
if (isModeChanged)
|
if (isModeChanged)
|
||||||
{
|
{
|
||||||
ConsoleControl.SetMode(handle, originalMode);
|
ConsoleControl.SetMode(handle, originalMode);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
WriteLineToConsole();
|
WriteLineToConsole();
|
||||||
PostRead(result.ToString());
|
PostRead(result.ToString());
|
||||||
|
@ -463,7 +402,6 @@ namespace Microsoft.PowerShell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// Handle writing print token with proper cursor adjustment for ReadLineSafe
|
/// Handle writing print token with proper cursor adjustment for ReadLineSafe
|
||||||
|
@ -573,7 +511,7 @@ namespace Microsoft.PowerShell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// If <paramref name="m"/> is set on <paramref name="flagToUnset"/>, unset it and return true;
|
/// If <paramref name="m"/> is set on <paramref name="flagToUnset"/>, unset it and return true;
|
||||||
|
@ -593,6 +531,7 @@ namespace Microsoft.PowerShell
|
||||||
/// false otherwise
|
/// false otherwise
|
||||||
///
|
///
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
|
||||||
private static bool shouldUnsetMode(
|
private static bool shouldUnsetMode(
|
||||||
ConsoleControl.ConsoleModes flagToUnset,
|
ConsoleControl.ConsoleModes flagToUnset,
|
||||||
ref ConsoleControl.ConsoleModes m)
|
ref ConsoleControl.ConsoleModes m)
|
||||||
|
@ -604,14 +543,11 @@ namespace Microsoft.PowerShell
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#region WriteToConsole
|
#region WriteToConsole
|
||||||
|
|
||||||
internal void WriteToConsole(string value, bool transcribeResult)
|
internal void WriteToConsole(string value, bool transcribeResult)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
ConsoleHandle handle = ConsoleControl.GetActiveScreenBufferHandle();
|
ConsoleHandle handle = ConsoleControl.GetActiveScreenBufferHandle();
|
||||||
|
|
||||||
// Ensure that we're in the proper line-output mode. We don't lock here as it does not matter if we
|
// Ensure that we're in the proper line-output mode. We don't lock here as it does not matter if we
|
||||||
|
@ -628,17 +564,12 @@ namespace Microsoft.PowerShell
|
||||||
m |= desiredMode;
|
m |= desiredMode;
|
||||||
ConsoleControl.SetMode(handle, m);
|
ConsoleControl.SetMode(handle, m);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
PreWrite();
|
PreWrite();
|
||||||
|
|
||||||
// This is atomic, so we don't lock here...
|
// This is atomic, so we don't lock here...
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
ConsoleControl.WriteConsole(handle, value);
|
ConsoleControl.WriteConsole(handle, value);
|
||||||
#else
|
|
||||||
Console.Out.Write(value);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isInteractiveTestToolListening && Console.IsOutputRedirected)
|
if (isInteractiveTestToolListening && Console.IsOutputRedirected)
|
||||||
{
|
{
|
||||||
|
@ -1539,9 +1470,9 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// We use System.Environment.NewLine because we are platform-agnostic
|
// We don't use System.Environment.NewLine because we are very platform specific with our use of the win32 console APIs
|
||||||
|
|
||||||
internal static string Crlf = System.Environment.NewLine;
|
internal const string Crlf = "\x000D\x000A";
|
||||||
private const string Tab = "\x0009";
|
private const string Tab = "\x0009";
|
||||||
|
|
||||||
internal enum ReadLineResult
|
internal enum ReadLineResult
|
||||||
|
@ -1688,11 +1619,10 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
private string ReadLineFromConsole(bool endOnTab, string initialContent, bool calledFromPipeline, ref string restOfLine, ref ReadLineResult result)
|
private string ReadLineFromConsole(bool endOnTab, string initialContent, bool calledFromPipeline, ref string restOfLine, ref ReadLineResult result)
|
||||||
{
|
{
|
||||||
|
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||||
PreRead();
|
PreRead();
|
||||||
// Ensure that we're in the proper line-input mode.
|
// Ensure that we're in the proper line-input mode.
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
|
||||||
ConsoleControl.ConsoleModes m = ConsoleControl.GetMode(handle);
|
ConsoleControl.ConsoleModes m = ConsoleControl.GetMode(handle);
|
||||||
|
|
||||||
const ConsoleControl.ConsoleModes desiredMode =
|
const ConsoleControl.ConsoleModes desiredMode =
|
||||||
|
@ -1706,7 +1636,6 @@ namespace Microsoft.PowerShell
|
||||||
m |= desiredMode;
|
m |= desiredMode;
|
||||||
ConsoleControl.SetMode(handle, m);
|
ConsoleControl.SetMode(handle, m);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// If more characters are typed than you asked, then the next call to ReadConsole will return the
|
// If more characters are typed than you asked, then the next call to ReadConsole will return the
|
||||||
// additional characters beyond those you requested.
|
// additional characters beyond those you requested.
|
||||||
|
@ -1723,44 +1652,18 @@ namespace Microsoft.PowerShell
|
||||||
// If input is terminated with a break key (Ctrl-C, Ctrl-Break, Close, etc.), then the buffer will be
|
// If input is terminated with a break key (Ctrl-C, Ctrl-Break, Close, etc.), then the buffer will be
|
||||||
// the empty string.
|
// the empty string.
|
||||||
|
|
||||||
#if UNIX
|
|
||||||
// For Unix systems, we implement a basic readline loop around Console.ReadKey(), that
|
|
||||||
// supports backspace, arrow keys, Ctrl-C, and Ctrl-D. This readline is only used for
|
|
||||||
// interactive prompts (like Read-Host), otherwise it is assumed that PSReadLine is
|
|
||||||
// available. Therefore this explicitly does not support history or tab completion.
|
|
||||||
|
|
||||||
bool treatControlCAsInput = Console.TreatControlCAsInput;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
ConsoleKeyInfo keyInfo;
|
|
||||||
string s = "";
|
|
||||||
int index = 0;
|
|
||||||
int cursorLeft = Console.CursorLeft;
|
|
||||||
int cursorCurrent = cursorLeft;
|
|
||||||
bool insertMode = true;
|
|
||||||
Console.TreatControlCAsInput = true;
|
|
||||||
#else
|
|
||||||
rawui.ClearKeyCache();
|
|
||||||
uint keyState = 0;
|
uint keyState = 0;
|
||||||
|
|
||||||
|
rawui.ClearKeyCache();
|
||||||
|
|
||||||
string s = "";
|
string s = "";
|
||||||
#endif
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#if UNIX
|
|
||||||
keyInfo = Console.ReadKey(true);
|
|
||||||
#else
|
|
||||||
s += ConsoleControl.ReadConsole(handle, initialContent, maxInputLineLength, endOnTab, out keyState);
|
s += ConsoleControl.ReadConsole(handle, initialContent, maxInputLineLength, endOnTab, out keyState);
|
||||||
Dbg.Assert(s != null, "s should never be null");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNIX
|
Dbg.Assert(s != null, "s should never be null");
|
||||||
// Handle Ctrl-C ending input
|
|
||||||
if (keyInfo.Key == ConsoleKey.C && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control))
|
|
||||||
#else
|
|
||||||
if (s.Length == 0)
|
if (s.Length == 0)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
result = ReadLineResult.endedOnBreak;
|
result = ReadLineResult.endedOnBreak;
|
||||||
s = null;
|
s = null;
|
||||||
|
@ -1774,29 +1677,13 @@ namespace Microsoft.PowerShell
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNIX
|
|
||||||
if (keyInfo.Key == ConsoleKey.Enter)
|
|
||||||
#else
|
|
||||||
if (s.EndsWith(Crlf, StringComparison.CurrentCulture))
|
if (s.EndsWith(Crlf, StringComparison.CurrentCulture))
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
result = ReadLineResult.endedOnEnter;
|
result = ReadLineResult.endedOnEnter;
|
||||||
#if UNIX
|
|
||||||
// We're intercepting characters, so we need to echo the newline
|
|
||||||
Console.Out.WriteLine();
|
|
||||||
#else
|
|
||||||
s = s.Remove(s.Length - Crlf.Length);
|
s = s.Remove(s.Length - Crlf.Length);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNIX
|
|
||||||
if (keyInfo.Key == ConsoleKey.Tab)
|
|
||||||
{
|
|
||||||
// This is unsupported
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int i = s.IndexOf(Tab, StringComparison.CurrentCulture);
|
int i = s.IndexOf(Tab, StringComparison.CurrentCulture);
|
||||||
|
|
||||||
if (endOnTab && i != -1)
|
if (endOnTab && i != -1)
|
||||||
|
@ -1846,139 +1733,17 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if UNIX
|
|
||||||
if (keyInfo.Key == ConsoleKey.Backspace)
|
|
||||||
{
|
|
||||||
if (index > 0)
|
|
||||||
{
|
|
||||||
int length = s.Length;
|
|
||||||
s = s.Remove(index - 1, 1);
|
|
||||||
index--;
|
|
||||||
cursorCurrent = Console.CursorLeft;
|
|
||||||
Console.CursorLeft = cursorLeft;
|
|
||||||
Console.Out.Write(s.PadRight(length));
|
|
||||||
Console.CursorLeft = cursorCurrent - 1;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.Delete
|
|
||||||
|| (keyInfo.Key == ConsoleKey.D && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)))
|
|
||||||
{
|
|
||||||
if (index < s.Length)
|
|
||||||
{
|
|
||||||
int length = s.Length;
|
|
||||||
s = s.Remove(index, 1);
|
|
||||||
cursorCurrent = Console.CursorLeft;
|
|
||||||
Console.CursorLeft = cursorLeft;
|
|
||||||
Console.Out.Write(s.PadRight(length));
|
|
||||||
Console.CursorLeft = cursorCurrent;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.LeftArrow
|
|
||||||
|| (keyInfo.Key == ConsoleKey.B && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)))
|
|
||||||
{
|
|
||||||
if (Console.CursorLeft > cursorLeft)
|
|
||||||
{
|
|
||||||
Console.CursorLeft--;
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.RightArrow
|
|
||||||
|| (keyInfo.Key == ConsoleKey.F && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)))
|
|
||||||
{
|
|
||||||
if (Console.CursorLeft < cursorLeft + s.Length)
|
|
||||||
{
|
|
||||||
Console.CursorLeft++;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.UpArrow
|
|
||||||
|| keyInfo.Key == ConsoleKey.DownArrow
|
|
||||||
|| keyInfo.Key == ConsoleKey.PageUp
|
|
||||||
|| keyInfo.Key == ConsoleKey.PageDown)
|
|
||||||
{
|
|
||||||
// Arrow/Page Up/down is unimplemented, so fail gracefully
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.Home
|
|
||||||
|| (keyInfo.Key == ConsoleKey.A && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)))
|
|
||||||
{
|
|
||||||
Console.CursorLeft = cursorLeft;
|
|
||||||
index = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.End
|
|
||||||
|| (keyInfo.Key == ConsoleKey.E && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)))
|
|
||||||
{
|
|
||||||
Console.CursorLeft = cursorLeft + s.Length;
|
|
||||||
index = s.Length;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.Escape)
|
|
||||||
{
|
|
||||||
Console.CursorLeft = cursorLeft;
|
|
||||||
index = s.Length;
|
|
||||||
s = "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyInfo.Key == ConsoleKey.Insert)
|
|
||||||
{
|
|
||||||
// Toggle insert/overwrite mode
|
|
||||||
insertMode = !insertMode;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Char.IsControl(keyInfo.KeyChar))
|
|
||||||
{
|
|
||||||
// blacklist control characters
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modify string
|
|
||||||
if (!insertMode) // then overwrite mode
|
|
||||||
{
|
|
||||||
s = s.Remove(index, 1);
|
|
||||||
}
|
|
||||||
s = s.Insert(index, keyInfo.KeyChar.ToString());
|
|
||||||
index++;
|
|
||||||
|
|
||||||
// Redisplay string
|
|
||||||
cursorCurrent = Console.CursorLeft;
|
|
||||||
Console.CursorLeft = cursorLeft;
|
|
||||||
Console.Out.Write(s);
|
|
||||||
Console.CursorLeft = cursorCurrent + 1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
while (true);
|
while (true);
|
||||||
|
|
||||||
Dbg.Assert(
|
Dbg.Assert(
|
||||||
(s == null && result == ReadLineResult.endedOnBreak)
|
(s == null && result == ReadLineResult.endedOnBreak)
|
||||||
|| (s != null && result != ReadLineResult.endedOnBreak),
|
|| (s != null && result != ReadLineResult.endedOnBreak),
|
||||||
"s should only be null if input ended with a break");
|
"s should only be null if input ended with a break");
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
#if UNIX
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Console.TreatControlCAsInput = treatControlCAsInput;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the character at the cursor when the user types 'tab' in the middle of line.
|
/// Get the character at the cursor when the user types 'tab' in the middle of line.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2006,7 +1771,6 @@ namespace Microsoft.PowerShell
|
||||||
Dbg.Assert(false, "the character at the cursor should be retrieved, never gets to here");
|
Dbg.Assert(false, "the character at the cursor should be retrieved, never gets to here");
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2047,15 +1811,13 @@ namespace Microsoft.PowerShell
|
||||||
/// </returns>
|
/// </returns>
|
||||||
internal string ReadLineWithTabCompletion(Executor exec)
|
internal string ReadLineWithTabCompletion(Executor exec)
|
||||||
{
|
{
|
||||||
string input = null;
|
|
||||||
string lastInput = "";
|
|
||||||
|
|
||||||
ReadLineResult rlResult = ReadLineResult.endedOnEnter;
|
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
ConsoleHandle handle = ConsoleControl.GetActiveScreenBufferHandle();
|
ConsoleHandle handle = ConsoleControl.GetActiveScreenBufferHandle();
|
||||||
|
|
||||||
|
string input = null;
|
||||||
|
string lastInput = "";
|
||||||
string lastCompletion = "";
|
string lastCompletion = "";
|
||||||
|
|
||||||
|
ReadLineResult rlResult = ReadLineResult.endedOnEnter;
|
||||||
Size screenBufferSize = RawUI.BufferSize;
|
Size screenBufferSize = RawUI.BufferSize;
|
||||||
|
|
||||||
// Save the cursor position at the end of the prompt string so that we can restore it later to write the
|
// Save the cursor position at the end of the prompt string so that we can restore it later to write the
|
||||||
|
@ -2065,7 +1827,6 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
CommandCompletion commandCompletion = null;
|
CommandCompletion commandCompletion = null;
|
||||||
string completionInput = null;
|
string completionInput = null;
|
||||||
#endif
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -2076,6 +1837,9 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
input = ReadLine(true, lastInput, out rlResult, false, false);
|
input = ReadLine(true, lastInput, out rlResult, false, false);
|
||||||
|
|
||||||
|
Coordinates endOfInputCursorPos = RawUI.CursorPosition;
|
||||||
|
string completedInput = null;
|
||||||
|
|
||||||
if (input == null)
|
if (input == null)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -2086,13 +1850,6 @@ namespace Microsoft.PowerShell
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNIX // Portable code only ends on enter (or no input), so tab is not processed
|
|
||||||
throw new PlatformNotSupportedException("This readline state is unsupported in portable code!");
|
|
||||||
#else
|
|
||||||
|
|
||||||
Coordinates endOfInputCursorPos = RawUI.CursorPosition;
|
|
||||||
string completedInput = null;
|
|
||||||
|
|
||||||
if (rlResult == ReadLineResult.endedOnTab || rlResult == ReadLineResult.endedOnShiftTab)
|
if (rlResult == ReadLineResult.endedOnTab || rlResult == ReadLineResult.endedOnShiftTab)
|
||||||
{
|
{
|
||||||
int tabIndex = input.IndexOf(Tab, StringComparison.CurrentCulture);
|
int tabIndex = input.IndexOf(Tab, StringComparison.CurrentCulture);
|
||||||
|
@ -2196,7 +1953,6 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
lastInput = completedInput;
|
lastInput = completedInput;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
while (true);
|
while (true);
|
||||||
|
|
||||||
|
@ -2212,7 +1968,6 @@ namespace Microsoft.PowerShell
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !UNIX
|
|
||||||
private void SendLeftArrows(int length)
|
private void SendLeftArrows(int length)
|
||||||
{
|
{
|
||||||
var inputs = new ConsoleControl.INPUT[length * 2];
|
var inputs = new ConsoleControl.INPUT[length * 2];
|
||||||
|
@ -2242,7 +1997,6 @@ namespace Microsoft.PowerShell
|
||||||
|
|
||||||
ConsoleControl.MimicKeyPress(inputs);
|
ConsoleControl.MimicKeyPress(inputs);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
private CommandCompletion GetNewCompletionResults(string input)
|
private CommandCompletion GetNewCompletionResults(string input)
|
||||||
{
|
{
|
||||||
|
|
|
@ -400,7 +400,7 @@ namespace Microsoft.PowerShell
|
||||||
{
|
{
|
||||||
object userInput = ReadLineSafe(false, null);
|
object userInput = ReadLineSafe(false, null);
|
||||||
string userInputString = userInput as string;
|
string userInputString = userInput as string;
|
||||||
System.Management.Automation.Diagnostics.Assert(userInputString != null, "ReadLineSafe did not return a string");
|
Diagnostics.Assert(userInputString != null, "ReadLineSafe did not return a string");
|
||||||
rawInputString = userInputString;
|
rawInputString = userInputString;
|
||||||
}
|
}
|
||||||
if (rawInputString == null)
|
if (rawInputString == null)
|
||||||
|
|
|
@ -315,7 +315,7 @@ namespace Microsoft.PowerShell
|
||||||
Dictionary<int, bool> defaultChoiceKeys,
|
Dictionary<int, bool> defaultChoiceKeys,
|
||||||
bool shouldEmulateForMultipleChoiceSelection)
|
bool shouldEmulateForMultipleChoiceSelection)
|
||||||
{
|
{
|
||||||
System.Management.Automation.Diagnostics.Assert(defaultChoiceKeys != null, "defaultChoiceKeys cannot be null.");
|
Diagnostics.Assert(defaultChoiceKeys != null, "defaultChoiceKeys cannot be null.");
|
||||||
|
|
||||||
ConsoleColor fg = RawUI.ForegroundColor;
|
ConsoleColor fg = RawUI.ForegroundColor;
|
||||||
ConsoleColor bg = RawUI.BackgroundColor;
|
ConsoleColor bg = RawUI.BackgroundColor;
|
||||||
|
|
|
@ -102,30 +102,14 @@ namespace Microsoft.PowerShell
|
||||||
location.X = 0;
|
location.X = 0;
|
||||||
location.Y = Math.Min(location.Y + 2, bufSize.Height);
|
location.Y = Math.Min(location.Y + 2, bufSize.Height);
|
||||||
|
|
||||||
#if UNIX
|
|
||||||
// replace the saved region in the screen buffer with our progress display
|
|
||||||
location = rawui.CursorPosition;
|
|
||||||
|
|
||||||
//set the cursor position back to the beginning of the region to overwrite write-progress
|
|
||||||
//if the cursor is at the bottom, back it up to overwrite the previous write progress
|
|
||||||
if (location.Y >= rawui.BufferSize.Height - rows)
|
|
||||||
{
|
|
||||||
Console.Out.Write('\n');
|
|
||||||
if (location.Y >= rows)
|
|
||||||
{
|
|
||||||
location.Y -= rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rawui.CursorPosition = location;
|
|
||||||
#else
|
|
||||||
// Save off the current contents of the screen buffer in the region that we will occupy
|
// Save off the current contents of the screen buffer in the region that we will occupy
|
||||||
|
|
||||||
savedRegion =
|
savedRegion =
|
||||||
rawui.GetBufferContents(
|
rawui.GetBufferContents(
|
||||||
new Rectangle(location.X, location.Y, location.X + cols - 1, location.Y + rows - 1));
|
new Rectangle(location.X, location.Y, location.X + cols - 1, location.Y + rows - 1));
|
||||||
#endif
|
|
||||||
|
|
||||||
// replace the saved region in the screen buffer with our progress display
|
// replace the saved region in the screen buffer with our progress display
|
||||||
|
|
||||||
rawui.SetBufferContents(location, tempProgressRegion);
|
rawui.SetBufferContents(location, tempProgressRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,30 +30,21 @@ namespace System.Management.Automation
|
||||||
// 2. Load assembly with culture 'en' (Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35)
|
// 2. Load assembly with culture 'en' (Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35)
|
||||||
// When the first attempt fails, we again need to retrieve the resouce string to construct another exception, which ends up with an infinite loop.
|
// When the first attempt fails, we again need to retrieve the resouce string to construct another exception, which ends up with an infinite loop.
|
||||||
private const string BaseFolderDoesNotExist = "The base directory '{0}' does not exist.";
|
private const string BaseFolderDoesNotExist = "The base directory '{0}' does not exist.";
|
||||||
|
private const string CannotFindFileBasedOnAssemblyName = "Could not load file or assembly '{0}' or one of its dependencies. The system cannot find the file specified under any probing paths.";
|
||||||
private const string ManifestDefinitionDoesNotMatch = "Could not load file or assembly '{0}' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.";
|
private const string ManifestDefinitionDoesNotMatch = "Could not load file or assembly '{0}' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.";
|
||||||
private const string AssemblyPathDoesNotExist = "Could not load file or assembly '{0}' or one of its dependencies. The system cannot find the file specified.";
|
private const string AssemblyPathDoesNotExist = "Could not load file or assembly '{0}' or one of its dependencies. The system cannot find the file specified.";
|
||||||
private const string InvalidAssemblyExtensionName = "Could not load file or assembly '{0}' or one of its dependencies. The file specified is not a DLL file.";
|
private const string InvalidAssemblyExtensionName = "Could not load file or assembly '{0}' or one of its dependencies. The file specified is not a DLL file.";
|
||||||
private const string AbsolutePathRequired = "Absolute path information is required.";
|
private const string AbsolutePathRequired = "Absolute path information is required.";
|
||||||
private const string SingletonAlreadyInitialized = "The singleton of PowerShellAssemblyLoadContext has already been initialized.";
|
|
||||||
private const string UseResolvingEventHandlerOnly = "PowerShellAssemblyLoadContext was initialized to use its 'Resolving' event handler only.";
|
|
||||||
|
|
||||||
#endregion Resource_Strings
|
#endregion Resource_Strings
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize a singleton of PowerShellAssemblyLoadContext
|
/// This constructor is for testability purpose only
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static PowerShellAssemblyLoadContext InitializeSingleton(string basePaths, bool useResolvingHandlerOnly)
|
protected PowerShellAssemblyLoadContext()
|
||||||
{
|
{
|
||||||
lock (syncObj)
|
|
||||||
{
|
|
||||||
if (Instance != null)
|
|
||||||
throw new InvalidOperationException(SingletonAlreadyInitialized);
|
|
||||||
|
|
||||||
Instance = new PowerShellAssemblyLoadContext(basePaths, useResolvingHandlerOnly);
|
|
||||||
return Instance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -63,25 +54,7 @@ namespace System.Management.Automation
|
||||||
/// Base directory paths that are separated by semicolon ';'.
|
/// Base directory paths that are separated by semicolon ';'.
|
||||||
/// They will be the default paths to probe assemblies.
|
/// They will be the default paths to probe assemblies.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="useResolvingHandlerOnly">
|
internal PowerShellAssemblyLoadContext(string basePaths)
|
||||||
/// Indicate whether this instance is going to be used as a
|
|
||||||
/// full fledged ALC, or only its 'Resolve' handler is going
|
|
||||||
/// to be used.
|
|
||||||
/// </param>
|
|
||||||
/// <remarks>
|
|
||||||
/// When <paramref name="useResolvingHandlerOnly"/> is true, we will register to the 'Resolving' event of the default
|
|
||||||
/// load context with our 'Resolve' method, and depend on the default load context to resolve/load assemblies for PS.
|
|
||||||
/// This mode is used when TPA list of the native host only contains .NET Core libraries.
|
|
||||||
/// In this case, TPA binder will be consulted before hitting our resolving logic. The binding order of Assembly.Load is:
|
|
||||||
/// TPA binder --> Resolving event
|
|
||||||
///
|
|
||||||
/// When <paramref name="useResolvingHandlerOnly"/> is false, we will use this instance as a full fledged load context
|
|
||||||
/// to resolve/load assemblies for PS. This mode is used when TPA list of the native host contains both .NET Core libraries
|
|
||||||
/// and PS assemblies.
|
|
||||||
/// In this case, our Load override will kick in before consulting the TPA binder. The binding order of Assembly.Load is:
|
|
||||||
/// Load override --> TPA binder --> Resolving event
|
|
||||||
/// </remarks>
|
|
||||||
private PowerShellAssemblyLoadContext(string basePaths, bool useResolvingHandlerOnly)
|
|
||||||
{
|
{
|
||||||
#region Validation
|
#region Validation
|
||||||
if (string.IsNullOrEmpty(basePaths))
|
if (string.IsNullOrEmpty(basePaths))
|
||||||
|
@ -109,34 +82,17 @@ namespace System.Management.Automation
|
||||||
this.probingPaths = new List<string>(this.basePaths);
|
this.probingPaths = new List<string>(this.basePaths);
|
||||||
|
|
||||||
// NEXT: Initialize the CoreCLR type catalog dictionary [OrdinalIgnoreCase]
|
// NEXT: Initialize the CoreCLR type catalog dictionary [OrdinalIgnoreCase]
|
||||||
|
// - Key: namespace qualified type name (FullName)
|
||||||
|
// - Value: strong name of the TPA that contains the type represented by Key.
|
||||||
coreClrTypeCatalog = InitializeTypeCatalog();
|
coreClrTypeCatalog = InitializeTypeCatalog();
|
||||||
|
|
||||||
// LAST: Handle useResolvingHandlerOnly flag
|
|
||||||
this.useResolvingHandlerOnly = useResolvingHandlerOnly;
|
|
||||||
this.activeLoadContext = useResolvingHandlerOnly ? Default : this;
|
|
||||||
if (useResolvingHandlerOnly)
|
|
||||||
{
|
|
||||||
Default.Resolving += Resolve;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var tempSet = new HashSet<string>(coreClrTypeCatalog.Values, StringComparer.OrdinalIgnoreCase);
|
|
||||||
tpaSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
||||||
foreach (string tpa in tempSet)
|
|
||||||
{
|
|
||||||
string shortName = tpa.Substring(0, tpa.IndexOf(','));
|
|
||||||
tpaSet.Add(shortName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Constructor
|
#endregion Constructor
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
private readonly bool useResolvingHandlerOnly;
|
// Serialized type catalog file
|
||||||
private readonly AssemblyLoadContext activeLoadContext;
|
private readonly object syncObj = new object();
|
||||||
private readonly static object syncObj = new object();
|
|
||||||
private readonly string[] basePaths;
|
private readonly string[] basePaths;
|
||||||
// Initially, 'probingPaths' only contains psbase path. But every time we load an assembly through 'LoadFrom(string AssemblyPath)', we
|
// Initially, 'probingPaths' only contains psbase path. But every time we load an assembly through 'LoadFrom(string AssemblyPath)', we
|
||||||
// add its parent path to 'probingPaths', so that we are able to support implicit loading of an assembly from the same place where the
|
// add its parent path to 'probingPaths', so that we are able to support implicit loading of an assembly from the same place where the
|
||||||
|
@ -144,11 +100,8 @@ namespace System.Management.Automation
|
||||||
// We don't need to worry about removing any paths from 'probingPaths', because once an assembly is loaded, it won't be unloaded until
|
// We don't need to worry about removing any paths from 'probingPaths', because once an assembly is loaded, it won't be unloaded until
|
||||||
// the current process exits, and thus the assembly itself and its parent folder cannot be deleted or renamed.
|
// the current process exits, and thus the assembly itself and its parent folder cannot be deleted or renamed.
|
||||||
private readonly List<string> probingPaths;
|
private readonly List<string> probingPaths;
|
||||||
// CoreCLR type catalog dictionary
|
// We use dictionary because the generated binary file by DataContractSerializer is about 39% smaller in size than using Hashtable.
|
||||||
// - Key: namespace qualified type name (FullName)
|
|
||||||
// - Value: strong name of the TPA that contains the type represented by Key.
|
|
||||||
private readonly Dictionary<string, string> coreClrTypeCatalog;
|
private readonly Dictionary<string, string> coreClrTypeCatalog;
|
||||||
private readonly HashSet<string> tpaSet;
|
|
||||||
private readonly string[] extensions = new string[] { ".ni.dll", ".dll" };
|
private readonly string[] extensions = new string[] { ".ni.dll", ".dll" };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -170,18 +123,6 @@ namespace System.Management.Automation
|
||||||
|
|
||||||
#endregion Fields
|
#endregion Fields
|
||||||
|
|
||||||
#region Properties
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Singleton instance of PowerShellAssemblyLoadContext
|
|
||||||
/// </summary>
|
|
||||||
internal static PowerShellAssemblyLoadContext Instance
|
|
||||||
{
|
|
||||||
get; private set;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Properties
|
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -198,24 +139,6 @@ namespace System.Management.Automation
|
||||||
/// Search the file "[assemblyName.Name][.ni].dll" in probing paths. If the file is found and it matches the requested AssemblyName, load it with LoadFromAssemblyPath.
|
/// Search the file "[assemblyName.Name][.ni].dll" in probing paths. If the file is found and it matches the requested AssemblyName, load it with LoadFromAssemblyPath.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override Assembly Load(AssemblyName assemblyName)
|
protected override Assembly Load(AssemblyName assemblyName)
|
||||||
{
|
|
||||||
if (useResolvingHandlerOnly)
|
|
||||||
throw new NotSupportedException(UseResolvingEventHandlerOnly);
|
|
||||||
|
|
||||||
// We let the default context load the assemblies included in the type catalog as there
|
|
||||||
// appears to be a bug in .NET with method resolution with system libraries loaded by our
|
|
||||||
// context and not the default. We use the short name because some packages have inconsistent
|
|
||||||
// verions between reference and runtime assemblies.
|
|
||||||
if (tpaSet.Contains(assemblyName.Name))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return Resolve(this, assemblyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The handler for the Resolving event
|
|
||||||
/// </summary>
|
|
||||||
private Assembly Resolve(AssemblyLoadContext loadContext, AssemblyName assemblyName)
|
|
||||||
{
|
{
|
||||||
// Probe the assembly cache
|
// Probe the assembly cache
|
||||||
Assembly asmLoaded;
|
Assembly asmLoaded;
|
||||||
|
@ -262,16 +185,25 @@ namespace System.Management.Automation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We failed to find the assembly file; or we found the file, but the assembly file doesn't match the request.
|
// We failed to find the file specified
|
||||||
// In this case, return null so that other Resolving event handlers can kick in to resolve the request.
|
if (!isAssemblyFileFound)
|
||||||
if (!isAssemblyFileFound || !isAssemblyFileMatching)
|
|
||||||
{
|
{
|
||||||
return null;
|
ThrowFileNotFoundException(
|
||||||
|
CannotFindFileBasedOnAssemblyName,
|
||||||
|
assemblyName.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We found the file specified, but the found assembly doesn't match the request
|
||||||
|
if (!isAssemblyFileMatching)
|
||||||
|
{
|
||||||
|
ThrowFileLoadException(
|
||||||
|
ManifestDefinitionDoesNotMatch,
|
||||||
|
assemblyName.FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
asmLoaded = asmFilePath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
|
asmLoaded = asmFilePath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
|
||||||
? loadContext.LoadFromNativeImagePath(asmFilePath, null)
|
? base.LoadFromNativeImagePath(asmFilePath, null)
|
||||||
: loadContext.LoadFromAssemblyPath(asmFilePath);
|
: base.LoadFromAssemblyPath(asmFilePath);
|
||||||
if (asmLoaded != null)
|
if (asmLoaded != null)
|
||||||
{
|
{
|
||||||
// Add the loaded assembly to the cache
|
// Add the loaded assembly to the cache
|
||||||
|
@ -307,8 +239,8 @@ namespace System.Management.Automation
|
||||||
|
|
||||||
// Load the assembly through 'LoadFromNativeImagePath' or 'LoadFromAssemblyPath'
|
// Load the assembly through 'LoadFromNativeImagePath' or 'LoadFromAssemblyPath'
|
||||||
asmLoaded = assemblyPath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
|
asmLoaded = assemblyPath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
|
||||||
? activeLoadContext.LoadFromNativeImagePath(assemblyPath, null)
|
? base.LoadFromNativeImagePath(assemblyPath, null)
|
||||||
: activeLoadContext.LoadFromAssemblyPath(assemblyPath);
|
: base.LoadFromAssemblyPath(assemblyPath);
|
||||||
|
|
||||||
if (asmLoaded != null)
|
if (asmLoaded != null)
|
||||||
{
|
{
|
||||||
|
@ -350,8 +282,8 @@ namespace System.Management.Automation
|
||||||
if (TryGetAssemblyFromCache(assemblyName, out asmLoaded))
|
if (TryGetAssemblyFromCache(assemblyName, out asmLoaded))
|
||||||
return asmLoaded;
|
return asmLoaded;
|
||||||
|
|
||||||
// Load the assembly through 'LoadFromStream'
|
// Load the assembly through 'base.LoadFromStream'
|
||||||
asmLoaded = activeLoadContext.LoadFromStream(assembly);
|
asmLoaded = base.LoadFromStream(assembly);
|
||||||
if (asmLoaded != null)
|
if (asmLoaded != null)
|
||||||
{
|
{
|
||||||
// Add the loaded assembly to the cache
|
// Add the loaded assembly to the cache
|
||||||
|
@ -376,19 +308,7 @@ namespace System.Management.Automation
|
||||||
string tpaStrongName;
|
string tpaStrongName;
|
||||||
if (coreClrTypeCatalog.TryGetValue(namespaceQualifiedTypeName, out tpaStrongName))
|
if (coreClrTypeCatalog.TryGetValue(namespaceQualifiedTypeName, out tpaStrongName))
|
||||||
{
|
{
|
||||||
try
|
return new Assembly[] { GetTrustedPlatformAssembly(tpaStrongName) };
|
||||||
{
|
|
||||||
return new Assembly[] { GetTrustedPlatformAssembly(tpaStrongName) };
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException)
|
|
||||||
{
|
|
||||||
// It's possible that the type catalog generated in OPS contains more entries than
|
|
||||||
// the one generated in windows build. This is because in OPS we have more freedom
|
|
||||||
// to control what packages to depend on, such as Json.NET.
|
|
||||||
// If we deploy the PSALC.dll generated from OPS to NanoServer, then it's possible
|
|
||||||
// that 'GetTrustedPlatformAssembly(tpaStrongName)' may fail for such entries. In
|
|
||||||
// this case, we ignore the exception and return our cached assemblies.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,46 +388,10 @@ namespace System.Management.Automation
|
||||||
return coreClrTypeCatalog.Keys;
|
return coreClrTypeCatalog.Keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set the profile optimization root on the appropriate load context
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// When using PS ALC as a full fledged ALC in OPS, we don't enable profile optimization.
|
|
||||||
/// This is because PS assemblies will be recorded in the profile, and the next time OPS
|
|
||||||
/// starts up, the default context will load the PS assemblies pretty early to ngen them
|
|
||||||
/// in another CPU core, so our Load override won't track the loading of them, and thus
|
|
||||||
/// OPS will fail to work.
|
|
||||||
/// The root cause is that dotnet.exe put all PS assemblies in TPA list. If PS assemblies
|
|
||||||
/// are not in TPA list, then we can enable profile optimization without a problem.
|
|
||||||
/// </remarks>
|
|
||||||
internal void SetProfileOptimizationRootImpl(string directoryPath)
|
|
||||||
{
|
|
||||||
if (this.useResolvingHandlerOnly)
|
|
||||||
activeLoadContext.SetProfileOptimizationRoot(directoryPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Start the profile optimization on the appropriate load context
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// When using PS ALC as a full fledged ALC in OPS, we don't enable profile optimization.
|
|
||||||
/// This is because PS assemblies will be recorded in the profile, and the next time OPS
|
|
||||||
/// starts up, the default context will load the PS assemblies pretty early to ngen them
|
|
||||||
/// in another CPU core, so our Load override won't track the loading of them, and thus
|
|
||||||
/// OPS will fail to work.
|
|
||||||
/// The root cause is that dotnet.exe put all PS assemblies in TPA list. If PS assemblies
|
|
||||||
/// are not in TPA list, then we can enable profile optimization without a problem.
|
|
||||||
/// </remarks>
|
|
||||||
internal void StartProfileOptimizationImpl(string profile)
|
|
||||||
{
|
|
||||||
if (this.useResolvingHandlerOnly)
|
|
||||||
activeLoadContext.StartProfileOptimization(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Protected_Internal_Methods
|
#endregion Protected_Internal_Methods
|
||||||
|
|
||||||
#region Private_Methods
|
#region Private_Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle the AssemblyLoad event
|
/// Handle the AssemblyLoad event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -650,12 +534,9 @@ namespace System.Management.Automation
|
||||||
/// </param>
|
/// </param>
|
||||||
private Assembly GetTrustedPlatformAssembly(string tpaStrongName)
|
private Assembly GetTrustedPlatformAssembly(string tpaStrongName)
|
||||||
{
|
{
|
||||||
// We always depend on the default context to load the TPAs that are recorded in
|
// Load the specified TPA. If the TPA is already loaded, it will be somehow
|
||||||
// the type catalog.
|
// cached in CoreCLR runtime, and thus calling 'Assembly.Load' again won't
|
||||||
// - If the requested TPA is already loaded, then 'Assembly.Load' will just get
|
// cause any overhead.
|
||||||
// it back from the cache of default context.
|
|
||||||
// - If the requested TPA is not loaded yet, then 'Assembly.Load' will make the
|
|
||||||
// default context to load it
|
|
||||||
AssemblyName assemblyName = new AssemblyName(tpaStrongName);
|
AssemblyName assemblyName = new AssemblyName(tpaStrongName);
|
||||||
Assembly asmLoaded = Assembly.Load(assemblyName);
|
Assembly asmLoaded = Assembly.Load(assemblyName);
|
||||||
return asmLoaded;
|
return asmLoaded;
|
||||||
|
@ -683,129 +564,29 @@ namespace System.Management.Automation
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Set an instance of PowerShellAssemblyLoadContext to be the default Assembly Load Context.
|
||||||
/// This is the managed entry point for Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll.
|
/// This is the managed entry point for Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PowerShellAssemblyLoadContextInitializer
|
public class PowerShellAssemblyLoadContextInitializer
|
||||||
{
|
{
|
||||||
private static object[] EmptyArray = new object[0];
|
private static bool IsInitialized = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a singleton of PowerShellAssemblyLoadContext.
|
/// Set the default Assembly Load Context
|
||||||
/// Then register to the Resolving event of the load context that loads this assembly.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
|
||||||
/// This method is to be used by native host whose TPA list doesn't include PS assemblies, such as the
|
|
||||||
/// in-box Nano powershell.exe, the PS remote WinRM plugin, in-box Nano DSC and in-box Nano SCOM agent.
|
|
||||||
/// </remarks>
|
|
||||||
/// <param name="basePaths">
|
|
||||||
/// Base directory paths that are separated by semicolon ';'.
|
|
||||||
/// They will be the default paths to probe assemblies.
|
|
||||||
/// </param>
|
|
||||||
public static void SetPowerShellAssemblyLoadContext([MarshalAs(UnmanagedType.LPWStr)]string basePaths)
|
public static void SetPowerShellAssemblyLoadContext([MarshalAs(UnmanagedType.LPWStr)]string basePaths)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(basePaths))
|
if (string.IsNullOrEmpty(basePaths))
|
||||||
|
{
|
||||||
throw new ArgumentNullException("basePaths");
|
throw new ArgumentNullException("basePaths");
|
||||||
|
}
|
||||||
|
|
||||||
PowerShellAssemblyLoadContext.InitializeSingleton(basePaths, useResolvingHandlerOnly: true);
|
if (!IsInitialized)
|
||||||
}
|
{
|
||||||
|
var psAsmLoadContext = new PowerShellAssemblyLoadContext(basePaths);
|
||||||
/// <summary>
|
AssemblyLoadContext.InitializeDefaultContext(psAsmLoadContext);
|
||||||
/// Create a singleton of PowerShellAssemblyLoadContext.
|
IsInitialized = true;
|
||||||
/// Then load System.Management.Automation and call the WSManPluginManagedEntryWrapper delegate.
|
}
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This method is used by the native host of the PSRP plugin.
|
|
||||||
/// </remarks>
|
|
||||||
/// <param name="wkrPtrs">
|
|
||||||
/// Passed to delegate.
|
|
||||||
/// </param>
|
|
||||||
public static int WSManPluginWrapper(IntPtr wkrPtrs)
|
|
||||||
{
|
|
||||||
string basePaths = System.IO.Path.GetDirectoryName(typeof(PowerShellAssemblyLoadContextInitializer).GetTypeInfo().Assembly.Location);
|
|
||||||
string entryAssemblyName = "System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
|
|
||||||
string entryTypeName = "System.Management.Automation.Remoting.WSManPluginManagedEntryWrapper";
|
|
||||||
string entryMethodName = "InitPlugin";
|
|
||||||
object[] args = { wkrPtrs };
|
|
||||||
|
|
||||||
var psLoadContext = PowerShellAssemblyLoadContext.InitializeSingleton(basePaths, useResolvingHandlerOnly: false);
|
|
||||||
var entryAssembly = psLoadContext.LoadFromAssemblyName(new AssemblyName(entryAssemblyName));
|
|
||||||
var entryType = entryAssembly.GetType(entryTypeName, throwOnError: true, ignoreCase: true);
|
|
||||||
var methodInfo = entryType.GetMethod(entryMethodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.IgnoreCase);
|
|
||||||
|
|
||||||
return (int)methodInfo.Invoke(null, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a singleton of PowerShellAssemblyLoadContext.
|
|
||||||
/// Then load the assembly containing the actual entry point using it.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="basePaths">
|
|
||||||
/// Base directory paths that are separated by semicolon ';'.
|
|
||||||
/// They will be the default paths to probe assemblies.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="entryAssemblyName">
|
|
||||||
/// Name of the assembly that contains the actual entry point.
|
|
||||||
/// </param>
|
|
||||||
/// <returns>
|
|
||||||
/// The assembly that contains the actual entry point.
|
|
||||||
/// </returns>
|
|
||||||
public static Assembly InitializeAndLoadEntryAssembly(string basePaths, AssemblyName entryAssemblyName)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(basePaths))
|
|
||||||
throw new ArgumentNullException("basePaths");
|
|
||||||
|
|
||||||
if (entryAssemblyName == null)
|
|
||||||
throw new ArgumentNullException("entryAssemblyName");
|
|
||||||
|
|
||||||
var psLoadContext = PowerShellAssemblyLoadContext.InitializeSingleton(basePaths, useResolvingHandlerOnly: false);
|
|
||||||
return psLoadContext.LoadFromAssemblyName(entryAssemblyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a singleton of PowerShellAssemblyLoadContext.
|
|
||||||
/// Then call into the actual entry point based on the given assembly name, type name, method name and arguments.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="basePaths">
|
|
||||||
/// Base directory paths that are separated by semicolon ';'.
|
|
||||||
/// They will be the default paths to probe assemblies.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="entryAssemblyName">
|
|
||||||
/// Name of the assembly that contains the actual entry point.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="entryTypeName">
|
|
||||||
/// Name of the type that contains the actual entry point.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="entryMethodName">
|
|
||||||
/// Name of the actual entry point method.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="args">
|
|
||||||
/// An array of arguments passed to the entry point method.
|
|
||||||
/// </param>
|
|
||||||
/// <returns>
|
|
||||||
/// The return value of running the entry point method.
|
|
||||||
/// </returns>
|
|
||||||
public static object InitializeAndCallEntryMethod(string basePaths, AssemblyName entryAssemblyName, string entryTypeName, string entryMethodName, object[] args)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(basePaths))
|
|
||||||
throw new ArgumentNullException("basePaths");
|
|
||||||
|
|
||||||
if (entryAssemblyName == null)
|
|
||||||
throw new ArgumentNullException("entryAssemblyName");
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(entryTypeName))
|
|
||||||
throw new ArgumentNullException("entryTypeName");
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(entryMethodName))
|
|
||||||
throw new ArgumentNullException("entryMethodName");
|
|
||||||
|
|
||||||
args = args ?? EmptyArray;
|
|
||||||
|
|
||||||
var psLoadContext = PowerShellAssemblyLoadContext.InitializeSingleton(basePaths, useResolvingHandlerOnly: false);
|
|
||||||
var entryAssembly = psLoadContext.LoadFromAssemblyName(entryAssemblyName);
|
|
||||||
var entryType = entryAssembly.GetType(entryTypeName, throwOnError: true, ignoreCase: true);
|
|
||||||
var methodInfo = entryType.GetMethod(entryMethodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.IgnoreCase);
|
|
||||||
|
|
||||||
return methodInfo.Invoke(null, args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1303,7 +1303,7 @@ Function PSGetSerializedShowCommandInfo
|
||||||
MessageBox.Show(
|
MessageBox.Show(
|
||||||
String.Format(
|
String.Format(
|
||||||
CultureInfo.CurrentUICulture,
|
CultureInfo.CurrentUICulture,
|
||||||
ShowCommandResources.EndProcessingErrorMessage,
|
Microsoft.Management.UI.Internal.ShowCommandResources.EndProcessingErrorMessage,
|
||||||
errorString),
|
errorString),
|
||||||
"Show-Command",
|
"Show-Command",
|
||||||
MessageBoxButton.OK,
|
MessageBoxButton.OK,
|
||||||
|
|
|
@ -75,12 +75,12 @@ namespace Microsoft.Management.UI.Internal
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// OK Button's content.
|
/// OK Button's content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly string OKButtonContent = XamlLocalizableResources.OutGridView_Button_OK;
|
private static readonly string OKButtonContent = Microsoft.Management.UI.Internal.XamlLocalizableResources.OutGridView_Button_OK;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancel Button's content.
|
/// Cancel Button's content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly string CancelButtonContent = XamlLocalizableResources.OutGridView_Button_Cancel;
|
private static readonly string CancelButtonContent = Microsoft.Management.UI.Internal.XamlLocalizableResources.OutGridView_Button_Cancel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to store selected items in the ok processing
|
/// Used to store selected items in the ok processing
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<ScrollViewer x:Name="Scroll" HorizontalAlignment="Stretch" Grid.Row="1" AutomationProperties.Name="{Binding HelpTitle}">
|
<ScrollViewer x:Name="Scroll" HorizontalAlignment="Stretch" Grid.Row="1" AutomationProperties.Name="{Binding HelpTitle}">
|
||||||
<RichTextBox x:Name="HelpText" FontFamily="Consolas" VerticalScrollBarVisibility="Disabled" BorderThickness="0" IsReadOnly="True" AutomationProperties.Name="{Binding HelpTitle}">
|
<RichTextBox x:Name="HelpText" FontFamily="Consolas" VerticalScrollBarVisibility="Disabled" BorderThickness="0" IsReadOnly="True" IsReadOnlyCaretVisible="True" AutomationProperties.Name="{Binding HelpTitle}">
|
||||||
<RichTextBox.LayoutTransform>
|
<RichTextBox.LayoutTransform>
|
||||||
<ScaleTransform ScaleX="{Binding Path=ZoomLevel}" ScaleY="{Binding Path=ZoomLevel}"/>
|
<ScaleTransform ScaleX="{Binding Path=ZoomLevel}" ScaleY="{Binding Path=ZoomLevel}"/>
|
||||||
</RichTextBox.LayoutTransform>
|
</RichTextBox.LayoutTransform>
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace System.Management.Automation.SecurityAccountsManager.Extensions
|
||||||
#if CORECLR
|
#if CORECLR
|
||||||
IntPtr buffer = SecureStringMarshal.SecureStringToCoTaskMemUnicode(str);
|
IntPtr buffer = SecureStringMarshal.SecureStringToCoTaskMemUnicode(str);
|
||||||
string clear = Marshal.PtrToStringUni(buffer);
|
string clear = Marshal.PtrToStringUni(buffer);
|
||||||
Marshal.ZeroFreeCoTaskMemUnicode(buffer);
|
SecureStringMarshal.ZeroFreeCoTaskMemUnicode(buffer);
|
||||||
#else
|
#else
|
||||||
var bstr = Marshal.SecureStringToBSTR(str);
|
var bstr = Marshal.SecureStringToBSTR(str);
|
||||||
string clear = Marshal.PtrToStringAuto(bstr);
|
string clear = Marshal.PtrToStringAuto(bstr);
|
||||||
|
@ -200,4 +200,4 @@ namespace System.Management.Automation.SecurityAccountsManager.Extensions
|
||||||
return ex.MakeErrorRecord(ex.ErrorName, ex.ErrorCategory, target ?? ex.Target);
|
return ex.MakeErrorRecord(ex.ErrorName, ex.ErrorCategory, target ?? ex.Target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -477,7 +477,6 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
|
||||||
#region Event and telemetry stuff
|
#region Event and telemetry stuff
|
||||||
//Calling PowerShell Telemetry APIs
|
//Calling PowerShell Telemetry APIs
|
||||||
protected void TraceMessage(string message, SoftwareIdentity swidObject) {
|
protected void TraceMessage(string message, SoftwareIdentity swidObject) {
|
||||||
#if !UNIX
|
|
||||||
TelemetryAPI.TraceMessage(message,
|
TelemetryAPI.TraceMessage(message,
|
||||||
new {
|
new {
|
||||||
PackageName = swidObject.Name,
|
PackageName = swidObject.Name,
|
||||||
|
@ -487,7 +486,6 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
|
||||||
ExuectionStatus = swidObject.Status,
|
ExuectionStatus = swidObject.Status,
|
||||||
ExecutionTime = DateTime.Today
|
ExecutionTime = DateTime.Today
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected enum EventTask {
|
protected enum EventTask {
|
||||||
|
@ -510,7 +508,6 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
|
||||||
|
|
||||||
protected void LogEvent(EventTask task, EventId id, string context, string name, string version, string providerName, string source, string status, string destinationPath)
|
protected void LogEvent(EventTask task, EventId id, string context, string name, string version, string providerName, string source, string status, string destinationPath)
|
||||||
{
|
{
|
||||||
#if !UNIX
|
|
||||||
var iis = InitialSessionState.CreateDefault2();
|
var iis = InitialSessionState.CreateDefault2();
|
||||||
|
|
||||||
using (Runspace rs = RunspaceFactory.CreateRunspace(iis))
|
using (Runspace rs = RunspaceFactory.CreateRunspace(iis))
|
||||||
|
@ -537,8 +534,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
|
||||||
Verbose(ex.Message);
|
Verbose(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -57,12 +57,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ProcessPackage(PackageProvider provider, IEnumerable<string> searchKey, SoftwareIdentity package)
|
protected override void ProcessPackage(PackageProvider provider, IEnumerable<string> searchKey, SoftwareIdentity package) {
|
||||||
{
|
|
||||||
ProcessPackage(provider, searchKey, package, IncludeDependencies ? new HashSet<string>() : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProcessPackage(PackageProvider provider, IEnumerable<string> searchKey, SoftwareIdentity package, HashSet<string> processedDependencies) {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -76,24 +71,14 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
|
||||||
foreach (var dep in package.Dependencies) {
|
foreach (var dep in package.Dependencies) {
|
||||||
// note: future work may be needed if the package sources currently selected by the user don't
|
// note: future work may be needed if the package sources currently selected by the user don't
|
||||||
// contain the dependencies.
|
// contain the dependencies.
|
||||||
|
var dependendcies = PackageManagementService.FindPackageByCanonicalId(dep, this);
|
||||||
|
var depPkg = dependendcies.OrderByDescending(pp => pp, SoftwareIdentityVersionComparer.Instance).FirstOrDefault();
|
||||||
|
|
||||||
// this dep is not processed yet
|
if (depPkg == null) {
|
||||||
if (!processedDependencies.Contains(dep))
|
missingDependencies.Add(dep);
|
||||||
{
|
Warning(Constants.Messages.UnableToFindDependencyPackage, dep);
|
||||||
var dependendcies = PackageManagementService.FindPackageByCanonicalId(dep, this);
|
} else {
|
||||||
var depPkg = dependendcies.OrderByDescending(pp => pp, SoftwareIdentityVersionComparer.Instance).FirstOrDefault();
|
ProcessPackage(depPkg.Provider, searchKey.Select(each => each + depPkg.Name).ToArray(), depPkg);
|
||||||
|
|
||||||
processedDependencies.Add(dep);
|
|
||||||
|
|
||||||
if (depPkg == null)
|
|
||||||
{
|
|
||||||
missingDependencies.Add(dep);
|
|
||||||
Warning(Constants.Messages.UnableToFindDependencyPackage, dep);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ProcessPackage(depPkg.Provider, searchKey.Select(each => each + depPkg.Name).ToArray(), depPkg, processedDependencies);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (missingDependencies.Any()) {
|
if (missingDependencies.Any()) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#if !UNIX
|
|
||||||
|
|
||||||
/********************************************************************++
|
/********************************************************************++
|
||||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
--********************************************************************/
|
--********************************************************************/
|
||||||
|
@ -281,6 +279,4 @@ namespace Microsoft.PowerShell.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -3956,12 +3956,7 @@ namespace Microsoft.PowerShell.Activities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var psvar = runspace.SessionStateProxy.PSVariable.Get(name);
|
runspace.SessionStateProxy.PSVariable.Set(name, value);
|
||||||
if (psvar == null || (psvar.Options & ScopedItemOptions.ReadOnly) == 0)
|
|
||||||
{
|
|
||||||
// don't try to overwrite read-only variables values
|
|
||||||
runspace.SessionStateProxy.PSVariable.Set(name, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (PSNotSupportedException)
|
catch (PSNotSupportedException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1307,8 +1307,9 @@ namespace Microsoft.PowerShell.Workflow
|
||||||
AddParameter("Depth", 10).
|
AddParameter("Depth", 10).
|
||||||
AddParameter("Path", tempPath).Invoke();
|
AddParameter("Path", tempPath).Invoke();
|
||||||
|
|
||||||
throw new Exception("Bug MSFT:246456 detected. Please capture " + tempPath + ", open a new issue " +
|
throw new Exception("Bug MSFT:246456 detected. Please capture " + tempPath + ", attach it to " +
|
||||||
"at https://github.com/PowerShell/PowerShell/issues/new and attach the file.");
|
"https://microsoft.visualstudio.com/DefaultCollection/WSSC/_workItems#id=246456&_a=edit, and " +
|
||||||
|
"then reassign the bug to leeholm.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace Microsoft.WSMan.Management
|
||||||
private FileStream _fs;
|
private FileStream _fs;
|
||||||
private StreamReader _sr;
|
private StreamReader _sr;
|
||||||
|
|
||||||
private static ResourceManager g_resourceMgr = new ResourceManager("Microsoft.WSMan.Management.resources.WsManResources", typeof(WSManHelper).GetTypeInfo().Assembly);
|
private static ResourceManager g_resourceMgr = new ResourceManager("WsManResources", typeof(WSManHelper).GetTypeInfo().Assembly);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -135,16 +135,20 @@ namespace Microsoft.WSMan.Management
|
||||||
|
|
||||||
internal WSManHelper()
|
internal WSManHelper()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
_resourceMgr = new ResourceManager("WsManResources", this.GetType().GetTypeInfo().Assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal WSManHelper(PSCmdlet cmdlet)
|
internal WSManHelper(PSCmdlet cmdlet)
|
||||||
{
|
{
|
||||||
cmdletname = cmdlet;
|
cmdletname = cmdlet;
|
||||||
|
_resourceMgr = new ResourceManager("WsManResources", this.GetType().GetTypeInfo().Assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal WSManHelper(NavigationCmdletProvider provider)
|
internal WSManHelper(NavigationCmdletProvider provider)
|
||||||
{
|
{
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
|
_resourceMgr = new ResourceManager("WsManResources", this.GetType().GetTypeInfo().Assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void ThrowIfNotAdministrator()
|
internal static void ThrowIfNotAdministrator()
|
||||||
|
@ -160,13 +164,14 @@ namespace Microsoft.WSMan.Management
|
||||||
|
|
||||||
internal string GetResourceMsgFromResourcetext(string rscname)
|
internal string GetResourceMsgFromResourcetext(string rscname)
|
||||||
{
|
{
|
||||||
return g_resourceMgr.GetString(rscname);
|
return _resourceMgr.GetString(rscname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static internal string FormatResourceMsgFromResourcetextS(string rscname,
|
static internal string FormatResourceMsgFromResourcetextS(string rscname,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
return FormatResourceMsgFromResourcetextS(g_resourceMgr, rscname, args);
|
ResourceManager resourceManager = new ResourceManager("WsManResources", typeof(WSManHelper).GetTypeInfo().Assembly);
|
||||||
|
return FormatResourceMsgFromResourcetextS(resourceManager, rscname, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string FormatResourceMsgFromResourcetext(string resourceName,
|
internal string FormatResourceMsgFromResourcetext(string resourceName,
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -587,7 +587,7 @@ function ConvertFrom-SddlString
|
||||||
Begin
|
Begin
|
||||||
{
|
{
|
||||||
# On CoreCLR CryptoKeyRights and ActiveDirectoryRights are not supported.
|
# On CoreCLR CryptoKeyRights and ActiveDirectoryRights are not supported.
|
||||||
if ($PSEdition -eq "PowerShellCore" -and ($Type -eq "CryptoKeyRights" -or $Type -eq "ActiveDirectoryRights"))
|
if ($PSEdition -eq "Core" -and ($Type -eq "CryptoKeyRights" -or $Type -eq "ActiveDirectoryRights"))
|
||||||
{
|
{
|
||||||
$errorId = "TypeNotSupported"
|
$errorId = "TypeNotSupported"
|
||||||
$errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument
|
$errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument
|
||||||
|
@ -622,7 +622,7 @@ function ConvertFrom-SddlString
|
||||||
{
|
{
|
||||||
param($AccessMask, $Type)
|
param($AccessMask, $Type)
|
||||||
|
|
||||||
if ($PSEdition -eq "PowerShellCore")
|
if ($PSEdition -eq "Core")
|
||||||
{
|
{
|
||||||
## All the types of access rights understood by .NET Core
|
## All the types of access rights understood by .NET Core
|
||||||
$rightTypes = [Ordered] @{
|
$rightTypes = [Ordered] @{
|
||||||
|
|
Binary file not shown.
|
@ -14,44 +14,25 @@ Microsoft.PowerShell.Core\Set-StrictMode -Version Latest
|
||||||
# Check if this is nano server. [System.Runtime.Loader.AssemblyLoadContext] is only available on NanoServer
|
# Check if this is nano server. [System.Runtime.Loader.AssemblyLoadContext] is only available on NanoServer
|
||||||
$script:isNanoServer = $null -ne ('System.Runtime.Loader.AssemblyLoadContext' -as [Type])
|
$script:isNanoServer = $null -ne ('System.Runtime.Loader.AssemblyLoadContext' -as [Type])
|
||||||
|
|
||||||
function IsWindows { $PSVariable = Get-Variable -Name IsWindows -ErrorAction Ignore; return (-not $PSVariable -or $PSVariable.Value) }
|
try
|
||||||
function IsLinux { $PSVariable = Get-Variable -Name IsLinux -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
|
|
||||||
function IsOSX { $PSVariable = Get-Variable -Name IsOSX -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
|
|
||||||
function IsCoreCLR { $PSVariable = Get-Variable -Name IsCoreCLR -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
|
|
||||||
|
|
||||||
if(IsWindows)
|
|
||||||
{
|
{
|
||||||
$script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell"
|
$script:MyDocumentsFolderPath = [Environment]::GetFolderPath("MyDocuments")
|
||||||
}
|
}
|
||||||
else
|
catch
|
||||||
{
|
{
|
||||||
$script:ProgramFilesPSPath = $PSHome
|
$script:MyDocumentsFolderPath = $null
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsWindows)
|
$script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell"
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$script:MyDocumentsFolderPath = [Environment]::GetFolderPath("MyDocuments")
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
$script:MyDocumentsFolderPath = $null
|
|
||||||
}
|
|
||||||
|
|
||||||
$script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath)
|
$script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath)
|
||||||
{
|
{
|
||||||
Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath "WindowsPowerShell"
|
Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath "WindowsPowerShell"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Microsoft.PowerShell.Management\Join-Path -Path $env:USERPROFILE -ChildPath "Documents\WindowsPowerShell"
|
Microsoft.PowerShell.Management\Join-Path -Path $env:USERPROFILE -ChildPath "Documents\WindowsPowerShell"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$script:MyDocumentsPSPath = Microsoft.PowerShell.Management\Join-Path -Path $HOME -ChildPath ".local/share/powershell"
|
|
||||||
}
|
|
||||||
|
|
||||||
$script:ProgramFilesModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesPSPath -ChildPath "Modules"
|
$script:ProgramFilesModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesPSPath -ChildPath "Modules"
|
||||||
$script:MyDocumentsModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath "Modules"
|
$script:MyDocumentsModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath "Modules"
|
||||||
|
@ -60,20 +41,10 @@ $script:ProgramFilesScriptsPath = Microsoft.PowerShell.Management\Join-Path -Pat
|
||||||
|
|
||||||
$script:MyDocumentsScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath "Scripts"
|
$script:MyDocumentsScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath "Scripts"
|
||||||
|
|
||||||
$script:TempPath = if(IsWindows){ ([System.IO.DirectoryInfo]$env:TEMP).FullName } else { '/tmp' }
|
$script:TempPath = ([System.IO.DirectoryInfo]$env:TEMP).FullName
|
||||||
$script:PSGetItemInfoFileName = "PSGetModuleInfo.xml"
|
$script:PSGetItemInfoFileName = "PSGetModuleInfo.xml"
|
||||||
|
$script:PSGetProgramDataPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramData -ChildPath 'Microsoft\Windows\PowerShell\PowerShellGet\'
|
||||||
if(IsWindows)
|
$script:PSGetAppLocalPath = Microsoft.PowerShell.Management\Join-Path -Path $env:LOCALAPPDATA -ChildPath 'Microsoft\Windows\PowerShell\PowerShellGet\'
|
||||||
{
|
|
||||||
$script:PSGetProgramDataPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramData -ChildPath 'Microsoft\Windows\PowerShell\PowerShellGet\'
|
|
||||||
$script:PSGetAppLocalPath = Microsoft.PowerShell.Management\Join-Path -Path $env:LOCALAPPDATA -ChildPath 'Microsoft\Windows\PowerShell\PowerShellGet\'
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$script:PSGetProgramDataPath = "$HOME/.config/powershell/powershellget" #TODO: Get $env:ProgramData equivalent
|
|
||||||
$script:PSGetAppLocalPath = "$HOME/.config/powershell/powershellget"
|
|
||||||
}
|
|
||||||
|
|
||||||
$script:PSGetModuleSourcesFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetAppLocalPath -ChildPath "PSRepositories.xml"
|
$script:PSGetModuleSourcesFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetAppLocalPath -ChildPath "PSRepositories.xml"
|
||||||
$script:PSGetModuleSources = $null
|
$script:PSGetModuleSources = $null
|
||||||
$script:PSGetInstalledModules = $null
|
$script:PSGetInstalledModules = $null
|
||||||
|
@ -118,8 +89,8 @@ $script:NuGetProviderVersion = [Version]'2.8.5.201'
|
||||||
|
|
||||||
$script:SupportsPSModulesFeatureName="supports-powershell-modules"
|
$script:SupportsPSModulesFeatureName="supports-powershell-modules"
|
||||||
$script:FastPackRefHastable = @{}
|
$script:FastPackRefHastable = @{}
|
||||||
$script:NuGetBinaryProgramDataPath=if(IsWindows) {"$env:ProgramFiles\PackageManagement\ProviderAssemblies"}
|
$script:NuGetBinaryProgramDataPath="$env:ProgramFiles\PackageManagement\ProviderAssemblies"
|
||||||
$script:NuGetBinaryLocalAppDataPath=if(IsWindows) {"$env:LOCALAPPDATA\PackageManagement\ProviderAssemblies"}
|
$script:NuGetBinaryLocalAppDataPath="$env:LOCALAPPDATA\PackageManagement\ProviderAssemblies"
|
||||||
# go fwlink for 'https://nuget.org/nuget.exe'
|
# go fwlink for 'https://nuget.org/nuget.exe'
|
||||||
$script:NuGetClientSourceURL = 'http://go.microsoft.com/fwlink/?LinkID=690216&clcid=0x409'
|
$script:NuGetClientSourceURL = 'http://go.microsoft.com/fwlink/?LinkID=690216&clcid=0x409'
|
||||||
$script:NuGetExeName = 'NuGet.exe'
|
$script:NuGetExeName = 'NuGet.exe'
|
||||||
|
@ -425,7 +396,10 @@ Microsoft.PowerShell.Utility\Import-LocalizedData LocalizedData -filename PSGet
|
||||||
# This code is required to add a .Net type and call the Telemetry APIs
|
# This code is required to add a .Net type and call the Telemetry APIs
|
||||||
# This is required since PowerShell does not support generation of .Net Anonymous types
|
# This is required since PowerShell does not support generation of .Net Anonymous types
|
||||||
#
|
#
|
||||||
$requiredAssembly = @( "system.management.automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" )
|
$requiredAssembly = @( "system.management.automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
||||||
|
"$([System.Net.IWebProxy].AssemblyQualifiedName)".Substring('System.Net.IWebProxy'.Length+1).Trim(),
|
||||||
|
"$([System.Uri].AssemblyQualifiedName)".Substring('System.Uri'.Length+1).Trim()
|
||||||
|
)
|
||||||
|
|
||||||
$source = @"
|
$source = @"
|
||||||
using System;
|
using System;
|
||||||
|
@ -450,6 +424,47 @@ namespace Microsoft.PowerShell.Commands.PowerShellGet
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used by Ping-Endpoint function to supply webproxy to HttpClient
|
||||||
|
/// We cannot use System.Net.WebProxy because this is not available on CoreClr
|
||||||
|
/// </summary>
|
||||||
|
public class InternalWebProxy : IWebProxy
|
||||||
|
{
|
||||||
|
Uri _proxyUri;
|
||||||
|
ICredentials _credentials;
|
||||||
|
|
||||||
|
public InternalWebProxy(Uri uri, ICredentials credentials)
|
||||||
|
{
|
||||||
|
Credentials = credentials;
|
||||||
|
_proxyUri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Credentials used by WebProxy
|
||||||
|
/// </summary>
|
||||||
|
public ICredentials Credentials
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _credentials;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_credentials = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri GetProxy(Uri destination)
|
||||||
|
{
|
||||||
|
return _proxyUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsBypassed(Uri host)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
|
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
|
||||||
public struct CERT_CHAIN_POLICY_PARA {
|
public struct CERT_CHAIN_POLICY_PARA {
|
||||||
|
@ -549,7 +564,7 @@ $script:TelemetryEnabled = $false
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
# If the telemetry namespace/methods are not found flow goes to the catch block where telemetry is disabled
|
# If the telemetry namespace/methods are not found flow goes to the catch block where telemetry is disabled
|
||||||
$telemetryMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | Get-Member -Static).Name
|
$telemetryMethods = ([Microsoft.PowerShell.Get.Telemetry] | Get-Member -Static).Name
|
||||||
|
|
||||||
if ($telemetryMethods.Contains("TraceMessageArtifactsNotFound") -and $telemetryMethods.Contains("TraceMessageNonPSGalleryRegistration"))
|
if ($telemetryMethods.Contains("TraceMessageArtifactsNotFound") -and $telemetryMethods.Contains("TraceMessageNonPSGalleryRegistration"))
|
||||||
{
|
{
|
||||||
|
@ -562,14 +577,14 @@ catch
|
||||||
# Ignore the error and try adding the type below
|
# Ignore the error and try adding the type below
|
||||||
}
|
}
|
||||||
|
|
||||||
if(-not $script:TelemetryEnabled -and (IsWindows))
|
if(-not $script:TelemetryEnabled)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Add-Type -ReferencedAssemblies $requiredAssembly -TypeDefinition $source -Language CSharp -ErrorAction SilentlyContinue
|
Add-Type -ReferencedAssemblies $requiredAssembly -TypeDefinition $source -Language CSharp -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
# If the telemetry namespace/methods are not found flow goes to the catch block where telemetry is disabled
|
# If the telemetry namespace/methods are not found flow goes to the catch block where telemetry is disabled
|
||||||
$telemetryMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | Get-Member -Static).Name
|
$telemetryMethods = ([Microsoft.PowerShell.Get.Telemetry] | Get-Member -Static).Name
|
||||||
|
|
||||||
if ($telemetryMethods.Contains("TraceMessageArtifactsNotFound") -and $telemetryMethods.Contains("TraceMessageNonPSGalleryRegistration"))
|
if ($telemetryMethods.Contains("TraceMessageArtifactsNotFound") -and $telemetryMethods.Contains("TraceMessageNonPSGalleryRegistration"))
|
||||||
{
|
{
|
||||||
|
@ -584,66 +599,6 @@ if(-not $script:TelemetryEnabled -and (IsWindows))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$RequiredAssembliesForInternalWebProxy = @( "$([System.Net.IWebProxy].AssemblyQualifiedName)".Substring('System.Net.IWebProxy'.Length+1).Trim(),
|
|
||||||
"$([System.Uri].AssemblyQualifiedName)".Substring('System.Uri'.Length+1).Trim() )
|
|
||||||
|
|
||||||
$SourceForInternalWebProxy = @"
|
|
||||||
using System;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace Microsoft.PowerShell.Commands.PowerShellGet
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Used by Ping-Endpoint function to supply webproxy to HttpClient
|
|
||||||
/// We cannot use System.Net.WebProxy because this is not available on CoreClr
|
|
||||||
/// </summary>
|
|
||||||
public class InternalWebProxy : IWebProxy
|
|
||||||
{
|
|
||||||
Uri _proxyUri;
|
|
||||||
ICredentials _credentials;
|
|
||||||
|
|
||||||
public InternalWebProxy(Uri uri, ICredentials credentials)
|
|
||||||
{
|
|
||||||
Credentials = credentials;
|
|
||||||
_proxyUri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Credentials used by WebProxy
|
|
||||||
/// </summary>
|
|
||||||
public ICredentials Credentials
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _credentials;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_credentials = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Uri GetProxy(Uri destination)
|
|
||||||
{
|
|
||||||
return _proxyUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsBypassed(Uri host)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"@
|
|
||||||
|
|
||||||
if(-not ('Microsoft.PowerShell.Commands.PowerShellGet.InternalWebProxy' -as [Type]))
|
|
||||||
{
|
|
||||||
Add-Type -ReferencedAssemblies $RequiredAssembliesForInternalWebProxy `
|
|
||||||
-TypeDefinition $SourceForInternalWebProxy `
|
|
||||||
-Language CSharp `
|
|
||||||
-ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region *-Module cmdlets
|
#region *-Module cmdlets
|
||||||
|
@ -727,7 +682,7 @@ function Publish-Module
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
{
|
{
|
||||||
if($script:isNanoServer -or (IsCoreCLR)) {
|
if($script:isNanoServer) {
|
||||||
$message = $LocalizedData.PublishPSArtifactUnsupportedOnNano -f "Module"
|
$message = $LocalizedData.PublishPSArtifactUnsupportedOnNano -f "Module"
|
||||||
ThrowError -ExceptionName "System.InvalidOperationException" `
|
ThrowError -ExceptionName "System.InvalidOperationException" `
|
||||||
-ExceptionMessage $message `
|
-ExceptionMessage $message `
|
||||||
|
@ -889,7 +844,7 @@ function Publish-Module
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$resolvedPath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
$resolvedPath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $resolvedPath -or
|
if(-not $resolvedPath -or
|
||||||
-not (Microsoft.PowerShell.Management\Test-Path -Path $resolvedPath -PathType Container))
|
-not (Microsoft.PowerShell.Management\Test-Path -Path $resolvedPath -PathType Container))
|
||||||
|
@ -1079,7 +1034,7 @@ function Publish-Module
|
||||||
# Use Find-Script to check if that name is already used as scriptname
|
# Use Find-Script to check if that name is already used as scriptname
|
||||||
$scriptPSGetItemInfo = Find-Script @FindParameters |
|
$scriptPSGetItemInfo = Find-Script @FindParameters |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $moduleName} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $moduleName} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
if($scriptPSGetItemInfo)
|
if($scriptPSGetItemInfo)
|
||||||
{
|
{
|
||||||
$message = $LocalizedData.SpecifiedNameIsAlearyUsed -f ($moduleName, $Repository, 'Find-Script')
|
$message = $LocalizedData.SpecifiedNameIsAlearyUsed -f ($moduleName, $Repository, 'Find-Script')
|
||||||
|
@ -1094,7 +1049,7 @@ function Publish-Module
|
||||||
$null = $FindParameters.Remove('Tag')
|
$null = $FindParameters.Remove('Tag')
|
||||||
$currentPSGetItemInfo = Find-Module @FindParameters |
|
$currentPSGetItemInfo = Find-Module @FindParameters |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $moduleInfo.Name} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $moduleInfo.Name} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
|
|
||||||
if($currentPSGetItemInfo)
|
if($currentPSGetItemInfo)
|
||||||
{
|
{
|
||||||
|
@ -1432,7 +1387,7 @@ function Save-Module
|
||||||
{
|
{
|
||||||
if($Path)
|
if($Path)
|
||||||
{
|
{
|
||||||
$destinationPath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
$destinationPath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-path $destinationPath))
|
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-path $destinationPath))
|
||||||
{
|
{
|
||||||
|
@ -1449,7 +1404,7 @@ function Save-Module
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$destinationPath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
$destinationPath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $destinationPath))
|
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $destinationPath))
|
||||||
{
|
{
|
||||||
|
@ -1898,7 +1853,7 @@ function Update-Module
|
||||||
|
|
||||||
if(-not $installedPackages -and -not (Test-WildcardPattern -Name $moduleName))
|
if(-not $installedPackages -and -not (Test-WildcardPattern -Name $moduleName))
|
||||||
{
|
{
|
||||||
$availableModules = Get-Module -ListAvailable $moduleName -Verbose:$false | Microsoft.PowerShell.Utility\Select-Object -Unique -ErrorAction Ignore
|
$availableModules = Get-Module -ListAvailable $moduleName -Verbose:$false | Microsoft.PowerShell.Utility\Select-Object -Unique
|
||||||
|
|
||||||
if(-not $availableModules)
|
if(-not $availableModules)
|
||||||
{
|
{
|
||||||
|
@ -2526,7 +2481,7 @@ function Publish-Script
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
{
|
{
|
||||||
if($script:isNanoServer -or (IsCoreCLR)) {
|
if($script:isNanoServer) {
|
||||||
$message = $LocalizedData.PublishPSArtifactUnsupportedOnNano -f "Script"
|
$message = $LocalizedData.PublishPSArtifactUnsupportedOnNano -f "Script"
|
||||||
ThrowError -ExceptionName "System.InvalidOperationException" `
|
ThrowError -ExceptionName "System.InvalidOperationException" `
|
||||||
-ExceptionMessage $message `
|
-ExceptionMessage $message `
|
||||||
|
@ -2547,7 +2502,7 @@ function Publish-Script
|
||||||
if($Path)
|
if($Path)
|
||||||
{
|
{
|
||||||
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
|
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $scriptFilePath -or
|
if(-not $scriptFilePath -or
|
||||||
-not (Microsoft.PowerShell.Management\Test-Path -Path $scriptFilePath -PathType Leaf))
|
-not (Microsoft.PowerShell.Management\Test-Path -Path $scriptFilePath -PathType Leaf))
|
||||||
|
@ -2564,7 +2519,7 @@ function Publish-Script
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$scriptFilePath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
|
$scriptFilePath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $scriptFilePath -or
|
if(-not $scriptFilePath -or
|
||||||
-not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $scriptFilePath -PathType Leaf))
|
-not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $scriptFilePath -PathType Leaf))
|
||||||
|
@ -2718,7 +2673,7 @@ function Publish-Script
|
||||||
# Use Find-Module to check if that name is already used as module name
|
# Use Find-Module to check if that name is already used as module name
|
||||||
$modulePSGetItemInfo = Find-Module @FindParameters |
|
$modulePSGetItemInfo = Find-Module @FindParameters |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $scriptName} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $scriptName} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
if($modulePSGetItemInfo)
|
if($modulePSGetItemInfo)
|
||||||
{
|
{
|
||||||
$message = $LocalizedData.SpecifiedNameIsAlearyUsed -f ($scriptName, $Repository, 'Find-Module')
|
$message = $LocalizedData.SpecifiedNameIsAlearyUsed -f ($scriptName, $Repository, 'Find-Module')
|
||||||
|
@ -2735,7 +2690,7 @@ function Publish-Script
|
||||||
$currentPSGetItemInfo = $null
|
$currentPSGetItemInfo = $null
|
||||||
$currentPSGetItemInfo = Find-Script @FindParameters |
|
$currentPSGetItemInfo = Find-Script @FindParameters |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $scriptName} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $scriptName} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
|
|
||||||
if($currentPSGetItemInfo)
|
if($currentPSGetItemInfo)
|
||||||
{
|
{
|
||||||
|
@ -3094,7 +3049,7 @@ function Save-Script
|
||||||
if($Path)
|
if($Path)
|
||||||
{
|
{
|
||||||
$destinationPath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
|
$destinationPath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-path $destinationPath))
|
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-path $destinationPath))
|
||||||
{
|
{
|
||||||
|
@ -3112,7 +3067,7 @@ function Save-Script
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$destinationPath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
|
$destinationPath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $destinationPath))
|
if(-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $destinationPath))
|
||||||
{
|
{
|
||||||
|
@ -4479,7 +4434,7 @@ function Test-ScriptFileInfo
|
||||||
$scriptFilePath = $null
|
$scriptFilePath = $null
|
||||||
if($Path)
|
if($Path)
|
||||||
{
|
{
|
||||||
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $scriptFilePath -or -not (Microsoft.PowerShell.Management\Test-Path -Path $scriptFilePath -PathType Leaf))
|
if(-not $scriptFilePath -or -not (Microsoft.PowerShell.Management\Test-Path -Path $scriptFilePath -PathType Leaf))
|
||||||
{
|
{
|
||||||
|
@ -4495,7 +4450,7 @@ function Test-ScriptFileInfo
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$scriptFilePath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
$scriptFilePath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $scriptFilePath -or -not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $scriptFilePath -PathType Leaf))
|
if(-not $scriptFilePath -or -not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $scriptFilePath -PathType Leaf))
|
||||||
{
|
{
|
||||||
|
@ -4552,7 +4507,7 @@ function Test-ScriptFileInfo
|
||||||
|
|
||||||
$psscriptInfoComments = $CommentTokens |
|
$psscriptInfoComments = $CommentTokens |
|
||||||
Microsoft.PowerShell.Core\Where-Object { $_.Extent.Text -match "<#PSScriptInfo" } |
|
Microsoft.PowerShell.Core\Where-Object { $_.Extent.Text -match "<#PSScriptInfo" } |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $psscriptInfoComments)
|
if(-not $psscriptInfoComments)
|
||||||
{
|
{
|
||||||
|
@ -4741,20 +4696,20 @@ function Test-ScriptFileInfo
|
||||||
|
|
||||||
if($allCommands)
|
if($allCommands)
|
||||||
{
|
{
|
||||||
$allCommandNames = $allCommands | ForEach-Object {$_.Name} | Select-Object -Unique -ErrorAction Ignore
|
$allCommandNames = $allCommands | ForEach-Object {$_.Name} | Select-Object -Unique
|
||||||
ValidateAndAdd-PSScriptInfoEntry -PSScriptInfo $PSScriptInfo `
|
ValidateAndAdd-PSScriptInfoEntry -PSScriptInfo $PSScriptInfo `
|
||||||
-PropertyName $script:DefinedCommands `
|
-PropertyName $script:DefinedCommands `
|
||||||
-PropertyValue $allCommandNames `
|
-PropertyValue $allCommandNames `
|
||||||
-CallerPSCmdlet $PSCmdlet
|
-CallerPSCmdlet $PSCmdlet
|
||||||
|
|
||||||
$allFunctionNames = $allCommands | Where-Object {-not $_.IsWorkflow} | ForEach-Object {$_.Name} | Select-Object -Unique -ErrorAction Ignore
|
$allFunctionNames = $allCommands | Where-Object {-not $_.IsWorkflow} | ForEach-Object {$_.Name} | Select-Object -Unique
|
||||||
ValidateAndAdd-PSScriptInfoEntry -PSScriptInfo $PSScriptInfo `
|
ValidateAndAdd-PSScriptInfoEntry -PSScriptInfo $PSScriptInfo `
|
||||||
-PropertyName $script:DefinedFunctions `
|
-PropertyName $script:DefinedFunctions `
|
||||||
-PropertyValue $allFunctionNames `
|
-PropertyValue $allFunctionNames `
|
||||||
-CallerPSCmdlet $PSCmdlet
|
-CallerPSCmdlet $PSCmdlet
|
||||||
|
|
||||||
|
|
||||||
$allWorkflowNames = $allCommands | Where-Object {$_.IsWorkflow} | ForEach-Object {$_.Name} | Select-Object -Unique -ErrorAction Ignore
|
$allWorkflowNames = $allCommands | Where-Object {$_.IsWorkflow} | ForEach-Object {$_.Name} | Select-Object -Unique
|
||||||
ValidateAndAdd-PSScriptInfoEntry -PSScriptInfo $PSScriptInfo `
|
ValidateAndAdd-PSScriptInfoEntry -PSScriptInfo $PSScriptInfo `
|
||||||
-PropertyName $script:DefinedWorkflows `
|
-PropertyName $script:DefinedWorkflows `
|
||||||
-PropertyValue $allWorkflowNames `
|
-PropertyValue $allWorkflowNames `
|
||||||
|
@ -4926,14 +4881,7 @@ function New-ScriptFileInfo
|
||||||
|
|
||||||
if(-not $Author)
|
if(-not $Author)
|
||||||
{
|
{
|
||||||
if(IsWindows)
|
$Author = (Get-EnvironmentVariable -Name 'USERNAME' -Target $script:EnvironmentVariableTarget.Process -ErrorAction SilentlyContinue)
|
||||||
{
|
|
||||||
$Author = (Get-EnvironmentVariable -Name 'USERNAME' -Target $script:EnvironmentVariableTarget.Process -ErrorAction SilentlyContinue)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$Author = $env:USER
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(-not $Guid)
|
if(-not $Guid)
|
||||||
|
@ -4990,7 +4938,7 @@ function New-ScriptFileInfo
|
||||||
$ScriptMetadataString += $ScriptCommentHelpInfoString
|
$ScriptMetadataString += $ScriptCommentHelpInfoString
|
||||||
$ScriptMetadataString += "Param()`r`n`r`n"
|
$ScriptMetadataString += "Param()`r`n`r`n"
|
||||||
|
|
||||||
$tempScriptFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:TempPath -ChildPath "$(Get-Random).ps1"
|
$tempScriptFilePath = Microsoft.PowerShell.Management\Join-Path -Path $env:TEMP -ChildPath "$(Get-Random).ps1"
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -5137,7 +5085,7 @@ function Update-ScriptFileInfo
|
||||||
if($Path)
|
if($Path)
|
||||||
{
|
{
|
||||||
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
|
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $scriptFilePath -or
|
if(-not $scriptFilePath -or
|
||||||
-not (Microsoft.PowerShell.Management\Test-Path -Path $scriptFilePath -PathType Leaf))
|
-not (Microsoft.PowerShell.Management\Test-Path -Path $scriptFilePath -PathType Leaf))
|
||||||
|
@ -5154,7 +5102,7 @@ function Update-ScriptFileInfo
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$scriptFilePath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
|
$scriptFilePath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $scriptFilePath -or
|
if(-not $scriptFilePath -or
|
||||||
-not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $scriptFilePath -PathType Leaf))
|
-not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $scriptFilePath -PathType Leaf))
|
||||||
|
@ -5214,14 +5162,7 @@ function Update-ScriptFileInfo
|
||||||
|
|
||||||
if(-not $Author)
|
if(-not $Author)
|
||||||
{
|
{
|
||||||
if(IsWindows)
|
$Author = (Get-EnvironmentVariable -Name 'USERNAME' -Target $script:EnvironmentVariableTarget.Process -ErrorAction SilentlyContinue)
|
||||||
{
|
|
||||||
$Author = (Get-EnvironmentVariable -Name 'USERNAME' -Target $script:EnvironmentVariableTarget.Process -ErrorAction SilentlyContinue)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$Author = $env:USER
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(-not $Guid)
|
if(-not $Guid)
|
||||||
|
@ -5358,7 +5299,7 @@ function Update-ScriptFileInfo
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$tempScriptFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:TempPath -ChildPath "$(Get-Random).ps1"
|
$tempScriptFilePath = Microsoft.PowerShell.Management\Join-Path -Path $env:TEMP -ChildPath "$(Get-Random).ps1"
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -5414,7 +5355,7 @@ function Update-ScriptFileInfo
|
||||||
|
|
||||||
$psscriptInfoComments = $CommentTokens |
|
$psscriptInfoComments = $CommentTokens |
|
||||||
Microsoft.PowerShell.Core\Where-Object { $_.Extent.Text -match "<#PSScriptInfo" } |
|
Microsoft.PowerShell.Core\Where-Object { $_.Extent.Text -match "<#PSScriptInfo" } |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $psscriptInfoComments)
|
if(-not $psscriptInfoComments)
|
||||||
{
|
{
|
||||||
|
@ -6041,15 +5982,10 @@ function Check-PSGalleryApiAvailability
|
||||||
{
|
{
|
||||||
$connected = Microsoft.PowerShell.Management\Test-Connection -ComputerName $microsoftDomain -Count 1 -Quiet
|
$connected = Microsoft.PowerShell.Management\Test-Connection -ComputerName $microsoftDomain -Count 1 -Quiet
|
||||||
}
|
}
|
||||||
elseif(Get-Command NetTCPIP\Test-Connection -ErrorAction Ignore)
|
else
|
||||||
{
|
{
|
||||||
$connected = NetTCPIP\Test-NetConnection -ComputerName $microsoftDomain -InformationLevel Quiet
|
$connected = NetTCPIP\Test-NetConnection -ComputerName $microsoftDomain -InformationLevel Quiet
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$connected = [System.Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable()
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( -not $connected)
|
if ( -not $connected)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
@ -6189,7 +6125,7 @@ function Ping-Endpoint
|
||||||
$results = @{}
|
$results = @{}
|
||||||
|
|
||||||
$WebProxy = $null
|
$WebProxy = $null
|
||||||
if($Proxy -and (IsWindows))
|
if($Proxy)
|
||||||
{
|
{
|
||||||
$ProxyNetworkCredential = $null
|
$ProxyNetworkCredential = $null
|
||||||
if($ProxyCredential)
|
if($ProxyCredential)
|
||||||
|
@ -6197,7 +6133,7 @@ function Ping-Endpoint
|
||||||
$ProxyNetworkCredential = $ProxyCredential.GetNetworkCredential()
|
$ProxyNetworkCredential = $ProxyCredential.GetNetworkCredential()
|
||||||
}
|
}
|
||||||
|
|
||||||
$WebProxy = New-Object Microsoft.PowerShell.Commands.PowerShellGet.InternalWebProxy -ArgumentList $Proxy,$ProxyNetworkCredential
|
$WebProxy = New-Object Microsoft.PowerShell.Get.InternalWebProxy -ArgumentList $Proxy,$ProxyNetworkCredential
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HttpClientApisAvailable)
|
if(HttpClientApisAvailable)
|
||||||
|
@ -6419,11 +6355,6 @@ function ValidateAndSet-PATHVariableIfUserAccepts
|
||||||
$Request
|
$Request
|
||||||
)
|
)
|
||||||
|
|
||||||
if(-not (IsWindows))
|
|
||||||
{
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-PSGetSettingsVariable
|
Set-PSGetSettingsVariable
|
||||||
|
|
||||||
# Check and add the scope path to PATH environment variable if USER accepts the prompt.
|
# Check and add the scope path to PATH environment variable if USER accepts the prompt.
|
||||||
|
@ -7219,10 +7150,9 @@ function Install-NuGetClientBinaries
|
||||||
$Force
|
$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
if(-not (IsWindows) -or
|
if($script:NuGetProvider -and
|
||||||
($script:NuGetProvider -and
|
(-not $BootstrapNuGetExe -or
|
||||||
(-not $BootstrapNuGetExe -or
|
($script:NuGetExePath -and (Microsoft.PowerShell.Management\Test-Path -Path $script:NuGetExePath))))
|
||||||
($script:NuGetExePath -and (Microsoft.PowerShell.Management\Test-Path -Path $script:NuGetExePath)))))
|
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -7306,7 +7236,7 @@ function Install-NuGetClientBinaries
|
||||||
$_.Path -and
|
$_.Path -and
|
||||||
((Microsoft.PowerShell.Management\Split-Path -Path $_.Path -Leaf) -eq $script:NuGetExeName) -and
|
((Microsoft.PowerShell.Management\Split-Path -Path $_.Path -Leaf) -eq $script:NuGetExeName) -and
|
||||||
(-not $_.Path.StartsWith($env:windir, [System.StringComparison]::OrdinalIgnoreCase))
|
(-not $_.Path.StartsWith($env:windir, [System.StringComparison]::OrdinalIgnoreCase))
|
||||||
} | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
} | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if($nugetCmd -and $nugetCmd.Path)
|
if($nugetCmd -and $nugetCmd.Path)
|
||||||
{
|
{
|
||||||
|
@ -7322,7 +7252,7 @@ function Install-NuGetClientBinaries
|
||||||
}
|
}
|
||||||
|
|
||||||
# On Nano server we don't need NuGet.exe
|
# On Nano server we don't need NuGet.exe
|
||||||
if(-not $bootstrapNuGetProvider -and ($script:isNanoServer -or (IsCoreCLR) -or -not $BootstrapNuGetExe))
|
if(-not $bootstrapNuGetProvider -and ($script:isNanoServer -or -not $BootstrapNuGetExe))
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -7379,7 +7309,7 @@ function Install-NuGetClientBinaries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($BootstrapNuGetExe -and -not $script:isNanoServer -and -not (IsCoreCLR))
|
if($BootstrapNuGetExe -and -not $script:isNanoServer)
|
||||||
{
|
{
|
||||||
Write-Verbose -Message $LocalizedData.DownloadingNugetExe
|
Write-Verbose -Message $LocalizedData.DownloadingNugetExe
|
||||||
|
|
||||||
|
@ -7463,21 +7393,10 @@ function Test-RunningAsElevated
|
||||||
[OutputType([bool])]
|
[OutputType([bool])]
|
||||||
Param()
|
Param()
|
||||||
|
|
||||||
if(IsWindows)
|
$wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
{
|
$prp=new-object System.Security.Principal.WindowsPrincipal($wid)
|
||||||
$wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
|
$adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
|
||||||
$prp=new-object System.Security.Principal.WindowsPrincipal($wid)
|
return $prp.IsInRole($adm)
|
||||||
$adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
|
|
||||||
return $prp.IsInRole($adm)
|
|
||||||
}
|
|
||||||
elseif((IsLinux) -or (IsOSX))
|
|
||||||
{
|
|
||||||
# Permission models on *nix can be very complex, to the point that you could never possibly guess without simply trying what you need to try;
|
|
||||||
# This is totally different from Windows where you can know what you can or cannot do with/without admin rights.
|
|
||||||
return $true
|
|
||||||
}
|
|
||||||
|
|
||||||
return $false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-EscapedString
|
function Get-EscapedString
|
||||||
|
@ -7563,7 +7482,7 @@ function ValidateAndGet-ScriptDependencies
|
||||||
|
|
||||||
$psgetItemInfo = Find-Module @FindModuleArguments |
|
$psgetItemInfo = Find-Module @FindModuleArguments |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
|
|
||||||
if(-not $psgetItemInfo)
|
if(-not $psgetItemInfo)
|
||||||
{
|
{
|
||||||
|
@ -7606,7 +7525,7 @@ function ValidateAndGet-ScriptDependencies
|
||||||
|
|
||||||
$psgetItemInfo = Find-Script @FindScriptArguments |
|
$psgetItemInfo = Find-Script @FindScriptArguments |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $requiredScript} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $requiredScript} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
|
|
||||||
if(-not $psgetItemInfo)
|
if(-not $psgetItemInfo)
|
||||||
{
|
{
|
||||||
|
@ -7733,7 +7652,7 @@ function ValidateAndGet-RequiredModuleDetails
|
||||||
|
|
||||||
$psgetItemInfo = Find-Module @FindModuleArguments |
|
$psgetItemInfo = Find-Module @FindModuleArguments |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
|
|
||||||
if(-not $psgetItemInfo)
|
if(-not $psgetItemInfo)
|
||||||
{
|
{
|
||||||
|
@ -7777,7 +7696,7 @@ function ValidateAndGet-RequiredModuleDetails
|
||||||
|
|
||||||
$psgetItemInfo = Find-Module @FindModuleArguments |
|
$psgetItemInfo = Find-Module @FindModuleArguments |
|
||||||
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
|
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Last 1
|
||||||
|
|
||||||
if(-not $psgetItemInfo)
|
if(-not $psgetItemInfo)
|
||||||
{
|
{
|
||||||
|
@ -9559,7 +9478,7 @@ function Find-Package
|
||||||
|
|
||||||
if($options.ContainsKey($script:Tag))
|
if($options.ContainsKey($script:Tag))
|
||||||
{
|
{
|
||||||
$userSpecifiedTags = $options[$script:Tag] | Microsoft.PowerShell.Utility\Select-Object -Unique -ErrorAction Ignore
|
$userSpecifiedTags = $options[$script:Tag] | Microsoft.PowerShell.Utility\Select-Object -Unique
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -9570,7 +9489,7 @@ function Find-Package
|
||||||
if($options.ContainsKey('DscResource'))
|
if($options.ContainsKey('DscResource'))
|
||||||
{
|
{
|
||||||
$specifiedDscResources = $options['DscResource'] |
|
$specifiedDscResources = $options['DscResource'] |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Unique -ErrorAction Ignore |
|
Microsoft.PowerShell.Utility\Select-Object -Unique |
|
||||||
Microsoft.PowerShell.Core\ForEach-Object {"$($script:DscResource)_$_"}
|
Microsoft.PowerShell.Core\ForEach-Object {"$($script:DscResource)_$_"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9578,7 +9497,7 @@ function Find-Package
|
||||||
if($options.ContainsKey('RoleCapability'))
|
if($options.ContainsKey('RoleCapability'))
|
||||||
{
|
{
|
||||||
$specifiedRoleCapabilities = $options['RoleCapability'] |
|
$specifiedRoleCapabilities = $options['RoleCapability'] |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Unique -ErrorAction Ignore |
|
Microsoft.PowerShell.Utility\Select-Object -Unique |
|
||||||
Microsoft.PowerShell.Core\ForEach-Object {"$($script:RoleCapability)_$_"}
|
Microsoft.PowerShell.Core\ForEach-Object {"$($script:RoleCapability)_$_"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9586,7 +9505,7 @@ function Find-Package
|
||||||
if($options.ContainsKey('Command'))
|
if($options.ContainsKey('Command'))
|
||||||
{
|
{
|
||||||
$specifiedCommands = $options['Command'] |
|
$specifiedCommands = $options['Command'] |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Unique -ErrorAction Ignore |
|
Microsoft.PowerShell.Utility\Select-Object -Unique |
|
||||||
Microsoft.PowerShell.Core\ForEach-Object {"$($script:Command)_$_"}
|
Microsoft.PowerShell.Core\ForEach-Object {"$($script:Command)_$_"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9594,7 +9513,7 @@ function Find-Package
|
||||||
if($options.ContainsKey('Includes'))
|
if($options.ContainsKey('Includes'))
|
||||||
{
|
{
|
||||||
$includes = $options['Includes'] |
|
$includes = $options['Includes'] |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Unique -ErrorAction Ignore |
|
Microsoft.PowerShell.Utility\Select-Object -Unique |
|
||||||
Microsoft.PowerShell.Core\ForEach-Object {"$($script:Includes)_$_"}
|
Microsoft.PowerShell.Core\ForEach-Object {"$($script:Includes)_$_"}
|
||||||
|
|
||||||
# Add PSIncludes_DscResource to $specifiedIncludes iff -DscResource names are not specified
|
# Add PSIncludes_DscResource to $specifiedIncludes iff -DscResource names are not specified
|
||||||
|
@ -10509,7 +10428,7 @@ function Install-PackageUtility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$InstalledItemsList | Select-Object -Unique -ErrorAction Ignore
|
$InstalledItemsList | Select-Object -Unique
|
||||||
|
|
||||||
if($Debug)
|
if($Debug)
|
||||||
{
|
{
|
||||||
|
@ -10595,11 +10514,11 @@ function Install-PackageUtility
|
||||||
$InstalledItemDetails = $null
|
$InstalledItemDetails = $null
|
||||||
if($packageType -eq $script:PSArtifactTypeModule)
|
if($packageType -eq $script:PSArtifactTypeModule)
|
||||||
{
|
{
|
||||||
$InstalledItemDetails = Get-InstalledModuleDetails -Name $pkg.Name | Select-Object -Last 1 -ErrorAction Ignore
|
$InstalledItemDetails = Get-InstalledModuleDetails -Name $pkg.Name | Select-Object -Last 1
|
||||||
}
|
}
|
||||||
elseif($packageType -eq $script:PSArtifactTypeScript)
|
elseif($packageType -eq $script:PSArtifactTypeScript)
|
||||||
{
|
{
|
||||||
$InstalledItemDetails = Get-InstalledScriptDetails -Name $pkg.Name | Select-Object -Last 1 -ErrorAction Ignore
|
$InstalledItemDetails = Get-InstalledScriptDetails -Name $pkg.Name | Select-Object -Last 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if($InstalledItemDetails -and
|
if($InstalledItemDetails -and
|
||||||
|
@ -11020,11 +10939,11 @@ function Uninstall-Package
|
||||||
}
|
}
|
||||||
$dependentModulesJob = Microsoft.PowerShell.Core\Start-Job -ScriptBlock $dependentModuleScript -ArgumentList $moduleName
|
$dependentModulesJob = Microsoft.PowerShell.Core\Start-Job -ScriptBlock $dependentModuleScript -ArgumentList $moduleName
|
||||||
Microsoft.PowerShell.Core\Wait-Job -job $dependentModulesJob
|
Microsoft.PowerShell.Core\Wait-Job -job $dependentModulesJob
|
||||||
$dependentModules = Microsoft.PowerShell.Core\Receive-Job -job $dependentModulesJob -ErrorAction Ignore
|
$dependentModules = Microsoft.PowerShell.Core\Receive-Job -job $dependentModulesJob
|
||||||
|
|
||||||
if(-not $Force -and $dependentModules)
|
if(-not $Force -and $dependentModules)
|
||||||
{
|
{
|
||||||
$message = $LocalizedData.UnableToUninstallAsOtherModulesNeedThisModule -f ($moduleName, $version, $moduleBase, $(($dependentModules.Name | Select-Object -Unique -ErrorAction Ignore) -join ','), $moduleName)
|
$message = $LocalizedData.UnableToUninstallAsOtherModulesNeedThisModule -f ($moduleName, $version, $moduleBase, $(($dependentModules.Name | Select-Object -Unique) -join ','), $moduleName)
|
||||||
|
|
||||||
ThrowError -ExceptionName "System.InvalidOperationException" `
|
ThrowError -ExceptionName "System.InvalidOperationException" `
|
||||||
-ExceptionMessage $message `
|
-ExceptionMessage $message `
|
||||||
|
@ -11170,7 +11089,7 @@ function Uninstall-Package
|
||||||
($scriptName,
|
($scriptName,
|
||||||
$version,
|
$version,
|
||||||
$scriptBase,
|
$scriptBase,
|
||||||
$(($dependentScriptNames | Select-Object -Unique -ErrorAction Ignore) -join ','),
|
$(($dependentScriptNames | Select-Object -Unique) -join ','),
|
||||||
$scriptName)
|
$scriptName)
|
||||||
|
|
||||||
ThrowError -ExceptionName 'System.InvalidOperationException' `
|
ThrowError -ExceptionName 'System.InvalidOperationException' `
|
||||||
|
@ -11715,20 +11634,11 @@ function Set-InstalledModulesVariable
|
||||||
foreach ($location in $modulePaths)
|
foreach ($location in $modulePaths)
|
||||||
{
|
{
|
||||||
# find all modules installed using PowerShellGet
|
# find all modules installed using PowerShellGet
|
||||||
$GetChildItemParams = @{
|
$moduleBases = Get-ChildItem $location -Recurse `
|
||||||
Path = $location
|
-Attributes Hidden -Filter $script:PSGetItemInfoFileName `
|
||||||
Recurse = $true
|
-ErrorAction SilentlyContinue `
|
||||||
Filter = $script:PSGetItemInfoFileName
|
-WarningAction SilentlyContinue `
|
||||||
ErrorAction = 'SilentlyContinue'
|
| Foreach-Object { $_.Directory }
|
||||||
WarningAction = 'SilentlyContinue'
|
|
||||||
}
|
|
||||||
|
|
||||||
if(IsWindows)
|
|
||||||
{
|
|
||||||
$GetChildItemParams['Attributes'] = 'Hidden'
|
|
||||||
}
|
|
||||||
|
|
||||||
$moduleBases = Get-ChildItem @GetChildItemParams | Foreach-Object { $_.Directory }
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($moduleBase in $moduleBases)
|
foreach ($moduleBase in $moduleBases)
|
||||||
|
@ -12042,7 +11952,7 @@ function Log-ArtifactNotFoundInPSGallery
|
||||||
# Perform Telemetry only if searched artifacts are not available in specified Gallery
|
# Perform Telemetry only if searched artifacts are not available in specified Gallery
|
||||||
if ($notFoundArtifacts)
|
if ($notFoundArtifacts)
|
||||||
{
|
{
|
||||||
[Microsoft.PowerShell.Commands.PowerShellGet.Telemetry]::TraceMessageArtifactsNotFound($notFoundArtifacts, $operationName)
|
[Microsoft.PowerShell.Get.Telemetry]::TraceMessageArtifactsNotFound($notFoundArtifacts, $operationName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12102,7 +12012,7 @@ function Log-NonPSGalleryRegistration
|
||||||
$scriptPublishLocationHash = Get-Hash -locationString $scriptPublishLocation
|
$scriptPublishLocationHash = Get-Hash -locationString $scriptPublishLocation
|
||||||
|
|
||||||
# Log the telemetry event
|
# Log the telemetry event
|
||||||
[Microsoft.PowerShell.Commands.PowerShellGet.Telemetry]::TraceMessageNonPSGalleryRegistration($sourceLocationType, $sourceLocationHash, $installationPolicy, $packageManagementProvider, $publishLocationHash, $scriptSourceLocationHash, $scriptPublishLocationHash, $operationName)
|
[Microsoft.PowerShell.Get.Telemetry]::TraceMessageNonPSGalleryRegistration($sourceLocationType, $sourceLocationHash, $installationPolicy, $packageManagementProvider, $publishLocationHash, $scriptSourceLocationHash, $scriptPublishLocationHash, $operationName)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns a SHA1 hash of the specified string
|
# Returns a SHA1 hash of the specified string
|
||||||
|
@ -12256,7 +12166,7 @@ function Test-ModuleInstalled
|
||||||
# Check if module is already installed
|
# Check if module is already installed
|
||||||
$availableModule = Microsoft.PowerShell.Core\Get-Module -ListAvailable -Name $Name -Verbose:$false |
|
$availableModule = Microsoft.PowerShell.Core\Get-Module -ListAvailable -Name $Name -Verbose:$false |
|
||||||
Microsoft.PowerShell.Core\Where-Object {-not (Test-ModuleSxSVersionSupport) -or -not $RequiredVersion -or ($RequiredVersion -eq $_.Version)} |
|
Microsoft.PowerShell.Core\Where-Object {-not (Test-ModuleSxSVersionSupport) -or -not $RequiredVersion -or ($RequiredVersion -eq $_.Version)} |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -Unique -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -Unique
|
||||||
|
|
||||||
return $availableModule
|
return $availableModule
|
||||||
}
|
}
|
||||||
|
@ -12317,7 +12227,7 @@ function Test-ScriptInstalled
|
||||||
|
|
||||||
$scriptInfo = $scriptInfos | Microsoft.PowerShell.Core\Where-Object {
|
$scriptInfo = $scriptInfos | Microsoft.PowerShell.Core\Where-Object {
|
||||||
(-not $RequiredVersion) -or ($RequiredVersion -eq $_.Version)
|
(-not $RequiredVersion) -or ($RequiredVersion -eq $_.Version)
|
||||||
} | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
} | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
return $scriptInfo
|
return $scriptInfo
|
||||||
}
|
}
|
||||||
|
@ -12545,7 +12455,7 @@ function Update-ModuleManifest
|
||||||
$ProcessorArchitecture,
|
$ProcessorArchitecture,
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('WindowsPowerShell','PowerShellCore')]
|
[ValidateSet('Desktop','Core')]
|
||||||
[string[]]
|
[string[]]
|
||||||
$CompatiblePSEditions,
|
$CompatiblePSEditions,
|
||||||
|
|
||||||
|
@ -13910,7 +13820,7 @@ function Validate-ModuleCommandAlreadyAvailable
|
||||||
-WarningAction SilentlyContinue |
|
-WarningAction SilentlyContinue |
|
||||||
Microsoft.PowerShell.Core\Where-Object { ($CommandNames -contains $_.Name) -and
|
Microsoft.PowerShell.Core\Where-Object { ($CommandNames -contains $_.Name) -and
|
||||||
($_.Source -ne $CurrentModuleInfo.Name) } |
|
($_.Source -ne $CurrentModuleInfo.Name) } |
|
||||||
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction SilentlyContinue
|
||||||
if($AvailableCommand)
|
if($AvailableCommand)
|
||||||
{
|
{
|
||||||
$message = $LocalizedData.ModuleCommandAlreadyAvailable -f ($AvailableCommand.Name, $CurrentModuleInfo.Name)
|
$message = $LocalizedData.ModuleCommandAlreadyAvailable -f ($AvailableCommand.Name, $CurrentModuleInfo.Name)
|
||||||
|
@ -14085,11 +13995,11 @@ function Get-InstalledModuleAuthenticodeSignature
|
||||||
|
|
||||||
$SourceModule = $AvailableModules | Microsoft.PowerShell.Core\Where-Object {
|
$SourceModule = $AvailableModules | Microsoft.PowerShell.Core\Where-Object {
|
||||||
$_.ModuleBase.StartsWith($InstallLocation, [System.StringComparison]::OrdinalIgnoreCase)
|
$_.ModuleBase.StartsWith($InstallLocation, [System.StringComparison]::OrdinalIgnoreCase)
|
||||||
} | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
} | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
|
|
||||||
if(-not $SourceModule)
|
if(-not $SourceModule)
|
||||||
{
|
{
|
||||||
$SourceModule = $AvailableModules | Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
|
$SourceModule = $AvailableModules | Microsoft.PowerShell.Utility\Select-Object -First 1
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -14147,8 +14057,6 @@ function Test-MicrosoftCertificate
|
||||||
$AuthenticodeSignature
|
$AuthenticodeSignature
|
||||||
)
|
)
|
||||||
|
|
||||||
$result = $false
|
|
||||||
|
|
||||||
if($AuthenticodeSignature.SignerCertificate)
|
if($AuthenticodeSignature.SignerCertificate)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -14162,11 +14070,10 @@ function Test-MicrosoftCertificate
|
||||||
}
|
}
|
||||||
|
|
||||||
$SafeX509ChainHandle = [Microsoft.PowerShell.Commands.PowerShellGet.Win32Helpers]::CertDuplicateCertificateChain($X509Chain.ChainContext)
|
$SafeX509ChainHandle = [Microsoft.PowerShell.Commands.PowerShellGet.Win32Helpers]::CertDuplicateCertificateChain($X509Chain.ChainContext)
|
||||||
$result = [Microsoft.PowerShell.Commands.PowerShellGet.Win32Helpers]::IsMicrosoftCertificate($SafeX509ChainHandle)
|
return [Microsoft.PowerShell.Commands.PowerShellGet.Win32Helpers]::IsMicrosoftCertificate($SafeX509ChainHandle)
|
||||||
$SafeX509ChainHandle.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result
|
return $false
|
||||||
}
|
}
|
||||||
|
|
||||||
function Test-ValidManifestModule
|
function Test-ValidManifestModule
|
||||||
|
@ -14215,7 +14122,7 @@ function Test-ValidManifestModule
|
||||||
-CallerPSCmdlet $PSCmdlet `
|
-CallerPSCmdlet $PSCmdlet `
|
||||||
-ErrorCategory InvalidOperation
|
-ErrorCategory InvalidOperation
|
||||||
}
|
}
|
||||||
elseif(IsWindows)
|
else
|
||||||
{
|
{
|
||||||
$ValidationResult = Validate-ModuleAuthenticodeSignature -CurrentModuleInfo $PSModuleInfo `
|
$ValidationResult = Validate-ModuleAuthenticodeSignature -CurrentModuleInfo $PSModuleInfo `
|
||||||
-InstallLocation $InstallLocation `
|
-InstallLocation $InstallLocation `
|
||||||
|
|
Binary file not shown.
|
@ -1,8 +1,8 @@
|
||||||
@{
|
@{
|
||||||
GUID="1DA87E53-152B-403E-98DC-74D7B4D63D59"
|
GUID="1DA87E53-152B-403E-98DC-74D7B4D63D59"
|
||||||
Author="Microsoft Corporation"
|
Author="Microsoft Corporation"
|
||||||
CompanyName="Microsoft Corporation"
|
CompanyName="Microsoft Corporation"
|
||||||
Copyright="© Microsoft Corporation. All rights reserved."
|
Copyright="© Microsoft Corporation. All rights reserved."
|
||||||
ModuleVersion="3.1.0.0"
|
ModuleVersion="3.1.0.0"
|
||||||
PowerShellVersion="3.0"
|
PowerShellVersion="3.0"
|
||||||
CmdletsToExport= "Format-List", "Format-Custom", "Format-Table", "Format-Wide",
|
CmdletsToExport= "Format-List", "Format-Custom", "Format-Table", "Format-Wide",
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -10,6 +10,6 @@ AliasesToExport = @()
|
||||||
FunctionsToExport = @()
|
FunctionsToExport = @()
|
||||||
CmdletsToExport="Disable-WSManCredSSP", "Enable-WSManCredSSP", "Get-WSManCredSSP", "Set-WSManQuickConfig", "Test-WSMan", "Invoke-WSManAction", "Connect-WSMan", "Disconnect-WSMan", "Get-WSManInstance", "Set-WSManInstance", "Remove-WSManInstance", "New-WSManInstance", "New-WSManSessionOption"
|
CmdletsToExport="Disable-WSManCredSSP", "Enable-WSManCredSSP", "Get-WSManCredSSP", "Set-WSManQuickConfig", "Test-WSMan", "Invoke-WSManAction", "Connect-WSMan", "Disconnect-WSMan", "Get-WSManInstance", "Set-WSManInstance", "Remove-WSManInstance", "New-WSManInstance", "New-WSManSessionOption"
|
||||||
NestedModules="Microsoft.WSMan.Management.dll"
|
NestedModules="Microsoft.WSMan.Management.dll"
|
||||||
FormatsToProcess="WSMan.format.ps1xml"
|
FormatsToProcess="..\..\WSMan.format.ps1xml"
|
||||||
HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=390788'
|
HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=390788'
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -10,7 +10,7 @@ AliasesToExport = @()
|
||||||
FunctionsToExport = @()
|
FunctionsToExport = @()
|
||||||
CmdletsToExport="Get-WinEvent", "Get-Counter", "Import-Counter", "Export-Counter", "New-WinEvent"
|
CmdletsToExport="Get-WinEvent", "Get-Counter", "Import-Counter", "Export-Counter", "New-WinEvent"
|
||||||
NestedModules="Microsoft.PowerShell.Commands.Diagnostics.dll"
|
NestedModules="Microsoft.PowerShell.Commands.Diagnostics.dll"
|
||||||
TypesToProcess="GetEvent.types.ps1xml"
|
TypesToProcess="..\..\GetEvent.types.ps1xml"
|
||||||
FormatsToProcess="Event.format.ps1xml","Diagnostics.format.ps1xml"
|
FormatsToProcess="..\..\Event.format.ps1xml","..\..\Diagnostics.format.ps1xml"
|
||||||
HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=390783'
|
HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=390783'
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue