Port PowerShell to .NET Core 3.0 (#9597)

This commit is contained in:
Steve Lee 2019-05-20 22:43:51 -07:00 committed by Dongbo Wang
parent afa76dec23
commit 29e21470d9
43 changed files with 695 additions and 631 deletions

View file

@ -62,6 +62,8 @@
Tracking Issue https://github.com/dotnet/sdk/issues/1557
-->
<PackageVersion>$(PSCoreBuildVersion)</PackageVersion>
<ApplicationIcon Condition="$(ProductVersion.Contains('preview'))">..\..\assets\Powershell_av_colors.ico</ApplicationIcon>
<ApplicationIcon Condition="!$(ProductVersion.Contains('preview'))">..\..\assets\Powershell_black.ico</ApplicationIcon>
</PropertyGroup>
@ -93,9 +95,8 @@
<Company>Microsoft Corporation</Company>
<Copyright>(c) Microsoft Corporation. All rights reserved.</Copyright>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.8</RuntimeFrameworkVersion>
<LangVersion>Latest</LangVersion>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
# On Windows paths is separated by semicolon
$script:TestModulePathSeparator = [System.IO.Path]::PathSeparator
$dotnetCLIChannel = "release"
$dotnetCLIChannel = 'preview' # TODO: Change this to 'release' once .Net Core 3.0 goes RTM
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
# Track if tags have been sync'ed
@ -410,7 +410,7 @@ Fix steps:
Pop-Location
}
# publish netcoreapp2.1 reference assemblies
# publish reference assemblies
try {
Push-Location "$PSScriptRoot/src/TypeCatalogGen"
$refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') }
@ -449,51 +449,6 @@ Fix steps:
}
}
if ($Environment.IsWindows) {
## need RCEdit to modify the binaries embedded resources
$rcedit = "~/.rcedit/rcedit-x64.exe"
if (-not (Test-Path -Type Leaf $rcedit)) {
$rcedit = Get-Command "rcedit-x64.exe" -CommandType Application -ErrorAction Ignore | Select-Object -First 1 | ForEach-Object Name
}
if (-not $rcedit) {
throw "RCEdit is required to modify pwsh.exe resources, please run 'Start-PSBootStrap' to install"
}
$ReleaseVersion = ""
if ($ReleaseTagToUse) {
$ReleaseVersion = $ReleaseTagToUse
} else {
$ReleaseVersion = (Get-PSCommitId -WarningAction SilentlyContinue) -replace '^v'
}
# in VSCode, depending on where you started it from, the git commit id may be empty so provide a default value
if (!$ReleaseVersion) {
$ReleaseVersion = "6.0.0"
$fileVersion = "6.0.0"
} else {
$fileVersion = $ReleaseVersion.Split("-")[0]
}
# in VSCode, the build output folder doesn't include the name of the exe so we have to add it for rcedit
$pwshPath = $Options.Output
if (!$pwshPath.EndsWith("pwsh.exe")) {
$pwshPath = Join-Path $Options.Output "pwsh.exe"
}
if (Test-IsPreview $ReleaseVersion) {
$iconPath = "$PSScriptRoot\assets\Powershell_av_colors.ico"
} else {
$iconPath = "$PSScriptRoot\assets\Powershell_black.ico"
}
# fxdependent package does not have an executable to set iconPath etc.
if ($Options.Runtime -ne 'fxdependent') {
Start-NativeExecution { & $rcedit $pwshPath --set-icon $iconPath `
--set-file-version $fileVersion --set-product-version $ReleaseVersion --set-version-string "ProductName" "PowerShell 7" `
--set-version-string "LegalCopyright" "(C) Microsoft Corporation. All Rights Reserved." `
--application-manifest "$PSScriptRoot\assets\pwsh.manifest" } | Write-Verbose
}
}
# download modules from powershell gallery.
# - PowerShellGet, PackageManagement, Microsoft.PowerShell.Archive
if ($PSModuleRestore) {
@ -617,8 +572,8 @@ function New-PSOptions {
[ValidateSet("Debug", "Release", "CodeCoverage", '')]
[string]$Configuration,
[ValidateSet("netcoreapp2.1")]
[string]$Framework,
[ValidateSet("netcoreapp3.0")]
[string]$Framework = "netcoreapp3.0",
# These are duplicated from Start-PSBuild
# We do not use ValidateScript since we want tab completion
@ -656,6 +611,7 @@ function New-PSOptions {
}
Write-Verbose "Using configuration '$Configuration'"
Write-Verbose "Using framework '$Framework'"
if (-not $Runtime) {
if ($Environment.IsLinux) {
@ -1741,19 +1697,6 @@ function Start-PSBootstrap {
$psInstallFile = [System.IO.Path]::Combine($PSScriptRoot, "tools", "install-powershell.ps1")
& $psInstallFile -AddToPath
}
## need RCEdit to modify the binaries embedded resources
if (-not (Test-Path "~/.rcedit/rcedit-x64.exe"))
{
Write-Log "Install RCEdit for modifying exe resources"
$rceditUrl = "https://github.com/electron/rcedit/releases/download/v1.0.0/rcedit-x64.exe"
New-Item -Path "~/.rcedit" -Type Directory -Force > $null
## need to specify TLS version 1.2 since GitHub API requires it
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -OutFile "~/.rcedit/rcedit-x64.exe" -Uri $rceditUrl
}
}
} finally {
Pop-Location
@ -1854,12 +1797,13 @@ function Start-TypeGen
<Target Name="_GetDependencies"
DependsOnTargets="ResolveAssemblyReferencesDesignTime">
<ItemGroup>
<_RefAssemblyPath Include="%(_ReferencesFromRAR.HintPath)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/>
<_RefAssemblyPath Include="%(_ReferencesFromRAR.OriginalItemSpec)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/>
</ItemGroup>
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" />
</Target>
</Project>
'@
New-Item -ItemType Directory -Path (Split-Path -Path $GetDependenciesTargetPath -Parent) -Force > $null
Set-Content -Path $GetDependenciesTargetPath -Value $GetDependenciesTargetValue -Force -Encoding Ascii
Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK"
@ -2317,7 +2261,7 @@ function Copy-PSGalleryModules
Remove-Item -Force -ErrorAction Ignore -Recurse "$Destination/$name"
New-Item -Path $dest -ItemType Directory -Force -ErrorAction Stop > $null
# Exclude files/folders that are not needed. The fullclr folder is coming from the PackageManagement module
$dontCopy = '*.nupkg', '*.nupkg.sha512', '*.nuspec', 'System.Runtime.InteropServices.RuntimeInformation.dll', 'fullclr'
$dontCopy = '*.nupkg', '*.nupkg.metadata', '*.nupkg.sha512', '*.nuspec', 'System.Runtime.InteropServices.RuntimeInformation.dll', 'fullclr'
Copy-Item -Exclude $dontCopy -Recurse $src/* $dest
}
}

View file

@ -71,7 +71,7 @@ Start-PSBuild
Congratulations! If everything went right, PowerShell is now built.
The `Start-PSBuild` script will output the location of the executable:
`./src/powershell-unix/bin/Debug/netcoreapp2.1/linux-x64/publish/pwsh`.
`./src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish/pwsh`.
You should now be running the PowerShell Core that you just built, if your run the above executable.
You can run our cross-platform Pester tests with `Start-PSPester`, and our xUnit tests with `Start-PSxUnit`.

View file

@ -36,4 +36,4 @@ We cannot do this for you in the build module due to #[847][].
Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild` from the module.
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp2.1/osx-x64/publish/pwsh`.
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp3.0/osx-x64/publish/pwsh`.

View file

@ -58,11 +58,11 @@ Import-Module ./build.psm1
Start-PSBuild
```
Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp2.1/win7-x64/publish/pwsh.exe`.
Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp3.0/win7-x64/publish/pwsh.exe`.
This location is of the form `./[project]/bin/[configuration]/[framework]/[rid]/publish/[binary name]`,
and our project is `powershell`, configuration is `Debug` by default,
framework is `netcoreapp2.1`, runtime identifier is `win7-x64` by default,
framework is `netcoreapp3.0`, runtime identifier is `win7-x64` by default,
and binary name is `pwsh`.
The function `Get-PSOutput` will return the path to the executable;
thus you can execute the development copy via `& (Get-PSOutput)`.

View file

@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.504"
"version": "3.0.100-preview5-011568"
}
}

View file

@ -663,7 +663,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
private static IEnumerable<PortableExecutableReference> InitDefaultRefAssemblies()
{
// netcoreapp2.1 currently comes with 144 reference assemblies (maybe more in future), so we use a capacity of '150'.
// netcoreapp3.0 currently comes with 148 reference assemblies (maybe more in future), so we use a capacity of '150'.
var defaultRefAssemblies = new List<PortableExecutableReference>(150);
foreach (string file in Directory.EnumerateFiles(s_netcoreAppRefFolder, "*.dll", SearchOption.TopDirectoryOnly))

View file

@ -2,10 +2,11 @@
<PropertyGroup>
<Description>Generates C# typed bindings for .resx files</Description>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>resgen</AssemblyName>
<OutputType>Exe</OutputType>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<RuntimeIdentifiers>win7-x86;win7-x64;osx-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup>

View file

@ -60,7 +60,8 @@ namespace System.Management.Automation
private static Version s_psV4Version = new Version(4, 0);
private static Version s_psV5Version = new Version(5, 0);
private static Version s_psV51Version = new Version(5, 1, NTVerpVars.PRODUCTBUILD, NTVerpVars.PRODUCTBUILD_QFE);
private static SemanticVersion s_psV6Version;
private static SemanticVersion s_psV6Version = new SemanticVersion(6, 0, 0, null, null);
private static SemanticVersion s_psV7Version;
/// <summary>
/// A constant to track current PowerShell Edition.
@ -99,12 +100,12 @@ namespace System.Management.Automation
rawGitCommitId = mainVersion;
}
s_psV6Version = new SemanticVersion(mainVersion);
s_psV7Version = new SemanticVersion(mainVersion);
s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version;
s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV7Version;
s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue;
s_psVersionTable[PSGitCommitIdName] = rawGitCommitId;
s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version };
s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version, s_psV7Version };
s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion);
s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion();
@ -271,6 +272,11 @@ namespace System.Management.Automation
internal static bool IsValidPSVersion(Version version)
{
if (version.Major == s_psV7Version.Major)
{
return version.Minor == s_psV7Version.Minor;
}
if (version.Major == s_psV6Version.Major)
{
return version.Minor == s_psV6Version.Minor;
@ -321,6 +327,11 @@ namespace System.Management.Automation
get { return s_psV6Version; }
}
internal static SemanticVersion PSV7Version
{
get { return s_psV7Version; }
}
#endregion
}

View file

@ -1182,8 +1182,6 @@ namespace System.Management.Automation
string compareName = Path.GetFileName(destinationPath);
string noExtensionCompareName = Path.GetFileNameWithoutExtension(destinationPath);
// See if it's the correct length. If it's shorter than CON, AUX, etc, it can't be a device name.
// Likewise, if it's longer than 'CLOCK$', it can't be a device name.
if (((compareName.Length < 3) || (compareName.Length > 6)) &&
((noExtensionCompareName.Length < 3) || (noExtensionCompareName.Length > 6)))
{

View file

@ -335,7 +335,7 @@ namespace System.Management.Automation.Provider
// If the parent is empty but the child is not, return the
// child
result = child.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator);
result = NormalizePath(child);
}
else if (!string.IsNullOrEmpty(parent) &&
string.IsNullOrEmpty(child))
@ -369,8 +369,8 @@ namespace System.Management.Automation.Provider
// Normalize the path so that only the default path separator is used as a
// separator even if the user types the alternate slash.
parent = parent.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator);
child = child.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator);
parent = NormalizePath(parent);
child = NormalizePath(child);
}
// Joins the paths

View file

@ -2,10 +2,11 @@
<PropertyGroup>
<Description>Generates CorePsTypeCatalog.cs given powershell.inc</Description>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>TypeCatalogGen</AssemblyName>
<OutputType>Exe</OutputType>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<RuntimeIdentifiers>win7-x86;win7-x64;osx-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup>

View file

@ -67,7 +67,7 @@ function Register-WinRmPlugin
SDKVersion="2" XmlRenderingType="text" Enabled="True" OutputBufferingMode="Block" ProcessIdleTimeoutSec="0" Architecture="{2}"
UseSharedProcess="false" RunAsUser="" RunAsPassword="" AutoRestart="false">
<InitializationParameters>
<Param Name="PSVersion" Value="6.0"/>
<Param Name="PSVersion" Value="7.0"/>
</InitializationParameters>
<Resources>
<Resource ResourceUri="http://schemas.microsoft.com/powershell/{0}" SupportsOptions="true" ExactMatch="true">

View file

@ -7,6 +7,7 @@
<AssemblyName>pwsh</AssemblyName>
<OutputType>Exe</OutputType>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<RuntimeIdentifiers>linux-x64;osx-x64;</RuntimeIdentifiers>
</PropertyGroup>

View file

@ -1,14 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Project ToolsVersion="15.0">
<Import Project="..\..\PowerShell.Common.props" />
<PropertyGroup>
<Description>PowerShell on Windows top-level project</Description>
<AssemblyName>pwsh</AssemblyName>
<OutputType>Exe</OutputType>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>
<RootNamespace>Microsoft.PowerShell</RootNamespace>
<ApplicationManifest>..\..\assets\pwsh.manifest</ApplicationManifest>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition="'$(RuntimeIdentifier)' == 'win-arm' or '$(RuntimeIdentifier)' == 'win-arm64'" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition="'$(RuntimeIdentifier)' == 'win-arm' or '$(RuntimeIdentifier)' == 'win-arm64'" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.WindowsDesktop" Condition="'$(RuntimeIdentifier)' != 'win-arm' and '$(RuntimeIdentifier)' != 'win-arm64'" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.WindowsDesktop" Condition="'$(RuntimeIdentifier)' != 'win-arm' and '$(RuntimeIdentifier)' != 'win-arm64'" />
<ItemGroup>
<Compile Include="..\powershell\Program.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
<Content Include="..\System.Management.Automation\powershell.config.json">

View file

@ -4,9 +4,8 @@
<Company>Microsoft Corporation</Company>
<Copyright>(c) Microsoft Corporation. All rights reserved.</Copyright>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.8</RuntimeFrameworkVersion>
<LangVersion>Latest</LangVersion>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

View file

@ -18,7 +18,7 @@
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="XunitXml.TestLogger" Version="2.0.0" />
<!-- The version of Microsoft.PowerShell.SDK should be the version we are releasing, so the tests use the correct SDK before publishing to NuGet.org -->
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.2.0-rc.1" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.2.0" />
<PackageReference Include="Xunit.SkippableFact" Version="1.3.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>

View file

@ -824,9 +824,14 @@ Describe "Console host api tests" -Tag CI {
Describe "Pwsh exe resources tests" -Tag CI {
It "Resource strings are embedded in the executable" -Skip:(!$IsWindows) {
$pwsh = Get-Item -Path "$PSHOME\pwsh.exe"
$pwsh.VersionInfo.FileVersion | Should -BeExactly $PSVersionTable.PSVersion.ToString().Split("-")[0]
$pwsh.VersionInfo.ProductVersion.Replace("-dirty","") | Should -BeExactly $PSVersionTable.GitCommitId
$pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell 7"
$pwsh.VersionInfo.FileVersion | Should -Match $PSVersionTable.PSVersion.ToString().Split("-")[0]
$productVersion = $pwsh.VersionInfo.ProductVersion.Replace("-dirty","").Replace(" Commits: ","-").Replace(" SHA: ","-g")
if ($PSVersionTable.GitCommitId.Contains("-g")) {
$productVersion | Should -BeExactly $PSVersionTable.GitCommitId
} else {
$productVersion | Should -Match $PSVersionTable.GitCommitId
}
$pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell"
}
It "Manifest contains compatibility section" -Skip:(!$IsWindows) {

View file

@ -45,7 +45,7 @@ Describe "PSVersionTable" -Tags "CI" {
$PSVersionTable.PSVersion | Should -BeOfType "System.Management.Automation.SemanticVersion"
$PSVersionTable.PSVersion | Should -BeExactly $expectedPSVersion
$PSVersionTable.PSVersion | Should -Match $expectedVersionPattern
$PSVersionTable.PSVersion.Major | Should -Be 6
$PSVersionTable.PSVersion.Major | Should -Be 7
}
It "GitCommitId property" {

View file

@ -72,6 +72,7 @@ Describe "Validate start of console host" -Tag CI {
'System.Threading.Tasks.dll'
'System.Threading.Tasks.Parallel.dll'
'System.Threading.Thread.dll'
'System.Threading.ThreadPool.dll'
'System.Threading.Timer.dll'
'System.Xml.ReaderWriter.dll'
'System.Xml.XDocument.dll'

View file

@ -488,7 +488,7 @@ Describe "TabCompletion" -Tags CI {
@{ inputStr = 'function Get-ScrumData {}; Get-Scrum'; expected = 'Get-ScrumData'; setup = $null }
@{ inputStr = 'function write-output {param($abcd) $abcd};Write-Output -a'; expected = '-abcd'; setup = $null }
@{ inputStr = 'function write-output {param($abcd) $abcd};Microsoft.PowerShell.Utility\Write-Output -'; expected = '-InputObject'; setup = $null }
@{ inputStr = '[math]::Co'; expected = 'Cos('; setup = $null }
@{ inputStr = '[math]::Co'; expected = 'CopySign('; setup = $null }
@{ inputStr = '[math]::PI.GetT'; expected = 'GetType('; setup = $null }
@{ inputStr = '[math]'; expected = '::E'; setup = $null }
@{ inputStr = '[math].'; expected = 'Assembly'; setup = $null }

View file

@ -667,7 +667,7 @@ foo``u{2195}abc
#Exponential
@{ Script = "0e0"; ExpectedValue = "0"; ExpectedType = [double] }
@{ Script = "0e1"; ExpectedValue = "0"; ExpectedType = [double] }
@{ Script = "-0e2"; ExpectedValue = "0"; ExpectedType = [double] }
@{ Script = "-0e2"; ExpectedValue = "-0"; ExpectedType = [double] }
@{ Script = "3e0"; ExpectedValue = "3"; ExpectedType = [double] }
@{ Script = "5e-2"; ExpectedValue = "0.05"; ExpectedType = [double] }
@{ Script = "5e2"; ExpectedValue = "500"; ExpectedType = [double] }

View file

@ -216,42 +216,42 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" {
New-ModuleManifest -Path "$testdrive\Modules\Foo\Foo_ro.psd1"
New-ModuleManifest -Path "$testdrive\Modules\Foo\Foo_rw.psd1"
New-ModuleManifest -Path "$testdrive\Modules\Bar\Bar_rw.psd1"
New-ModuleManifest -Path "$testdrive\Modules\Baz\Baz_const.psd1"
New-ModuleManifest -Path "$testdrive\Modules\Baz\Const_module.psd1"
New-Item -ItemType File -Path "$testdrive\Modules\Foo\Foo_ro.psm1" > $null
New-Item -ItemType File -Path "$testdrive\Modules\Foo\Foo_rw.psm1" > $null
New-Item -ItemType File -Path "$testdrive\Modules\Bar\Bar_rw.psm1" > $null
New-Item -ItemType File -Path "$testdrive\Modules\Baz\Baz_const.psm1" > $null
New-Item -ItemType File -Path "$testdrive\Modules\Baz\Const_module.psm1" > $null
$removeReadOnlyModulesTestCases = @(
# Simple patterns
@{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw"}
@{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro"}
@{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Baz_const", "Foo_ro"}
@{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro", "Foo_rw"}
@{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro"}
@{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Const_module", "Foo_ro"}
# Regex patterns
@{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro"}
@{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Baz_const", "Foo_ro"}
@{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro"}
@{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Const_module", "Foo_ro"}
)
$removeForceReadOnlyModulesTestCases = @(
# Simple patterns
@{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = "Foo_ro"; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_rw"}
@{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const"}
@{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Baz_const"}
@{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = "Foo_ro"; ShouldBePresent = "Bar_rw", "Const_module", "Foo_rw"}
@{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module"}
@{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Const_module"}
# Regex patterns
@{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const"}
@{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Baz_const"}
@{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module"}
@{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Const_module"}
)
$removeConstantModulesTestCases = @(
# Simple patterns
@{ NamesToRemove = "Baz_const"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw"}
@{ NamesToRemove = "Baz_const", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const"}
@{ NamesToRemove = "Const_module"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro", "Foo_rw"}
@{ NamesToRemove = "Const_module", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module"}
# Regex patterns
@{ NamesToRemove = "Foo_*", "Ba*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Baz_const"}
@{ NamesToRemove = "Foo_*", "Ba*", "Const*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Const_module"}
)
}
@ -264,8 +264,15 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" {
(Get-Module -Name "Foo_ro").AccessMode = "readOnly"
Import-Module -Name "$testdrive\Modules\Foo\Foo_rw.psd1" -Force
Import-Module -Name "$testdrive\Modules\Bar\Bar_rw.psd1" -Force
Import-Module -Name "$testdrive\Modules\Baz\Baz_const.psd1" -Force
(Get-Module -Name "Baz_const").AccessMode = "Constant"
# If this test is run again in the same session, this test module
# will already be loaded and can't be removed because it sets
# AccessMode to Constant, so only import this test module and
# set AccessMode if it isn't already loaded
if ($null -eq (Get-Module -Name "Const_module")) {
Import-Module -Name "$testdrive\Modules\Baz\Const_module.psd1" -Force
(Get-Module -Name "Const_module").AccessMode = "Constant"
}
}
It "Remove-Module (ReadOnly modules): <NamesToRemove>" -TestCases $removeReadOnlyModulesTestCases {
@ -304,7 +311,7 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" {
It "Remove-Module -Force (Constant modules): <NamesToRemove>" -TestCases $removeConstantModulesTestCases {
param([string[]]$NamesToRemove, [string[]]$ShouldBeRemoved, [string[]]$ShouldBePresent)
(Get-Module -Name "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw").Name | Should -BeExactly "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw"
(Get-Module -Name "Bar_rw", "Const_module", "Foo_ro", "Foo_rw").Name | Should -BeExactly "Bar_rw", "Const_module", "Foo_ro", "Foo_rw"
{ Remove-Module -Force -Name $NamesToRemove -ErrorAction Stop } | Should -Throw -ErrorId "Modules_ModuleIsConstant,Microsoft.PowerShell.Commands.RemoveModuleCommand"
{ Remove-Module -Force -Name $NamesToRemove -ErrorAction SilentlyContinue } | Should -Not -Throw

View file

@ -22,9 +22,33 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
$newTestFile = "NewTestFile.txt"
$testContent = "Some Content"
$testContent2 = "More Content"
$reservedNames = "CON", "PRN", "AUX", "CLOCK$", "NUL",
"COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
"LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"
$reservedNamesTests = @(
@{ deviceName = 'CON' }
@{ deviceName = 'PRN' }
@{ deviceName = 'AUX' }
@{ deviceName = 'CLOCK$' }
@{ deviceName = 'NUL' }
@{ deviceName = 'COM0' }
@{ deviceName = 'COM1' }
@{ deviceName = 'COM2' }
@{ deviceName = 'COM3' }
@{ deviceName = 'COM4' }
@{ deviceName = 'COM5' }
@{ deviceName = 'COM6' }
@{ deviceName = 'COM7' }
@{ deviceName = 'COM8' }
@{ deviceName = 'COM9' }
@{ deviceName = 'LPT0' }
@{ deviceName = 'LPT1' }
@{ deviceName = 'LPT2' }
@{ deviceName = 'LPT3' }
@{ deviceName = 'LPT4' }
@{ deviceName = 'LPT5' }
@{ deviceName = 'LPT6' }
@{ deviceName = 'LPT7' }
@{ deviceName = 'LPT8' }
@{ deviceName = 'LPT9' }
)
}
BeforeEach {
@ -154,51 +178,39 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
$contentAfter.Count | Should -Be 0
}
It "Copy-Item on Windows rejects Windows reserved device names" -Skip:(-not $IsWindows) {
foreach ($deviceName in $reservedNames)
{
{ Copy-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand"
}
It "Copy-Item on Windows rejects Windows reserved device name: <deviceName>" -Skip:(-not $IsWindows) -TestCases $reservedNamesTests {
param($deviceName)
{ Copy-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand"
}
It "Move-Item on Windows rejects Windows reserved device names" -Skip:(-not $IsWindows) {
foreach ($deviceName in $reservedNames)
{
{ Move-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "MoveError,Microsoft.PowerShell.Commands.MoveItemCommand"
}
It "Move-Item on Windows rejects Windows reserved device name: <deviceName>" -Skip:(-not $IsWindows) -TestCases $reservedNamesTests {
param($deviceName)
{ Move-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "MoveError,Microsoft.PowerShell.Commands.MoveItemCommand"
}
It "Rename-Item on Windows rejects Windows reserved device names" -Skip:(-not $IsWindows) {
foreach ($deviceName in $reservedNames)
{
{ Rename-Item -Path $testFile -NewName $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "RenameError,Microsoft.PowerShell.Commands.RenameItemCommand"
}
It "Rename-Item on Windows rejects Windows reserved device name: <deviceName>" -Skip:(-not $IsWindows) -TestCases $reservedNamesTests {
param($deviceName)
{ Rename-Item -Path $testFile -NewName $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "RenameError,Microsoft.PowerShell.Commands.RenameItemCommand"
}
It "Copy-Item on Unix succeeds with Windows reserved device names" -Skip:($IsWindows) {
foreach ($deviceName in $reservedNames)
{
Copy-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue
Test-Path $deviceName | Should -BeTrue
}
It "Copy-Item on Unix succeeds with Windows reserved device name: <deviceName>" -Skip:($IsWindows) -TestCases $reservedNamesTests {
param($deviceName)
Copy-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue
Test-Path $deviceName | Should -BeTrue
}
It "Move-Item on Unix succeeds with Windows reserved device names" -Skip:($IsWindows) {
foreach ($deviceName in $reservedNames)
{
Move-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue
Test-Path $deviceName | Should -BeTrue
New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue
}
It "Move-Item on Unix succeeds with Windows reserved device name: <deviceName>" -Skip:($IsWindows) -TestCases $reservedNamesTests {
param($deviceName)
Move-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue
Test-Path $deviceName | Should -BeTrue
New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue
}
It "Rename-Item on Unix succeeds with Windows reserved device names" -Skip:($IsWindows) {
foreach ($deviceName in $reservedNames)
{
Rename-Item -Path $testFile -NewName $deviceName -Force -ErrorAction SilentlyContinue
Test-Path $deviceName | Should -BeTrue
New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue
}
It "Rename-Item on Unix succeeds with Windows reserved device name: <deviceName>" -Skip:($IsWindows) -TestCases $reservedNamesTests {
param($deviceName)
Rename-Item -Path $testFile -NewName $deviceName -Force -ErrorAction SilentlyContinue
Test-Path $deviceName | Should -BeTrue
New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue
}
It "Set-Location on Unix succeeds with folder with colon: <path>" -Skip:($IsWindows) -TestCases @(
@ -426,7 +438,7 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows"
{
$item = Get-Item $TestPath
$dirName = $item.BaseName
$item = Get-Item $item.PSParentPath
$item = Get-Item $item.PSParentPath -Force
if ($item.LinkType -eq "SymbolicLink")
{
$TestPath = Join-Path $item.Target $dirName
@ -451,50 +463,50 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows"
Context "New-Item and hard/symbolic links" {
It "New-Item can create a hard link to a file" {
New-Item -ItemType HardLink -Path $hardLinkToFile -Value $realFile
New-Item -ItemType HardLink -Path $hardLinkToFile -Value $realFile > $null
Test-Path $hardLinkToFile | Should -BeTrue
$link = Get-Item -Path $hardLinkToFile
$link.LinkType | Should -BeExactly "HardLink"
Get-Content -Path $hardLinkToFile | Should -Be $fileContent
}
It "New-Item can create symbolic link to file" {
New-Item -ItemType SymbolicLink -Path $symLinkToFile -Value $realFile
New-Item -ItemType SymbolicLink -Path $symLinkToFile -Value $realFile > $null
Test-Path $symLinkToFile | Should -BeTrue
$real = Get-Item -Path $realFile
$link = Get-Item -Path $symLinkToFile
$link.LinkType | Should -BeExactly "SymbolicLink"
$link.Target | Should -Be $real.FullName
$link.Target | Should -BeExactly $real.ToString()
Get-Content -Path $symLinkToFile | Should -Be $fileContent
}
It "New-Item can create a symbolic link to nothing" {
New-Item -ItemType SymbolicLink -Path $symLinkToNothing -Value $nonFile
New-Item -ItemType SymbolicLink -Path $symLinkToNothing -Value $nonFile > $null
Test-Path $symLinkToNothing | Should -BeTrue
$link = Get-Item -Path $symLinkToNothing
$link.LinkType | Should -BeExactly "SymbolicLink"
$link.Target | Should -Be $nonFile
$link.Target | Should -Be $nonFile.ToString()
}
It "New-Item emits an error when path to symbolic link already exists." {
{ New-Item -ItemType SymbolicLink -Path $realDir -Value $symLinkToDir -ErrorAction Stop } | Should -Throw -ErrorId "SymLinkExists,Microsoft.PowerShell.Commands.NewItemCommand"
}
It "New-Item can create a symbolic link to a directory" -Skip:($IsWindows) {
New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir
New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir > $null
Test-Path $symLinkToDir | Should -BeTrue
$real = Get-Item -Path $realDir
$link = Get-Item -Path $symLinkToDir
$link.LinkType | Should -BeExactly "SymbolicLink"
$link.Target | Should -Be $real.FullName
$link.Target | Should -BeExactly $real.ToString()
}
It "New-Item can create a directory symbolic link to a directory" -Skip:(-Not $IsWindows) {
New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir
New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir > $null
Test-Path $symLinkToDir | Should -BeTrue
$real = Get-Item -Path $realDir
$link = Get-Item -Path $symLinkToDir
$link | Should -BeOfType System.IO.DirectoryInfo
$link.LinkType | Should -BeExactly "SymbolicLink"
$link.Target | Should -BeExactly $real.FullName
$link.Target | Should -BeExactly $real.ToString()
}
It "New-Item can create a directory junction to a directory" -Skip:(-Not $IsWindows) {
New-Item -ItemType Junction -Path $junctionToDir -Value $realDir
New-Item -ItemType Junction -Path $junctionToDir -Value $realDir > $null
Test-Path $junctionToDir | Should -BeTrue
}
}

View file

@ -16,10 +16,14 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') {
It "Should support -FileVersionInfo" {
$pwshVersion = Get-Process -Id $pid -FileVersionInfo
if ($IsWindows) {
$PSVersionTable.PSVersion | Should -MatchExactly $pwshVersion.FileVersion
$pwshVersion.FileVersion | Should -Match $PSVersionTable.PSVersion.ToString().Split("-")[0]
$pwshVersion.FileMajorPart | Should -BeExactly $PSVersionTable.PSVersion.Major
$pwshVersion.FileMinorPart | Should -BeExactly $PSVersionTable.PSVersion.Minor
$pwshVersion.FileBuildPart | Should -BeExactly $PSVersionTable.PSVersion.Patch
$gitCommitId = $PSVersionTable.GitCommitId
if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) }
$pwshVersion.ProductVersion.Replace("-dirty","") | Should -BeExactly $gitCommitId
$productVersion = $pwshVersion.ProductVersion.Replace(" Commits: ","-").Replace(" SHA: ","-g")
$productVersion | Should -Match $gitCommitId
} else {
$pwshVersion.FileVersion | Should -BeNullOrEmpty
}

View file

@ -78,7 +78,7 @@ Describe "Test-Connection" -tags "CI" {
{ $result = Test-Connection "fakeHost" -Count 1 -Quiet -ErrorAction Stop } | Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand"
# Error code = 11001 - Host not found.
if (!$isWindows) {
$Error[0].Exception.InnerException.ErrorCode | Should -Be 6
$Error[0].Exception.InnerException.ErrorCode | Should -Be -131073
} else {
$Error[0].Exception.InnerException.ErrorCode | Should -Be 11001
}
@ -113,8 +113,9 @@ Describe "Test-Connection" -tags "CI" {
$result2.Replies[0].Status | Should -BeIn "TtlExpired","TimedOut","Success"
} else {
$result1.Replies[0].Options.DontFragment | Should -BeFalse
# We expect 'TtlExpired' but if a router don't reply we get `TimeOut`
$result2.Replies[0].Status | Should -BeIn "TtlExpired","TimedOut"
# We expect 'TtlExpired' but if a router don't reply we get `TimedOut`
# AzPipelines returns $null
$result2.Replies[0].Status | Should -BeIn "TtlExpired","TimedOut",$null
}
}

View file

@ -1210,13 +1210,13 @@ Describe "Validate Json serialization" -Tags "CI" {
# Single
@{
TestInput = '[single]::MaxValue'
FromJson = "3.40282347E+38"
ToJson = "3.40282347E+38"
FromJson = "3.4028235E+38"
ToJson = "3.4028235E+38"
}
@{
TestInput = '[single]::MinValue'
FromJson = "-3.40282347E+38"
ToJson = "-3.40282347E+38"
FromJson = "-3.4028235E+38"
ToJson = "-3.4028235E+38"
}
# Double

View file

@ -182,7 +182,7 @@ Describe "Measure-Object" -Tags "CI" {
$result.Sum | Should -Be 55
$result.Minimum | Should -Be 1
$result.Maximum | Should -Be 10
($result.StandardDeviation).ToString() | Should -Be '3.02765035409749'
($result.StandardDeviation).ToString() | Should -Be '3.0276503540974917'
}
}

View file

@ -6,6 +6,8 @@ Describe "Assembly::LoadWithPartialName Validation Test" -Tags "CI" {
$defaultErrorId = 'FileLoadException'
$testcases = @(
# verify winforms is blocked
# winforms assembly is supported for .Net Core 3.0, if a new assembly needs to be blocked
# enable this test and add to list below
@{
Name = 'system.windows.forms'
ErrorId = $defaultErrorId
@ -19,7 +21,11 @@ Describe "Assembly::LoadWithPartialName Validation Test" -Tags "CI" {
# All existing cases should fail on all platforms either because it doesn't exist or
# because the assembly is blacklisted
It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: <Name>" -TestCases $testcases {
# This test is currently being skipped because System.Windows.Forms is part of .NET Core 3.0 so it gets
# load and thus no exception is thrown failing this test.
It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: <Name>" -Pending -TestCases $testcases {
param(
[Parameter(Mandatory)]
[string]

View file

@ -0,0 +1,11 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Resolve types in additional referenced assemblies" -Tag CI {
It "Will resolve DirectoryServices type <name>" -TestCases @(
@{ typename = "[System.DirectoryServices.AccountManagement.AdvancedFilters]"; name = "AdvancedFilters" }
){
param ($typename, $name)
pwsh -noprofile -command "$typename.Name" | Should -BeExactly $name
}
}

View file

@ -624,7 +624,7 @@ function Invoke-OpenCover
[parameter()]$OutputLog = "$home/Documents/OpenCover.xml",
[parameter()]$TestPath = "${script:psRepoPath}/test/powershell",
[parameter()]$OpenCoverPath = "$home/OpenCover",
[parameter()]$PowerShellExeDirectory = "${script:psRepoPath}/src/powershell-win-core/bin/CodeCoverage/netcoreapp2.1/win7-x64/publish",
[parameter()]$PowerShellExeDirectory = "${script:psRepoPath}/src/powershell-win-core/bin/CodeCoverage/netcoreapp3.0/win7-x64/publish",
[parameter()]$PesterLogElevated = "$HOME/Documents/TestResultsElevated.xml",
[parameter()]$PesterLogUnelevated = "$HOME/Documents/TestResultsUnelevated.xml",
[parameter()]$PesterLogFormat = "NUnitXml",

View file

@ -7,6 +7,7 @@
<AssemblyName>testexe</AssemblyName>
<OutputType>Exe</OutputType>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<RuntimeIdentifiers>win7-x86;win7-x64;osx-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup>

View file

@ -7,6 +7,7 @@
<AssemblyName>TestService</AssemblyName>
<OutputType>Exe</OutputType>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>
</PropertyGroup>

View file

@ -17,9 +17,9 @@ namespace mvc.Controllers
{
public class MultipartController : Controller
{
private IHostingEnvironment _environment;
private IWebHostEnvironment _environment;
public MultipartController(IHostingEnvironment environment)
public MultipartController(IWebHostEnvironment environment)
{
_environment = environment;
}

View file

@ -23,7 +23,7 @@ namespace mvc
if (args.Count() != 6)
{
System.Console.WriteLine("Required: <CertificatePath> <CertificatePassword> <HTTPPortNumber> <HTTPSPortNumberTls2> <HTTPSPortNumberTls11> <HTTPSPortNumberTls>");
Environment.Exit(1);
Environment.Exit(1);
}
BuildWebHost(args).Run();
@ -33,6 +33,7 @@ namespace mvc
WebHost.CreateDefaultBuilder()
.UseStartup<Startup>().UseKestrel(options =>
{
options.AllowSynchronousIO = true;
options.Listen(IPAddress.Loopback, int.Parse(args[2]));
options.Listen(IPAddress.Loopback, int.Parse(args[3]), listenOptions =>
{

View file

@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Constraints;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace mvc
{
@ -25,11 +26,14 @@ namespace mvc
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc(options => {
options.EnableEndpointRouting = false;
})
.AddNewtonsoftJson();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{

View file

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview5-19227-01" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
</ItemGroup>

View file

@ -1,7 +1,7 @@
{
"StableReleaseTag": "v6.2.0",
"PreviewReleaseTag": "v6.2.0-rc.1",
"PreviewReleaseTag": "v7.0.0-preview.1",
"ServicingReleaseTag": "v6.0.5",
"ReleaseTag": "v6.2.0",
"NextReleaseTag": "v6.2.0-rc.1"
"ReleaseTag": "v7.0.0",
"NextReleaseTag": "v7.0.0-preview.1"
}

View file

@ -125,14 +125,14 @@ function Start-PSPackage {
-not $Script:Options -or ## Start-PSBuild hasn't been executed yet
-not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly
$Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release'
$Script:Options.Framework -ne "netcoreapp2.1" ## Last build wasn't for CoreCLR
$Script:Options.Framework -ne "netcoreapp3.0" ## Last build wasn't for CoreCLR
} else {
-not $Script:Options -or ## Start-PSBuild hasn't been executed yet
-not $crossGenCorrect -or ## Last build didn't specify '-CrossGen' correctly
-not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly
$Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID
$Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release'
$Script:Options.Framework -ne "netcoreapp2.1" ## Last build wasn't for CoreCLR
$Script:Options.Framework -ne "netcoreapp3.0" ## Last build wasn't for CoreCLR
}
# Make sure the most recent build satisfies the package requirement
@ -1437,7 +1437,7 @@ function CreateNugetPlatformFolder
[string] $PlatformBinPath
)
$destPath = New-Item -ItemType Directory -Path (Join-Path $PackageRuntimesFolder "$Platform/lib/netcoreapp2.1")
$destPath = New-Item -ItemType Directory -Path (Join-Path $PackageRuntimesFolder "$Platform/lib/netcoreapp3.0")
$fullPath = Join-Path $PlatformBinPath $file
if (-not(Test-Path $fullPath)) {
@ -1535,7 +1535,7 @@ function New-ILNugetPackage
$packageRuntimesFolder = New-Item (Join-Path $filePackageFolder.FullName 'runtimes') -ItemType Directory
#region ref
$refFolder = New-Item (Join-Path $filePackageFolder.FullName 'ref/netcoreapp2.1') -ItemType Directory -Force
$refFolder = New-Item (Join-Path $filePackageFolder.FullName 'ref/netcoreapp3.0') -ItemType Directory -Force
CopyReferenceAssemblies -assemblyName $fileBaseName -refBinPath $refBinPath -refNugetPath $refFolder -assemblyFileList $fileList
#endregion ref
@ -1655,7 +1655,7 @@ function New-ILNugetPackage
}
<#
Copy the generated reference assemblies to the 'ref/netcoreapp2.1' folder properly.
Copy the generated reference assemblies to the 'ref/netcoreapp3.0' folder properly.
This is a helper function used by 'New-ILNugetPackage'
#>
function CopyReferenceAssemblies
@ -1892,7 +1892,7 @@ function New-ReferenceAssembly
Write-Log "Running: dotnet $arguments"
Start-NativeExecution -sb {dotnet $arguments}
$refBinPath = Join-Path $projectFolder "bin/Release/netcoreapp2.1/$assemblyName.dll"
$refBinPath = Join-Path $projectFolder "bin/Release/netcoreapp3.0/$assemblyName.dll"
if ($null -eq $refBinPath) {
throw "Reference assembly was not built."
}
@ -2546,7 +2546,7 @@ function New-MSIPatch
# This example shows how to produce a Debug-x64 installer for development purposes.
cd $RootPathOfPowerShellRepo
Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1
New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.1\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp3.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
#>
function New-MSIPackage
{
@ -2746,7 +2746,7 @@ function New-MSIPackage
# This example shows how to produce a Debug-x64 installer for development purposes.
cd $RootPathOfPowerShellRepo
Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1
New-MSIXPackage -Verbose -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.1\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
New-MSIXPackage -Verbose -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp3.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
#>
function New-MSIXPackage
{
@ -2923,7 +2923,6 @@ function Test-FileWxs
{
$passed = $false
$folder = Split-Path -Path $file
$name = Split-Path -Path $file -Leaf
$heatNode = $heatNodesByFile[$file]
$compGroupNode = Get-ComponentGroupNode -XmlDoc $newFilesAssetXml -XmlNsManager $xmlns
$filesNode = Get-DirectoryNode -Node $heatNode -XmlDoc $newFilesAssetXml -XmlNsManager $xmlns
@ -3263,7 +3262,7 @@ function New-GlobalToolNupkg
}
$packageInfo | ForEach-Object {
$ridFolder = New-Item -Path (Join-Path $_.RootFolder "tools/netcoreapp2.1/any") -ItemType Directory
$ridFolder = New-Item -Path (Join-Path $_.RootFolder "tools/netcoreapp3.0/any") -ItemType Directory
$packageType = $_.Type

View file

@ -132,7 +132,7 @@ open {0}
<files include="**/*" buildAction="None" copyToOutput="true" flatten="false" />
</contentFiles>
<dependencies>
<group targetFramework=".NETCoreApp2.1"></group>
<group targetFramework=".netcoreapp3.0"></group>
</dependencies>
</metadata>
</package>

View file

@ -11,6 +11,6 @@
<NuspecProperties>runtime=$(RID);version=$(SemVer);PackageName=$(PackageName)</NuspecProperties>
<NuspecBasePath>$(StagingPath)</NuspecBasePath>
<IsTool>True</IsTool>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>