Skip to content

Commit 777d372

Browse files
committed
Fixing local Core SDK Build not being debuggable
1 parent a43ef12 commit 777d372

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

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)