Skip to content

Commit

Permalink
Ask for execution policy change before running script.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Macocian committed Apr 9, 2021
1 parent a9aa730 commit 9fd7d8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Daybreak/Daybreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<Version>0.2</Version>
<Version>0.2.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Daybreak/Services/Updater/ApplicationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed class ApplicationUpdater : IApplicationUpdater
private const string OutputPathTag = "{OUTPUTPATh}";
private const string Url = "https://github.com/AlexMacocian/Daybreak/releases/latest";
private const string DownloadUrl = $"https://github.com/AlexMacocian/Daybreak/releases/download/v{VersionTag}/Daybreakv{VersionTag}.zip";
private const string SetExecutionPolicy = $"Set-ExecutionPolicy RemoteSigned -Scope CurrentUser";
private const string DelayCommand = "Start-Sleep -m 3000";
private const string ExtractCommandTemplate = $"Expand-Archive -Path '{InputFileTag}' -DestinationPath '{OutputPathTag}' -Force";
private const string RunClientCommand = @".\Daybreak.exe";
Expand Down Expand Up @@ -99,7 +100,8 @@ public async Task<bool> UpdateAvailable()
public void FinalizeUpdate()
{
File.WriteAllLines(ExtractAndRunPs1, new List<string>()
{
{
SetExecutionPolicy,
DelayCommand,
ExtractCommandTemplate
.Replace(InputFileTag, Path.GetFullPath(TempFile))
Expand Down

0 comments on commit 9fd7d8b

Please sign in to comment.