mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-17 12:15:47 +02:00
Move most of post build event (copying, cleanup) to PostBuild.ps1
This commit is contained in:
parent
24224ab4c6
commit
caea8d4315
@ -1,41 +1,71 @@
|
|||||||
Param([Parameter(Mandatory = $True, Position = 1)][string] $dir)
|
Param(
|
||||||
|
[Parameter(Mandatory = $True, Position = 1)][string] $targetDir,
|
||||||
|
[Parameter(Mandatory = $True, Position = 2)][string] $projectDir
|
||||||
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
Set-Location $dir
|
|
||||||
|
|
||||||
$version = (Get-Item TweetDuck.exe).VersionInfo.FileVersion
|
|
||||||
Write-Host "TweetDuck version" $version
|
|
||||||
|
|
||||||
function Check-Carriage-Return{
|
|
||||||
Param([Parameter(Mandatory = $True, Position = 1)] $fname)
|
|
||||||
|
|
||||||
$file = @(Get-ChildItem -Include $fname -Recurse)[0]
|
|
||||||
|
|
||||||
if ((Get-Content -Path $file.FullName -Raw).Contains("`r")){
|
|
||||||
Throw "$fname cannot contain carriage return"
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Verified" $file.FullName.Substring($dir.Length)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Rewrite-File{
|
|
||||||
[CmdletBinding()]
|
|
||||||
Param([Parameter(Mandatory = $True, ValueFromPipeline = $True)][array] $lines, [Parameter(Mandatory = $True, Position = 1)] $file)
|
|
||||||
|
|
||||||
$relative = $file.FullName.Substring($dir.Length)
|
|
||||||
|
|
||||||
if ($relative.StartsWith("scripts\")){
|
|
||||||
$lines = (,("#" + $version) + $lines)
|
|
||||||
}
|
|
||||||
|
|
||||||
$lines | Where { $_ -ne '' } | Set-Content -Path $file.FullName
|
|
||||||
Write-Host "Processed" $relative
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
Write-Host "------------------------------"
|
||||||
|
|
||||||
|
$version = (Get-Item (Join-Path $targetDir "TweetDuck.exe")).VersionInfo.FileVersion
|
||||||
|
Write-Host "TweetDuck version" $version
|
||||||
|
|
||||||
|
Write-Host "------------------------------"
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
|
||||||
|
Remove-Item -Path (Join-Path $targetDir "locales\*.pak") -Exclude "en-US.pak"
|
||||||
|
|
||||||
|
# Copy resources
|
||||||
|
|
||||||
|
Copy-Item (Join-Path $projectDir "bld\Resources\CEFSHARP-LICENSE.txt") -Destination $targetDir -Force
|
||||||
|
Copy-Item (Join-Path $projectDir "LICENSE.md") -Destination (Join-Path $targetDir "LICENSE.txt") -Force
|
||||||
|
|
||||||
|
New-Item -ItemType directory -Path $targetDir -Name "scripts" | Out-Null
|
||||||
|
New-Item -ItemType directory -Path $targetDir -Name "plugins" | Out-Null
|
||||||
|
New-Item -ItemType directory -Path $targetDir -Name "plugins\official" | Out-Null
|
||||||
|
New-Item -ItemType directory -Path $targetDir -Name "plugins\user" | Out-Null
|
||||||
|
|
||||||
|
Copy-Item (Join-Path $projectDir "Resources\Scripts\*") -Destination (Join-Path $targetDir "scripts") -Recurse
|
||||||
|
Copy-Item (Join-Path $projectDir "Resources\Plugins\*") -Exclude ".debug", "emoji-instructions.txt" -Destination (Join-Path $targetDir "plugins\official") -Recurse
|
||||||
|
|
||||||
|
# Post processing
|
||||||
|
|
||||||
|
function Check-Carriage-Return{
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory = $True, Position = 1)] $fname
|
||||||
|
)
|
||||||
|
|
||||||
|
$file = @(Get-ChildItem -Path $targetDir -Include $fname -Recurse)[0]
|
||||||
|
|
||||||
|
if ((Get-Content -Path $file.FullName -Raw).Contains("`r")){
|
||||||
|
Throw "$fname cannot contain carriage return"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Verified" $file.FullName.Substring($targetDir.Length)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Rewrite-File{
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory = $True, ValueFromPipeline = $True)][array] $lines,
|
||||||
|
[Parameter(Mandatory = $True, Position = 1)] $file
|
||||||
|
)
|
||||||
|
|
||||||
|
$relativePath = $file.FullName.Substring($targetDir.Length)
|
||||||
|
|
||||||
|
if ($relativePath.StartsWith("scripts\")){
|
||||||
|
$lines = (,("#" + $version) + $lines)
|
||||||
|
}
|
||||||
|
|
||||||
|
$lines | Where { $_ -ne '' } | Set-Content -Path $file.FullName
|
||||||
|
Write-Host "Processed" $relativePath
|
||||||
|
}
|
||||||
|
|
||||||
Check-Carriage-Return("emoji-ordering.txt")
|
Check-Carriage-Return("emoji-ordering.txt")
|
||||||
|
|
||||||
ForEach($file in Get-ChildItem -Filter *.js -Exclude configuration.default.js -Recurse){
|
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.js" -Exclude "configuration.default.js" -Recurse){
|
||||||
$lines = Get-Content -Path $file.FullName
|
$lines = Get-Content -Path $file.FullName
|
||||||
$lines = $lines | % { $_.TrimStart() }
|
$lines = $lines | % { $_.TrimStart() }
|
||||||
$lines = $lines -Replace '^(.*?)((?<=^|[;{}()])\s?//(?:\s.*|$))?$', '$1'
|
$lines = $lines -Replace '^(.*?)((?<=^|[;{}()])\s?//(?:\s.*|$))?$', '$1'
|
||||||
@ -43,7 +73,7 @@ try{
|
|||||||
,$lines | Rewrite-File $file
|
,$lines | Rewrite-File $file
|
||||||
}
|
}
|
||||||
|
|
||||||
ForEach($file in Get-ChildItem -Filter *.css -Recurse){
|
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.css" -Recurse){
|
||||||
$lines = Get-Content -Path $file.FullName
|
$lines = Get-Content -Path $file.FullName
|
||||||
$lines = $lines -Replace '\s*/\*.*?\*/', ''
|
$lines = $lines -Replace '\s*/\*.*?\*/', ''
|
||||||
$lines = $lines -Replace '^\s+(.+):\s?(.+?)(?:\s?(!important))?;$', '$1:$2$3;'
|
$lines = $lines -Replace '^\s+(.+):\s?(.+?)(?:\s?(!important))?;$', '$1:$2$3;'
|
||||||
@ -51,10 +81,12 @@ try{
|
|||||||
@(($lines | Where { $_ -ne '' }) -Join ' ') | Rewrite-File $file
|
@(($lines | Where { $_ -ne '' }) -Join ' ') | Rewrite-File $file
|
||||||
}
|
}
|
||||||
|
|
||||||
ForEach($file in Get-ChildItem -Filter *.html -Recurse){
|
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.html" -Recurse){
|
||||||
$lines = Get-Content -Path $file.FullName
|
$lines = Get-Content -Path $file.FullName
|
||||||
,($lines | % { $_.TrimStart() }) | Rewrite-File $file
|
,($lines | % { $_.TrimStart() }) | Rewrite-File $file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host "------------------------------"
|
||||||
}catch{
|
}catch{
|
||||||
Write-Host "Encountered an error while running PostBuild.ps1 on line" $_.InvocationInfo.ScriptLineNumber
|
Write-Host "Encountered an error while running PostBuild.ps1 on line" $_.InvocationInfo.ScriptLineNumber
|
||||||
Write-Host $_
|
Write-Host $_
|
||||||
|
@ -402,37 +402,20 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>xcopy "$(ProjectDir)LICENSE.md" "$(TargetDir)" /Y
|
<PostBuildEvent>rmdir "$(ProjectDir)bin\Debug"
|
||||||
del "$(TargetDir)LICENSE.txt"
|
|
||||||
ren "$(TargetDir)LICENSE.md" "LICENSE.txt"
|
|
||||||
xcopy "$(ProjectDir)bld\Resources\CEFSHARP-LICENSE.txt" "$(TargetDir)" /Y
|
|
||||||
|
|
||||||
rmdir "$(TargetDir)scripts" /S /Q
|
|
||||||
mkdir "$(TargetDir)scripts"
|
|
||||||
xcopy "$(ProjectDir)Resources\Scripts\*" "$(TargetDir)scripts\" /E /Y
|
|
||||||
|
|
||||||
rmdir "$(TargetDir)plugins" /S /Q
|
|
||||||
mkdir "$(TargetDir)plugins"
|
|
||||||
mkdir "$(TargetDir)plugins\official"
|
|
||||||
mkdir "$(TargetDir)plugins\user"
|
|
||||||
xcopy "$(ProjectDir)Resources\Plugins\*" "$(TargetDir)plugins\official\" /E /Y
|
|
||||||
rmdir "$(TargetDir)plugins\official\.debug" /S /Q
|
|
||||||
del "$(TargetDir)plugins\official\emoji-keyboard\emoji-instructions.txt"
|
|
||||||
|
|
||||||
rmdir "$(ProjectDir)bin\Debug"
|
|
||||||
rmdir "$(ProjectDir)bin\Release"
|
rmdir "$(ProjectDir)bin\Release"
|
||||||
|
|
||||||
attrib +R "$(TargetDir)locales\en-US.pak"
|
rmdir "$(TargetDir)scripts" /S /Q
|
||||||
del /Q /A:-R "$(TargetDir)locales\*.pak"
|
rmdir "$(TargetDir)plugins" /S /Q
|
||||||
attrib -R "$(TargetDir)locales\en-US.pak"
|
|
||||||
|
powershell -ExecutionPolicy Unrestricted -File "$(ProjectDir)Resources\PostBuild.ps1" "$(TargetDir)\" "$(ProjectDir)\"
|
||||||
|
|
||||||
if $(ConfigurationName) == Debug (
|
if $(ConfigurationName) == Debug (
|
||||||
rmdir "$(TargetDir)plugins\official\.debug" /S /Q
|
rmdir "$(TargetDir)plugins\official\.debug" /S /Q
|
||||||
mkdir "$(TargetDir)plugins\user\.debug"
|
mkdir "$(TargetDir)plugins\user\.debug"
|
||||||
xcopy "$(ProjectDir)Resources\Plugins\.debug\*" "$(TargetDir)plugins\user\.debug\" /E /Y
|
xcopy "$(ProjectDir)Resources\Plugins\.debug\*" "$(TargetDir)plugins\user\.debug\" /E /Y
|
||||||
)
|
)
|
||||||
|
</PostBuildEvent>
|
||||||
powershell -ExecutionPolicy Unrestricted -File "$(ProjectDir)Resources\PostBuild.ps1" "$(TargetDir)\"</PostBuildEvent>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Target Name="AfterBuild" Condition="$(ConfigurationName) == Release">
|
<Target Name="AfterBuild" Condition="$(ConfigurationName) == Release">
|
||||||
<Exec Command="del "$(TargetDir)*.pdb"" />
|
<Exec Command="del "$(TargetDir)*.pdb"" />
|
||||||
|
Loading…
Reference in New Issue
Block a user