Skip to content

Commit

Permalink
AppUpdater throw error if UpdateUrl in publish.json was empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Dec 19, 2020
1 parent 159f5f4 commit 4a7e934
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
5 changes: 1 addition & 4 deletions Pub/PublishApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ if (-not $noclean)
dotnet clean "$projectDir" -c "Release" --output $outDir
}
dotnet publish "$projectDir" -c "Release" --output $outDir --framework net5.0 --no-self-contained /p:Version=$versionParam
if ($LASTEXITCODE -gt 0)
{
Throw "The publish exited with error code: " + $lastexitcode;
}
if ($LASTEXITCODE -gt 0) { Throw "The publish exited with error code: " + $lastexitcode; }

#####
# create zip package
Expand Down
Binary file modified Pub/Version.json
Binary file not shown.
5 changes: 4 additions & 1 deletion VpnHood.Common/AppUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public AppUpdater(string appFolder = null, AppUpdaterOptions options = null)
PublishInfo = JsonSerializer.Deserialize<PublishInfo>(File.ReadAllText(PublishInfoPath));

//set update Url by PublishInfo if it is not overwrited by parameter
if (UpdateUri == null && PublishInfo.UpdateUrl != null)
if (UpdateUri == null && !string.IsNullOrEmpty(PublishInfo.UpdateUrl))
UpdateUri = new Uri(PublishInfo.UpdateUrl);
}
}
Expand Down Expand Up @@ -172,6 +172,9 @@ private void CheckUpdateOffline()

private async Task DownloadUpdate(PublishInfo publishInfo)
{
if (string.IsNullOrEmpty(publishInfo.PackageDownloadUrl))
throw new Exception($"Could not find : {nameof(publishInfo.PackageDownloadUrl)}");

// open source stream from net
using var httpClient = new HttpClient { Timeout = TimeSpan.FromMilliseconds(10000) };
using var srcStream = await httpClient.GetStreamAsync(publishInfo.PackageDownloadUrl);
Expand Down
5 changes: 2 additions & 3 deletions VpnHood.Server.App.NetCore/_publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ $packageName = "VpnHoodServer";

. "$PSScriptRoot\..\Pub\PublishApp.ps1" `
$PSScriptRoot -withLauncher `
-packageName "$packageName" `
-packageName $packageName `
-updateUrl "https://github.com/vpnhood/VpnHood/releases/latest/download/$packageName.json" `
-packageDownloadUrl "https://github.com/vpnhood/VpnHood/releases/latest/download/$packageName.zip" `

-packageDownloadUrl "https://github.com/vpnhood/VpnHood/releases/latest/download/$packageName.zip"
1 change: 1 addition & 0 deletions VpnHood.sln
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pub", "Pub", "{AD60711B-C6D
Pub\PublishApps.ps1 = Pub\PublishApps.ps1
Pub\PublishNuget.ps1 = Pub\PublishNuget.ps1
Pub\PublishNugets.ps1 = Pub\PublishNugets.ps1
..\VpnHood.wiki\Version-History.md = ..\VpnHood.wiki\Version-History.md
Pub\Version.json = Pub\Version.json
EndProjectSection
EndProject
Expand Down

0 comments on commit 4a7e934

Please sign in to comment.