diff --git a/build.psm1 b/build.psm1 index ed1709f39..f830a5d71 100644 --- a/build.psm1 +++ b/build.psm1 @@ -697,7 +697,7 @@ function Copy-MappedFiles { # Do some intelligens to prevent shouting us in the foot with CL management # finding base-line CL - $cl = git tag | % {if ($_ -match 'SD.(\d+)$') {[int]$Matches[1]} } | sort -Descending | select -First 1 + $cl = git --git-dir="$PSScriptRoot/.git" tag | % {if ($_ -match 'SD.(\d+)$') {[int]$Matches[1]} } | Sort-Object -Descending | Select-Object -First 1 if ($cl) { Write-Host -ForegroundColor Green "Current base-line CL is SD:$cl (based on tags)" @@ -743,15 +743,15 @@ function Copy-MappedFiles { end { $map.GetEnumerator() | % { - mkdir (Split-Path $_.Value) -ErrorAction SilentlyContinue > $null + New-Item -ItemType Directory (Split-Path $_.Value) -ErrorAction SilentlyContinue > $null if ($PSBoundParameters['Verbose']) { - cp $_.Key $_.Value -Verbose + Copy-Item $_.Key $_.Value -Verbose } else { - cp $_.Key $_.Value + Copy-Item $_.Key $_.Value } } } @@ -799,7 +799,7 @@ function Get-Mappings { $map = @{} $mapFiles | % { - $rawHashtable = $_ | cat -Raw | ConvertFrom-Json | Convert-PSObjectToHashtable + $rawHashtable = $_ | Get-Content -Raw | ConvertFrom-Json | Convert-PSObjectToHashtable $mapRoot = Split-Path $_.FullName if ($KeepRelativePaths) { @@ -860,7 +860,7 @@ function Send-GitDiffToSd { Set-Content -Value $diff -Path $env:TEMP\diff -Encoding Ascii if ($WhatIf) { Write-Host -Foreground Green "Patch content" - cat $env:TEMP\diff + Get-Content $env:TEMP\diff } else { & $patchPath --binary -p1 $sdFilePath $env:TEMP\diff } diff --git a/src/Microsoft.PowerShell.ConsoleHost/map.json b/src/Microsoft.PowerShell.ConsoleHost/map.json index 5277a8d1d..10b79cf1d 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/map.json +++ b/src/Microsoft.PowerShell.ConsoleHost/map.json @@ -10,7 +10,7 @@ "monad/src/host/msh/resources/ProgressNodeStrings.resx": "resources/ProgressNodeStrings.resx", "monad/src/host/msh/resources/ConsoleHostRawUserInterfaceStrings.resx": "resources/ConsoleHostRawUserInterfaceStrings.resx", "monad/src/host/msh/PendingProgress.cs": "host/msh/PendingProgress.cs", - "monad/src/host/msh/ConsoleTextWriter.cs": "host/msh/ConsoleTextWriter.cs", + "monad/src/host/msh/Consoletextwriter.cs": "host/msh/ConsoleTextWriter.cs", "monad/src/host/msh/resources/ConsoleControlStrings.resx": "resources/ConsoleControlStrings.resx", "monad/src/host/msh/ConsoleHostUserInterfacePromptForChoice.cs": "host/msh/ConsoleHostUserInterfacePromptForChoice.cs", "monad/src/host/msh/ConsoleShell.cs": "host/msh/ConsoleShell.cs", diff --git a/src/System.Management.Automation/map.json b/src/System.Management.Automation/map.json index 686728edb..17e1a5370 100644 --- a/src/System.Management.Automation/map.json +++ b/src/System.Management.Automation/map.json @@ -472,7 +472,6 @@ "monad/src/engine/resources/Authenticode.resx": "resources/Authenticode.resx", "monad/src/engine/COM/ComUtil.cs": "engine/COM/ComUtil.cs", "monad/src/engine/hostifaces/MshHostUserInterface.cs": "engine/hostifaces/MshHostUserInterface.cs", - "monad/src/utils/ArchitectureSensitiveAttribute.cs": "utils/ArchitectureSensitiveAttribute.cs", "monad/src/engine/DriveInterfaces.cs": "engine/DriveInterfaces.cs", "monad/src/engine/ComInterop/Errors.cs": "engine/ComInterop/Errors.cs", "monad/src/singleshell/config/MshConsoleInfo.cs": "singleshell/config/MshConsoleInfo.cs", diff --git a/src/System.Management.Automation/utils/ArchitectureSensitiveAttribute.cs b/src/System.Management.Automation/utils/ArchitectureSensitiveAttribute.cs deleted file mode 100644 index 9cf302f0f..000000000 --- a/src/System.Management.Automation/utils/ArchitectureSensitiveAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -/********************************************************************++ -Copyright (c) Microsoft Corporation. All rights reserved. ---********************************************************************/ - -using System; -using System.Reflection; - -namespace System.Management.Automation.Internal -{ - /// - /// This attribute is used for Design For Testability. - /// It should be placed on any method containing code - /// which is likely to be sensitive to X86/X64/IA64 issues, - /// primarily code which calls DllImports or otherwise uses - /// NativeMethods. This allows us to generate code coverage - /// data specific to architecture sensitive code. - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] - internal class ArchitectureSensitiveAttribute : Attribute - { - /// - /// Constructor for the ArchitectureSensitiveAttribute class. - /// - internal ArchitectureSensitiveAttribute () - { - } - } -} diff --git a/src/powershell-native/CMakeLists.txt b/src/powershell-native/CMakeLists.txt index 581179158..885acfcbe 100644 --- a/src/powershell-native/CMakeLists.txt +++ b/src/powershell-native/CMakeLists.txt @@ -25,7 +25,6 @@ add_definitions(-DUNICODE) add_definitions(-D_UNICODE) add_executable(powershell WIN32 - nativemsh/pwrshcommon/ConfigFileReader.cpp nativemsh/pwrshcommon/pwrshcommon.cpp nativemsh/pwrshcommon/WinSystemCallFacade.cpp diff --git a/src/powershell-native/map.json b/src/powershell-native/map.json index 6e047a599..cdcb1cc0e 100644 --- a/src/powershell-native/map.json +++ b/src/powershell-native/map.json @@ -1,8 +1,6 @@ { "monad/nttargets/assemblies/nativemsh/pwrshexe/OutputWriter.h": "nativemsh/pwrshexe/OutputWriter.h", - "monad/nttargets/assemblies/nativemsh/pwrshcommon/ConfigFileReader.cpp": "nativemsh/pwrshcommon/ConfigFileReader.cpp", "monad/nttargets/assemblies/nativemsh/pwrshcommon/NativeMsh.h": "nativemsh/pwrshcommon/NativeMsh.h", - "monad/nttargets/assemblies/nativemsh/pwrshcommon/ConfigFileReader.h": "nativemsh/pwrshcommon/ConfigFileReader.h", "monad/nttargets/assemblies/nativemsh/pwrshcommon/pwrshcommon.cpp": "nativemsh/pwrshcommon/pwrshcommon.cpp", "monad/nttargets/assemblies/nativemsh/pwrshcommon/SystemCallFacade.h": "nativemsh/pwrshcommon/SystemCallFacade.h", "monad/nttargets/assemblies/nativemsh/pwrshcommon/WinSystemCallFacade.cpp": "nativemsh/pwrshcommon/WinSystemCallFacade.cpp", diff --git a/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.cpp b/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.cpp deleted file mode 100644 index a070b6782..000000000 --- a/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// ---------------------------------------------------------------------- -// -// Microsoft Windows NT -// Copyright (C) Microsoft Corporation, 2014. -// -// Contents: Source code for abstraction of CLR and worker differences between PowerShell versions. -// pwrshplugin is totally unmanaged. -// ---------------------------------------------------------------------- - -#include -#include -#include - -#include "NativeMsh.h" -#include "ConfigFileReader.h" - -namespace NativeMsh -{ - // The name of the PowerShell config file that identifies the PowerShell install location. - // We use a config file to avoid writing to the registry during install. - static PCWSTR powerShellConfigFileName = L"PowerShellConfig.txt"; - - ConfigFileReader::ConfigFileReader() - { - } - - unsigned int ConfigFileReader::Read( - std::wstring pathToConfig) - { - std::wstring absolutePathToConfigFile(pathToConfig); - absolutePathToConfigFile += powerShellConfigFileName; - std::wfstream psConfigFile(absolutePathToConfigFile.c_str()); - - if (!psConfigFile.is_open()) - { - return EXIT_CODE_INIT_FAILURE; - } - - std::wstring line; - std::wstring psRootTag(L"PSROOTDIR="); - while (std::getline(psConfigFile, line)) - { - this->pathToPowerShellAssemblies = this->getValueFromLine(line, psRootTag); - if (this->pathToPowerShellAssemblies.size() > 0) // Found a match - { - std::wstring::const_iterator iter = this->pathToPowerShellAssemblies.end(); - if (*iter != L'\\') - { - // Guarantee that there is a '\' at the end of the path - this->pathToPowerShellAssemblies.append(L"\\"); - } - break; - } - } - - if (0 == this->pathToPowerShellAssemblies.size()) - { - return EXIT_CODE_INIT_FAILURE; - } - else - { - return EXIT_CODE_SUCCESS; - } - } - - // This trim function removes beginning and ending whitespace. It does not - // remove internal whitespace because that is valid within paths. - std::wstring ConfigFileReader::trim( - const std::wstring& toTrim) - { - static PCWSTR WHITESPACE_CHARS = L" \n\r\t"; - std::wstring copyToTrim = toTrim; - std::size_t first = copyToTrim.find_first_not_of(WHITESPACE_CHARS); - - if (first == std::wstring::npos) - { - // No non-whitespace found - return std::wstring(L""); - } - - // Result not checked for std::wstring::npos because it is guaranteed to have a value if the first pass succeeded. - copyToTrim.erase(copyToTrim.find_last_not_of(WHITESPACE_CHARS)+1); - - return copyToTrim.substr(first); - } - - // Parses the specified line for the given tag - std::wstring ConfigFileReader::getValueFromLine( - const std::wstring& line, // Passed by value to preserve the original line. - std::wstring& tagToFind) - { - std::wstring trimmedLine = this->trim(line); - std::size_t index = trimmedLine.find(tagToFind); - if (std::string::npos != index) - { - std::wstring value = trimmedLine.substr(index + tagToFind.size()); // Everything else after the tag - return this->trim(value); - } - else - { - return std::wstring(L""); - } - } -} diff --git a/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.h b/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.h deleted file mode 100644 index 7e2d4454b..000000000 --- a/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.h +++ /dev/null @@ -1,34 +0,0 @@ -// ---------------------------------------------------------------------- -// -// Microsoft Windows NT -// Copyright (C) Microsoft Corporation, 2014. -// -// Contents: Source code for abstraction of CLR and worker differences between PowerShell versions. -// pwrshplugin is totally unmanaged. -// ---------------------------------------------------------------------- - -#pragma once - -#include - -namespace NativeMsh -{ - class ConfigFileReader - { - protected: - std::wstring pathToPowerShellAssemblies; - - protected: - std::wstring trim(const std::wstring& toTrim); - - std::wstring getValueFromLine(const std::wstring& line, std::wstring& tagToFind); - - public: - ConfigFileReader(); - - virtual unsigned int Read(std::wstring pathToConfig); - - // Information Getters - std::wstring GetPathToPowerShell() { return pathToPowerShellAssemblies; } - }; -} // namespace NativeMsh \ No newline at end of file