From 73598edccc1a6a601cb8922e6e624885c9a90e0c Mon Sep 17 00:00:00 2001 From: Patrick Meinecke Date: Thu, 27 Jun 2024 18:23:58 -0400 Subject: [PATCH] Fix building credman for tests --- ExtensionModules/CredManStore/build.ps1 | 115 ------------------ ExtensionModules/CredManStore/doBuild.ps1 | 73 ----------- .../CredManStore/pspackageproject.json | 9 -- SecretManagement.build.ps1 | 5 +- 4 files changed, 3 insertions(+), 199 deletions(-) delete mode 100644 ExtensionModules/CredManStore/build.ps1 delete mode 100644 ExtensionModules/CredManStore/doBuild.ps1 delete mode 100644 ExtensionModules/CredManStore/pspackageproject.json diff --git a/ExtensionModules/CredManStore/build.ps1 b/ExtensionModules/CredManStore/build.ps1 deleted file mode 100644 index a6c65df..0000000 --- a/ExtensionModules/CredManStore/build.ps1 +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -# Do NOT edit this file. Edit dobuild.ps1 -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")] -param ( - [Parameter(ParameterSetName="build")] - [switch] - $Clean, - - [Parameter(ParameterSetName="build")] - [switch] - $Build, - - [Parameter(ParameterSetName="publish")] - [switch] - $Publish, - - [Parameter(ParameterSetName="publish")] - [switch] - $Signed, - - [Parameter(ParameterSetName="build")] - [switch] - $Test, - - [Parameter(ParameterSetName="build")] - [string[]] - [ValidateSet("Functional","StaticAnalysis")] - $TestType = @("Functional"), - - [Parameter(ParameterSetName="help")] - [switch] - $UpdateHelp, - - [ValidateSet("Debug", "Release")] - [string] $BuildConfiguration = "Debug", - - [ValidateSet("netstandard2.0")] - [string] $BuildFramework = "netstandard2.0" -) - -if ( ! ( Get-Module -ErrorAction SilentlyContinue PSPackageProject) ) { - Install-Module PSPackageProject -} - -$config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot - -$script:ModuleName = $config.ModuleName -$script:SrcPath = $config.SourcePath -$script:OutDirectory = $config.BuildOutputPath -$script:SignedDirectory = $config.SignedOutputPath -$script:TestPath = $config.TestPath - -$script:ModuleRoot = $PSScriptRoot -$script:Culture = $config.Culture -$script:HelpPath = $config.HelpPath - -$script:BuildConfiguration = $BuildConfiguration -$script:BuildFramework = $BuildFramework - -if ($env:TF_BUILD) { - $vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" - - $vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" -} - -. $PSScriptRoot/doBuild.ps1 - -if ($Clean -and (Test-Path $OutDirectory)) -{ - Remove-Item -Path $OutDirectory -Force -Recurse -ErrorAction Stop -Verbose - - if (Test-Path "${SrcPath}/code/bin") - { - Remove-Item -Path "${SrcPath}/code/bin" -Recurse -Force -ErrorAction Stop -Verbose - } - - if (Test-Path "${SrcPath}/code/obj") - { - Remove-Item -Path "${SrcPath}/code/obj" -Recurse -Force -ErrorAction Stop -Verbose - } -} - -if (-not (Test-Path $OutDirectory)) -{ - $script:OutModule = New-Item -ItemType Directory -Path (Join-Path $OutDirectory $ModuleName) -} -else -{ - $script:OutModule = Join-Path $OutDirectory $ModuleName -} - -if ($Build.IsPresent) -{ - $sb = (Get-Item Function:DoBuild).ScriptBlock - Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish -} - -if ($Publish.IsPresent) -{ - Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent -} - -if ( $Test.IsPresent ) { - Invoke-PSPackageProjectTest -Type $TestType -} - -if ($UpdateHelp.IsPresent) { - Add-PSPackageProjectCmdletHelp -ProjectRoot $ModuleRoot -ModuleName $ModuleName -Culture $Culture -} diff --git a/ExtensionModules/CredManStore/doBuild.ps1 b/ExtensionModules/CredManStore/doBuild.ps1 deleted file mode 100644 index f3ca6a1..0000000 --- a/ExtensionModules/CredManStore/doBuild.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -<# -.DESCRIPTION -Implement build and packaging of the package and place the output $OutDirectory/$ModuleName -#> -function DoBuild -{ - Write-Verbose -Verbose -Message "Starting DoBuild with configuration: $BuildConfiguration, framework: $BuildFramework" - - # Module build out path - $BuildOutPath = "${OutDirectory}/${ModuleName}" - Write-Verbose -Verbose -Message "Module output file path: '$BuildOutPath'" - - # Module build source path - $BuildSrcPath = "bin/${BuildConfiguration}/${BuildFramework}/publish" - Write-Verbose -Verbose -Message "Module build source path: '$BuildSrcPath'" - - # Copy psd1 file - Write-Verbose -Verbose "Copy-Item ${SrcPath}/${ModuleName}.psd1 to ${OutDirectory}/${ModuleName}" - Copy-Item "${SrcPath}/${ModuleName}.psd1" "${OutDirectory}/${ModuleName}" - - # Copy format files here - Write-Verbose -Verbose "Copy-Item ${SrcPath}/${ModuleName}.format.ps1xml to ${OutDirectory}/${ModuleName}" - copy-item "${SrcPath}/${ModuleName}.format.ps1xml" "${OutDirectory}/${ModuleName}" - - # Copy help - Write-Verbose -Verbose -Message "Copying help files to '$BuildOutPath'" - copy-item -Recurse "${HelpPath}/${Culture}" "$BuildOutPath" - - if ( Test-Path "${SrcPath}/code" ) { - Write-Verbose -Verbose -Message "Building assembly and copying to '$BuildOutPath'" - # build code and place it in the staging location - Push-Location "${SrcPath}/code" - try { - # Build source - Write-Verbose -Verbose -Message "Building with configuration: $BuildConfiguration, framework: $BuildFramework" - Write-Verbose -Verbose -Message "Building location: PSScriptRoot: $PSScriptRoot, PWD: $pwd" - dotnet publish --configuration $BuildConfiguration --framework $BuildFramework --output $BuildSrcPath - - # Debug: Check - - # Place build results - if (! (Test-Path -Path "$BuildSrcPath/${ModuleName}.dll")) - { - throw "Expected binary was not created: $BuildSrcPath/${ModuleName}.dll" - } - - Write-Verbose -Verbose -Message "Copying $BuildSrcPath/${ModuleName}.dll to $BuildOutPath" - Copy-Item "$BuildSrcPath/${ModuleName}.dll" -Dest "$BuildOutPath" - - if (Test-Path -Path "$BuildSrcPath/${ModuleName}.pdb") - { - Write-Verbose -Verbose -Message "Copying $BuildSrcPath/${ModuleName}.pdb to $BuildOutPath" - Copy-Item -Path "$BuildSrcPath/${ModuleName}.pdb" -Dest "$BuildOutPath" - } - } - catch { - # Write-Error "dotnet build failed with error: $_" - Write-Verbose -Verbose -Message "dotnet build failed with error: $_" - } - finally { - Pop-Location - } - } - else { - Write-Verbose -Verbose -Message "No code to build in '${SrcPath}/code'" - } - - ## Add build and packaging here - Write-Verbose -Verbose -Message "Ending DoBuild" -} diff --git a/ExtensionModules/CredManStore/pspackageproject.json b/ExtensionModules/CredManStore/pspackageproject.json deleted file mode 100644 index 2f6779b..0000000 --- a/ExtensionModules/CredManStore/pspackageproject.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ModuleName": "Microsoft.PowerShell.CredManStore", - "Culture": "en-US", - "BuildOutputPath": "out", - "SignedOutputPath": "signed", - "HelpPath": "help", - "TestPath": "test", - "SourcePath": "src" -} diff --git a/SecretManagement.build.ps1 b/SecretManagement.build.ps1 index 4a5363a..49854a1 100644 --- a/SecretManagement.build.ps1 +++ b/SecretManagement.build.ps1 @@ -7,7 +7,7 @@ param( $ProjectName = "SecretManagement" $FullModuleName = 'Microsoft.PowerShell.SecretManagement' $CSharpSource = Join-Path $PSScriptRoot src/code -$CSharpPublish = Join-Path $PSScriptRoot artifacts/publish +$CSharpPublish = Join-Path $PSScriptRoot artifacts/publish/$FullModuleName/$Configuration $ModuleOut = Join-Path $PSScriptRoot module $PackageOut = Join-Path $PSScriptRoot out $HelpSource = Join-Path $PSScriptRoot help @@ -60,7 +60,8 @@ task BuildDocs { task BuildModule { New-Item -ItemType Directory -Force $ModuleOut | Out-Null - Invoke-BuildExec { dotnet publish $CSharpSource --configuration $Configuration --output $CSharpPublish } + Invoke-BuildExec { dotnet publish $CSharpSource --configuration $Configuration } + Invoke-BuildExec { dotnet publish $PSScriptRoot/ExtensionModules/CredManStore/src/code --configuration $Configuration } $CSharpArtifacts | ForEach-Object { $item = Join-Path $CSharpPublish $_