Skip to content

Commit

Permalink
Post-build event fixes; fix to updater debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Brhsoftco committed Apr 9, 2021
1 parent 911d79e commit 0afebf7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
14 changes: 7 additions & 7 deletions GitHubUpdater/UpdateClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,19 @@ private string GetUpdateInfo(string resource, bool waitWindow = true)
/// </summary>
/// <param name="apiResponse">The raw JSON itself</param>
/// <param name="prettyPrint">Whether or not the JSON is formatted when the file is written (false for better performance, true for readability)</param>
private static void LogApiResponse(string apiResponse, bool prettyPrint = false)
private void LogApiResponse(string apiResponse, bool prettyPrint = false)
{
try
{
//check if the data is valid before trying to write it to a file
if (!string.IsNullOrEmpty(apiResponse))
//check if the data is valid before trying to write it to a file,
//and only allow this function to run if in debug mode
if (!string.IsNullOrWhiteSpace(apiResponse) && DebugMode)
{
//the reason we hash the time is for uniqueness; it'll be different each time
//since the system time keeps ticking along.
var timeHash = MD5Helper.CalculateMd5Hash(DateTime.Now.ToString());
//hash a new GUID for uniqueness
var uniqueString = MD5Helper.CalculateMd5Hash(Guid.NewGuid().ToString());

//GitHub API responses are always in JSON format; the extension must reflect this.
var fileName = @$"apiResponse_{timeHash}.json";
var fileName = @$"apiResponse_{uniqueString}.json";
var fileDir = $@"{Globals.UpdateRootDir}\debug";
var filePath = $@"{fileDir}\{fileName}";

Expand Down
37 changes: 26 additions & 11 deletions PlexDL/PlexDL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -404,21 +404,36 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>IF $(ConfigurationName) == Release (
IF NOT EXIST "$(TargetDir)lib\" mkdir $(TargetDir)lib
IF NOT EXIST "$(TargetDir)pdb\" mkdir $(TargetDir)pdb
IF NOT EXIST "$(TargetDir)xml\" mkdir $(TargetDir)xml
<PostBuildEvent>@ECHO OFF
IF $(ConfigurationName) == Release (

copy /y $(TargetDir)*.dll $(TargetDir)lib
copy /y $(TargetDir)*.pdb $(TargetDir)pdb
copy /y $(TargetDir)*.xml $(TargetDir)xml
REM create new directories if they don't exist
ECHO Creating Release Directories....
IF NOT EXIST "$(TargetDir)lib\" mkdir "$(TargetDir)lib" &gt;nul
IF NOT EXIST "$(TargetDir)pdb\" mkdir "$(TargetDir)pdb" &gt;nul
IF NOT EXIST "$(TargetDir)xml\" mkdir "$(TargetDir)xml" &gt;nul

del /f /q *.dll
del /f /q *.pdb
del /f /q *.xml
REM copy to new location
ECHO Copying Release Files...
copy /y "$(TargetDir)*.dll" "$(TargetDir)lib" &gt;nul
copy /y "$(TargetDir)*.pdb" "$(TargetDir)pdb" &gt;nul
copy /y "$(TargetDir)*.xml" "$(TargetDir)xml" &gt;nul

REM delete old files
ECHO Cleaning Release Files...
del /f /q *.dll &gt;nul
del /f /q *.pdb &gt;nul
del /f /q *.xml &gt;nul

REM config files get restored on run
del /f /q *.config
ECHO Cleaning Old Configuration Files...
del /f /q *.config &gt;nul

REM create release zip
ECHO Creating Release Package...
powershell Compress-Archive -Force -Path '$(TargetDir)*' -DestinationPath '$(TargetDir)Release.zip' &gt;nul

ECHO Release Package Is Ready
)</PostBuildEvent>
</PropertyGroup>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
Expand Down

0 comments on commit 0afebf7

Please sign in to comment.