Created a csproj to pin test modules and updated build.psm1 accordingly (#8350)
This commit is contained in:
parent
743a964392
commit
3794a5e39f
27
build.psm1
27
build.psm1
|
@ -5,10 +5,6 @@
|
|||
# On Windows paths is separated by semicolon
|
||||
$script:TestModulePathSeparator = [System.IO.Path]::PathSeparator
|
||||
|
||||
# Path to a directory to store modules we temporarily need to test PowerShell
|
||||
$script:TestModuleDirPath = Join-Path ([System.IO.Path]::GetTempPath()) 'PwshTestModules'
|
||||
$null = New-Item -Force -ItemType Directory -Path $script:TestModuleDirPath
|
||||
|
||||
$dotnetCLIChannel = "release"
|
||||
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
|
||||
|
||||
|
@ -556,7 +552,7 @@ function Restore-PSModuleToBuild
|
|||
|
||||
Write-Log "Restore PowerShell modules to $publishPath"
|
||||
$modulesDir = Join-Path -Path $publishPath -ChildPath "Modules"
|
||||
Copy-PSGalleryModules -Destination $modulesDir
|
||||
Copy-PSGalleryModules -Destination $modulesDir -CsProjPath "$PSScriptRoot\src\Modules\PSGalleryModules.csproj"
|
||||
}
|
||||
|
||||
function Restore-PSPester
|
||||
|
@ -848,8 +844,8 @@ function Publish-PSTestTools {
|
|||
}
|
||||
}
|
||||
|
||||
# Get the SelfSignedCertificate module so the web listener can use it
|
||||
Save-Module -Name SelfSignedCertificate -Path $script:TestModuleDirPath -Repository "PSGallery" -MinimumVersion '0.0.2' -Force -Confirm:$false
|
||||
# `dotnet restore` on test project is not called if product projects have been restored unless -Force is specified.
|
||||
Copy-PSGalleryModules -Destination "${PSScriptRoot}/test/tools/Modules" -CsProjPath "$PSScriptRoot/test/tools/Modules/PSGalleryTestModules.csproj" -Force
|
||||
}
|
||||
|
||||
function Get-ExperimentalFeatureTests {
|
||||
|
@ -893,7 +889,7 @@ function Start-PSPester {
|
|||
|
||||
if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge "4.2" } ))
|
||||
{
|
||||
Restore-PSPester
|
||||
Restore-PSPester
|
||||
}
|
||||
|
||||
if ($IncludeFailingTest.IsPresent)
|
||||
|
@ -954,7 +950,7 @@ function Start-PSPester {
|
|||
}
|
||||
|
||||
# Autoload (in subprocess) temporary modules used in our tests
|
||||
$newPathFragment = $TestModulePath + $TestModulePathSeparator + $script:TestModuleDirPath + $TestModulePathSeparator
|
||||
$newPathFragment = $TestModulePath + $TestModulePathSeparator
|
||||
$command += '$env:PSModulePath = '+"'$newPathFragment'" + '+$env:PSModulePath;'
|
||||
|
||||
# Windows needs the execution policy adjusted
|
||||
|
@ -2271,7 +2267,13 @@ function Copy-PSGalleryModules
|
|||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Destination
|
||||
[string]$CsProjPath,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Destination,
|
||||
|
||||
[Parameter()]
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
if (!$Destination.EndsWith("Modules")) {
|
||||
|
@ -2279,7 +2281,8 @@ function Copy-PSGalleryModules
|
|||
}
|
||||
|
||||
Find-DotNet
|
||||
Restore-PSPackage
|
||||
|
||||
Restore-PSPackage -ProjectDirs (Split-Path $CsProjPath) -Force:$Force.IsPresent
|
||||
|
||||
$cache = dotnet nuget locals global-packages -l
|
||||
if ($cache -match "info : global-packages: (.*)") {
|
||||
|
@ -2289,7 +2292,7 @@ function Copy-PSGalleryModules
|
|||
throw "Can't find nuget global cache"
|
||||
}
|
||||
|
||||
$psGalleryProj = [xml](Get-Content -Raw $PSScriptRoot\src\Modules\PSGalleryModules.csproj)
|
||||
$psGalleryProj = [xml](Get-Content -Raw $CsProjPath)
|
||||
|
||||
foreach ($m in $psGalleryProj.Project.ItemGroup.PackageReference) {
|
||||
$name = $m.Include
|
||||
|
|
9
test/tools/Modules/PSGalleryTestModules.csproj
Normal file
9
test/tools/Modules/PSGalleryTestModules.csproj
Normal file
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
|
||||
<Import Project="..\..\Test.Common.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SelfSignedCertificate" Version="0.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in a new issue