From 994f9635ef77b60ec79797db2bc8ccc981362474 Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Sat, 18 Dec 2021 01:29:26 +0100 Subject: [PATCH] Fix post build scripts to support moved F# executables --- .gitignore | 1 + TweetDuck.csproj | 10 +++------- bld/POST BUILD.bat | 12 ------------ bld/POST BUILD.ps1 | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 19 deletions(-) delete mode 100644 bld/POST BUILD.bat create mode 100644 bld/POST BUILD.ps1 diff --git a/.gitignore b/.gitignore index bb7ef794..4fcdddf4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ bld/* !bld/*.iss !bld/*.bat +!bld/*.ps1 !bld/Redist !bld/Resources diff --git a/TweetDuck.csproj b/TweetDuck.csproj index 5426a663..a6d9b539 100644 --- a/TweetDuck.csproj +++ b/TweetDuck.csproj @@ -405,15 +405,11 @@ rmdir "$(ProjectDir)bin\Release" rmdir "$(TargetDir)scripts" /S /Q rmdir "$(TargetDir)plugins" /S /Q -IF EXIST "$(ProjectDir)bld\post_build.exe" ( - "$(ProjectDir)bld\post_build.exe" "$(TargetDir)\" "$(ProjectDir)\" "$(ConfigurationName)" -) ELSE ( - "$(DevEnvDir)CommonExtensions\Microsoft\FSharp\fsi.exe" "$(ProjectDir)Resources\PostBuild.fsx" --exec --nologo -- "$(TargetDir)\" "$(ProjectDir)\" "$(ConfigurationName)" -) +"$(ProjectDir)bld\post_build.exe" "$(TargetDir)\" "$(ProjectDir)\" "$(ConfigurationName)" </PostBuildEvent> </PropertyGroup> - <Target Name="BeforeBuild" Condition="(!$([System.IO.File]::Exists("$(ProjectDir)\bld\post_build.exe")) OR ($([System.IO.File]::GetLastWriteTime("$(ProjectDir)\Resources\PostBuild.fsx").Ticks) > $([System.IO.File]::GetLastWriteTime("$(ProjectDir)\bld\post_build.exe").Ticks)))"> - <Exec Command=""$(ProjectDir)bld\POST BUILD.bat" "$(DevEnvDir)CommonExtensions\Microsoft\FSharp\fsc.exe"" WorkingDirectory="$(ProjectDir)bld\" IgnoreExitCode="true" /> + <Target Name="BeforeBuild" Condition="(!$([System.IO.File]::Exists("$(ProjectDir)bld\post_build.exe")) OR ($([System.IO.File]::GetLastWriteTime("$(ProjectDir)Resources\PostBuild.fsx").Ticks) > $([System.IO.File]::GetLastWriteTime("$(ProjectDir)bld\post_build.exe").Ticks)))"> + <Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File "$(ProjectDir)bld\POST BUILD.ps1" "$(DevEnvDir)\CommonExtensions\Microsoft\FSharp"" WorkingDirectory="$(ProjectDir)bld\" IgnoreExitCode="true" /> </Target> <Target Name="AfterBuild" Condition="$(ConfigurationName) == Release"> <Exec Command="del "$(TargetDir)*.pdb"" /> diff --git a/bld/POST BUILD.bat b/bld/POST BUILD.bat deleted file mode 100644 index 16089dfb..00000000 --- a/bld/POST BUILD.bat +++ /dev/null @@ -1,12 +0,0 @@ -@ECHO OFF - -IF EXIST "post_build.exe" ( - DEL "post_build.exe" -) - -IF NOT EXIST %1 ( - ECHO fsc.exe not found - EXIT 1 -) - -%1 --standalone --deterministic --preferreduilang:en-US --platform:x86 --target:exe --out:post_build.exe "%~dp0..\Resources\PostBuild.fsx" diff --git a/bld/POST BUILD.ps1 b/bld/POST BUILD.ps1 new file mode 100644 index 00000000..575ed712 --- /dev/null +++ b/bld/POST BUILD.ps1 @@ -0,0 +1,22 @@ +if ([IO.File]::Exists("post_build.exe")) { + [IO.File]::Delete("post_build.exe"); +} + +$fs = $args[0]; +$fsc = ""; + +if ([IO.File]::Exists("$fs\fsc.exe")) { + $fsc = "$fs\fsc.exe"; +} + +if ([IO.File]::Exists("$fs\Tools\fsc.exe")) { + $fsc = "$fs\Tools\fsc.exe"; +} + +if ($fsc -eq "") { + Write-Host "fsc.exe not found" + $Host.SetShouldExit(1); + exit +} + +& $fsc --standalone --deterministic --preferreduilang:en-US --platform:x86 --target:exe --out:post_build.exe "$PSScriptRoot\..\Resources\PostBuild.fsx"