diff --git a/Scripts/build.ps1 b/Scripts/build.ps1 index d007483dfe..6da8031310 100644 --- a/Scripts/build.ps1 +++ b/Scripts/build.ps1 @@ -1,3 +1,6 @@ +param([string]$config, [string]$solution) +Write-Host "Current config is $config" + function Build-Version { if ([string]::IsNullOrEmpty($env:APPVEYOR_BUILD_VERSION)) { $v = "1.2.0" @@ -10,10 +13,12 @@ function Build-Version { } function Build-Path { - if ([string]::IsNullOrEmpty($env:APPVEYOR_BUILD_FOLDER)) { - $p = Convert-Path . - } else { + if (![string]::IsNullOrEmpty($env:APPVEYOR_BUILD_FOLDER)) { $p = $env:APPVEYOR_BUILD_FOLDER + } elseif (![string]::IsNullOrEmpty($solution)) { + $p = $solution + } else { + $p = Get-Location } Write-Host "Build Folder: $p" @@ -22,6 +27,29 @@ function Build-Path { return $p } +function Copy-Resources ($path, $config) { + $project = "$path\Wox" + $output = "$path\Output" + $target = "$output\$config" + Copy-Item -Recurse -Force $project\Themes\* $target\Themes\ + Copy-Item -Recurse -Force $project\Images\* $target\Images\ + Copy-Item -Recurse -Force $path\Plugins\HelloWorldPython $target\Plugins\HelloWorldPython + Copy-Item -Recurse -Force $path\JsonRPC $target\JsonRPC + Copy-Item -Force $path\packages\squirrel*\tools\Squirrel.exe $output\Update.exe +} + +function Delete-Unused ($path, $config) { + $target = "$path\Output\$config" + $included = @( + "Wox.Plugin.pdb", "Wox.Plugin.dll", "Wox.Core.*", "Wox.Infrastructure.*", + "ICSharpCode.*", "JetBrains.*", "Pinyin4Net.*", "NLog.*" + ) + foreach ($i in $included){ + Remove-Item -Path $target\Plugins -Include $i -Recurse + } + Remove-Item -Path $target -Include "*.xml" -Recurse +} + function Validate-Directory ($output) { New-Item $output -ItemType Directory -Force } @@ -65,13 +93,14 @@ function Pack-Squirrel-Installer ($path, $version, $output) { $nupkg = "$output\Wox.$version.nupkg" Write-Host "nupkg path: $nupkg" $icon = "$path\Wox\Resources\app.ico" + Write-Host "icon: $icon" # Squirrel.com: https://github.com/Squirrel/Squirrel.Windows/issues/369 New-Alias Squirrel $path\packages\squirrel*\tools\Squirrel.exe -Force # why we need Write-Output: https://github.com/Squirrel/Squirrel.Windows/issues/489#issuecomment-156039327 # directory of releaseDir in fucking squirrel can't be same as directory ($nupkg) in releasify $temp = "$output\Temp" - Squirrel --releasify $nupkg --releaseDir $temp --setupIcon $iconPath --no-msi | Write-Output + Squirrel --releasify $nupkg --releaseDir $temp --setupIcon $icon --no-msi | Write-Output Move-Item $temp\* $output -Force Remove-Item $temp @@ -84,23 +113,27 @@ function Pack-Squirrel-Installer ($path, $version, $output) { } function Main { - $v = Build-Version $p = Build-Path - $o = "$p\Output\Packages" - New-Alias Nuget $p\packages\NuGet.CommandLine.*\tools\NuGet.exe -Force + $v = Build-Version + Copy-Resources $p $config - Validate-Directory $o + if ($config -eq "Release"){ + + Delete-Unused $p $config + $o = "$p\Output\Packages" + Validate-Directory $o + New-Alias Nuget $p\packages\NuGet.CommandLine.*\tools\NuGet.exe -Force + Pack-Squirrel-Installer $p $v $o - $isInCI = $env:APPVEYOR - if ($isInCI) { - Pack-Nuget $p $v $o - Zip-Release $p $v $o + $isInCI = $env:APPVEYOR + if ($isInCI) { + Pack-Nuget $p $v $o + Zip-Release $p $v $o + } + + Write-Host "List output directory" + Get-ChildItem $o } - - Pack-Squirrel-Installer $p $v $o - - Write-Host "List output directory" - Get-ChildItem $o } Main \ No newline at end of file diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 4ef7286fb8..ff7771adb0 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -433,33 +433,7 @@ - -xcopy /Y /E $(ProjectDir)Themes\* $(TargetDir)Themes\ -xcopy /Y /E $(ProjectDir)Images\* $(TargetDir)Images\ -xcopy /Y /D /E $(SolutionDir)Plugins\HelloWorldPython\* $(TargetDir)Plugins\HelloWorldPython\* -xcopy /Y /E $(SolutionDir)JsonRPC\* $(TargetDir)JsonRPC\ - -cd $(SolutionDir)packages\squirrel*\tools -copy /Y Squirrel.exe $(TargetDir)..\Update.exe -cd $(SolutionDir) - -if $(ConfigurationName) == Release ( -cd "$(TargetDir)Plugins" & del /s /q NLog.dll -cd "$(TargetDir)Plugins" & del /s /q NLog.config -cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.pdb -cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.dll -cd "$(TargetDir)Plugins" & del /s /q Wox.Core.dll -cd "$(TargetDir)Plugins" & del /s /q Wox.Core.pdb -cd "$(TargetDir)Plugins" & del /s /q ICSharpCode.SharpZipLib.dll -cd "$(TargetDir)Plugins" & del /s /q NAppUpdate.Framework.dll -cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.dll -cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.pdb -cd "$(TargetDir)Plugins" & del /s /q Newtonsoft.Json.dll -cd "$(TargetDir)Plugins" & del /s /q JetBrains.Annotations.dll -cd "$(TargetDir)Plugins" & del /s /q Pinyin4Net.dll -cd "$(TargetDir)" & del /s /q *.xml -) - + powershell.exe -NoProfile -File $(SolutionDir)Scripts\build.ps1 $(ConfigurationName) $(SolutionDir) taskkill /f /fi "IMAGENAME eq Wox.exe"