diff --git a/Build-Plugin.ps1 b/Build-Plugin.ps1 index 06caf80..1c2db89 100644 --- a/Build-Plugin.ps1 +++ b/Build-Plugin.ps1 @@ -52,10 +52,6 @@ Write-Host "Using MSBuild: $msbuild" -ForegroundColor Gray # --- Resolve all HintPaths to Disco bin --- $csproj = Join-Path $PluginDir "$PluginName.csproj" $csprojContent = Get-Content $csproj -Raw - -# Replace ALL HintPath entries to point at DiscoBinPath -# This catches Disco.Models, Disco.Data, Disco.Services, Newtonsoft.Json, -# System.Web.Mvc, System.Web.WebPages, System.Web.Razor, etc. $csprojContent = [regex]::Replace($csprojContent, '[^<]+\\([^\\<]+\.dll)', "$DiscoBinPath\`$1") $tempCsproj = Join-Path $PluginDir "$PluginName.build.csproj" @@ -85,7 +81,6 @@ Write-Host "Build successful: $pluginDll" -ForegroundColor Green # --- Generate Manifest --- Write-Host "`nGenerating manifest..." -ForegroundColor Yellow -# Copy all DLLs from Disco bin to build output for ManifestGenerator foreach ($dll in $requiredDlls) { Copy-Item (Join-Path $DiscoBinPath $dll) $buildOutput -Force -ErrorAction SilentlyContinue } @@ -95,7 +90,6 @@ foreach ($dep in $extraDlls) { if (Test-Path $depPath) { Copy-Item $depPath $buildOutput -Force -ErrorAction SilentlyContinue } } -# Try ManifestGenerator $useManifestGen = $false $manifestGenExe = Join-Path $DiscoBinPath "Disco.Services.Plugins.ManifestGenerator.exe" if (-not (Test-Path $manifestGenExe)) { @@ -131,12 +125,8 @@ if (-not $useManifestGen) { # --- Package --- Write-Host "`nPackaging .discoPlugin file..." -ForegroundColor Yellow -$excludePatterns = @( - "Disco.Models.*", "Disco.Data.*", "Disco.Services.*", "Disco.Web.*", "Disco.BI.*", - "EntityFramework.*", "System.Web.Mvc.*", "System.Web.WebPages.*", "System.Web.Razor.*", - "RazorGenerator.Mvc.*", "Newtonsoft.Json.*", - "*.build.csproj", "*.discoPlugin" -) +# Only include the plugin DLL, PDB, and manifest - nothing else +$includeFiles = @("$PluginName.dll", "$PluginName.pdb", "manifest.json") if (-not $version) { $version = [System.Reflection.AssemblyName]::GetAssemblyName($pluginDll).Version @@ -145,29 +135,29 @@ if (-not $version) { $packageName = "$PluginName-$($version.ToString()).discoPlugin" $packagePath = Join-Path $PluginDir $packageName +# Clean old packages Get-ChildItem $PluginDir -Filter "*.discoPlugin" | Remove-Item -Force +Get-ChildItem $PluginDir -Filter "*.zip" | Where-Object { $_.Name -like "$PluginName*" } | Remove-Item -Force -$filesToPackage = Get-ChildItem $buildOutput -Recurse -File | Where-Object { - $file = $_.Name - -not ($excludePatterns | Where-Object { $file -like $_ }) -} - +# Build clean temp folder with only plugin files $tempPkg = Join-Path $env:TEMP "discoplugin_$([guid]::NewGuid().ToString('N'))" New-Item -ItemType Directory -Path $tempPkg -Force | Out-Null -foreach ($f in $filesToPackage) { - $relativePath = $f.FullName.Substring($buildOutput.Length + 1) - $destPath = Join-Path $tempPkg $relativePath - $destDir = Split-Path $destPath -Parent - if (-not (Test-Path $destDir)) { New-Item -ItemType Directory -Path $destDir -Force | Out-Null } - Copy-Item $f.FullName $destPath -Force +foreach ($f in $includeFiles) { + $src = Join-Path $buildOutput $f + if (Test-Path $src) { + Copy-Item $src $tempPkg -Force + } } Write-Host "Files in package:" -ForegroundColor Gray -Get-ChildItem $tempPkg -Recurse -File | ForEach-Object { - Write-Host " $($_.FullName.Substring($tempPkg.Length + 1))" -ForegroundColor Gray +Get-ChildItem $tempPkg -File | ForEach-Object { + Write-Host " $($_.Name)" -ForegroundColor Gray } -Compress-Archive -Path "$tempPkg\*" -DestinationPath $packagePath -Force +# Create as .zip first (Compress-Archive requires .zip), then rename +$zipPath = Join-Path $PluginDir "$PluginName-$($version.ToString()).zip" +Compress-Archive -Path "$tempPkg\*" -DestinationPath $zipPath -Force +Rename-Item $zipPath $packageName -Force Remove-Item $tempPkg -Recurse -Force $packageSize = [math]::Round((Get-Item $packagePath).Length / 1KB, 1)