Skip to content

Commit 27d6bdd

Browse files
authored
Merge pull request #4838 from KoenZomers/FixLocalCoreBuild
Fixing local Core SDK Build not being debuggable
2 parents a43ef12 + 7a40219 commit 27d6bdd

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
130130
- Fixed `Get-PnPFolder` throwing an exception when a lot of files and folders are present [#4819](https://github.com/pnp/powershell/pull/4819)
131131
- Fixed `Set-PnPTerm -Name "New Name" -Lcid 1043` changing the default name of the taxonomy item, ignoring the provided language id and changing the name for the default language instead. [#4824](https://github.com/pnp/powershell/pull/4824)
132132
- Fixed `Get-PnPPropertyBag` not returning updated values after running it for the first time [#4823](https://github.com/pnp/powershell/pull/4823)
133+
- Fixed local build of PnP PowerShell using a local Core SDK build not being debuggable and optimized PnP PowerShell debug profiles for Visual Studio Code [#4838](https://github.com/pnp/powershell/pull/4838)
133134

134135
### Removed
135136

build/Build-Debug.ps1

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ $version = "$($versionObject.Major).$($versionObject.Minor).$buildVersion"
5353

5454
Write-Host "Building PnP.PowerShell version $version-debug" -ForegroundColor Yellow
5555

56-
$buildCmd = "dotnet build `"$PSScriptRoot/../src/Commands/PnP.PowerShell.csproj`"" + "--nologo --configuration Debug -p:VersionPrefix=$version -p:VersionSuffix=debug";
56+
$buildCmd = "dotnet build `"$PSScriptRoot/../src/Commands/PnP.PowerShell.csproj`" --nologo --configuration Debug -p:VersionPrefix=$version -p:VersionSuffix=debug";
5757
if ($NoIncremental) {
5858
$buildCmd += " --no-incremental";
5959
}
@@ -62,25 +62,28 @@ if ($Force) {
6262
}
6363
if ($LocalPnPFramework) {
6464
# Check if available
65-
$pnpFrameworkAssembly = Join-Path $PSScriptRoot -ChildPath "..\..\pnpframework\src\lib\PnP.Framework\bin\Debug\netstandard2.0\PnP.Framework.dll"
65+
$pnpFrameworkAssembly = Join-Path $PSScriptRoot -ChildPath "..\..\pnpframework\src\lib\PnP.Framework\bin\Debug\$configuration\PnP.Framework.dll"
6666
$pnpFrameworkAssembly = [System.IO.Path]::GetFullPath($pnpFrameworkAssembly)
6767
if (Test-Path $pnpFrameworkAssembly -PathType Leaf) {
68+
$pnpFrameworkAssemblyItem = Get-ChildItem -Path $pnpFrameworkAssembly
69+
Write-Host " Using local PnP Framework build located at $($pnpFrameworkAssemblyItem.FullName) compiled at $($pnpFrameworkAssemblyItem.LastWritetime)" -ForegroundColor Yellow
6870
$buildCmd += " -p:PnPFrameworkPath=`"..\..\..\pnpframework\src\lib\`""
6971
}
70-
else {
72+
else {
7173
$localFolder = Join-Path $PSScriptRoot -ChildPath "..\..\pnpframework"
7274
$localFolder = [System.IO.Path]::GetFullPath($localFolder)
7375
Write-Error -Message "Please make sure you have a local copy of the PnP.Framework repository installed at $localFolder"
7476
}
7577
}
7678
if ($LocalPnPCore) {
77-
# Check if available
78-
$pnpCoreAssembly = Join-Path $PSScriptRoot -ChildPath "..\..\pnpcore\src\sdk\PnP.Core\bin\Debug\netstandard2.0\PnP.Core.dll"
79+
$pnpCoreAssembly = Join-Path $PSScriptRoot -ChildPath "..\..\pnpcore\src\sdk\PnP.Core\bin\Debug\$configuration\PnP.Core.dll"
7980
$pnpCoreAssembly = [System.IO.Path]::GetFullPath($pnpCoreAssembly)
8081
if (Test-Path $pnpCoreAssembly -PathType Leaf) {
82+
$pnpCoreAssemblyItem = Get-ChildItem -Path $pnpCoreAssembly
83+
Write-Host " Using local PnP.Core SDK build located at $($pnpCoreAssemblyItem.FullName) compiled at $($pnpCoreAssemblyItem.LastWritetime)" -ForegroundColor Yellow
8184
$buildCmd += " -p:PnPCoreSdkPath=`"..\..\..\pnpcore\src\sdk\`""
8285
}
83-
else {
86+
else {
8487
$localFolder = Join-Path $PSScriptRoot -ChildPath "..\..\pnpcore"
8588
$localFolder = [System.IO.Path]::GetFullPath($localFolder)
8689
Write-Error -Message "Please make sure you have a local copy of the PnP.Core repository installed at $localFolder"
@@ -127,6 +130,12 @@ if ($LASTEXITCODE -eq 0) {
127130
Copy-Item -Path "$PSScriptRoot/../resources/*.ps1xml" -Destination "$destinationFolder"
128131
Get-ChildItem -Path "$PSScriptRoot/../src/ALC/bin/Debug/net8.0" | Where-Object { $_.Extension -in '.dll', '.pdb' } | Foreach-Object { if (!$assemblyExceptions.Contains($_.Name)) { [void]$commonFiles.Add($_.Name) }; Copy-Item -LiteralPath $_.FullName -Destination $commonPath }
129132
Get-ChildItem -Path "$PSScriptRoot/../src/Commands/bin/Debug/$configuration" | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $corePath }
133+
134+
if ($LocalPnPCore) {
135+
# Ensure the local PnP.Core SDK is copied to the module folder or else debugging will not work. This assembly otherwises comes in through PnP Framework and will still use the NuGet version instead of the local build.
136+
Write-Host " Copying local PnP.Core SDK assembly" -ForegroundColor Yellow
137+
Copy-Item -Path $pnpCoreAssembly -Destination "$destinationFolder\Core" -Force
138+
}
130139
}
131140
Catch {
132141
Write-Error "Cannot copy files to $destinationFolder. Maybe a PowerShell session is still using the module or PS modules are hosted in a OneDrive synced location. In the latter case, manually delete $destinationFolder and try again."
@@ -150,7 +159,7 @@ if ($LASTEXITCODE -eq 0) {
150159
}
151160
Write-Host "Importing dotnet core version of assembly"
152161
Import-Module -Name "$destinationFolder/Core/PnP.PowerShell.dll" -DisableNameChecking
153-
$cmdlets = get-command -Module PnP.PowerShell | ForEach-Object { "`"$_`"" }
162+
$cmdlets = Get-Command -Module PnP.PowerShell | ForEach-Object { "`"$_`"" }
154163
$cmdlets -Join ","
155164
}
156165
$cmdletsString = Start-ThreadJob -ScriptBlock $scriptBlock | Receive-Job -Wait

0 commit comments

Comments
 (0)