diff --git a/Velopack.sln b/Velopack.sln index 4bf5aa17..e9588d61 100644 --- a/Velopack.sln +++ b/Velopack.sln @@ -39,6 +39,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{3E EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaCrossPlat", "examples\AvaloniaCrossPlat\AvaloniaCrossPlat.csproj", "{1FF6A262-13D0-45DF-B818-77AC84C52C6F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LegacyTestApp", "test\LegacyTestApp\LegacyTestApp.csproj", "{8B27C4BF-21B8-48B0-80F8-74520227C35F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -89,6 +91,10 @@ Global {1FF6A262-13D0-45DF-B818-77AC84C52C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU {1FF6A262-13D0-45DF-B818-77AC84C52C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU {1FF6A262-13D0-45DF-B818-77AC84C52C6F}.Release|Any CPU.Build.0 = Release|Any CPU + {8B27C4BF-21B8-48B0-80F8-74520227C35F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8B27C4BF-21B8-48B0-80F8-74520227C35F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8B27C4BF-21B8-48B0-80F8-74520227C35F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8B27C4BF-21B8-48B0-80F8-74520227C35F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -99,6 +105,7 @@ Global {175B06A5-5C09-4DAB-A6AF-C8A2257BD1B6} = {7AC3A776-B582-4B65-9D03-BD52332B5CA3} {784B5987-2E71-4AEE-81B9-E0CC7F1DBEB3} = {7AC3A776-B582-4B65-9D03-BD52332B5CA3} {1FF6A262-13D0-45DF-B818-77AC84C52C6F} = {3EBFA551-780C-473D-A197-0EE56F2CBA82} + {8B27C4BF-21B8-48B0-80F8-74520227C35F} = {7AC3A776-B582-4B65-9D03-BD52332B5CA3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {68CA987A-9BAB-4C75-8EEB-4596BA6BBD07} diff --git a/test/LegacyTestApp/BuildClowdV2.ps1 b/test/LegacyTestApp/BuildClowdV2.ps1 new file mode 100644 index 00000000..fb38dab6 --- /dev/null +++ b/test/LegacyTestApp/BuildClowdV2.ps1 @@ -0,0 +1,9 @@ + + +Set-Alias Squirrel ($env:USERPROFILE + "\.nuget\packages\clowd.squirrel\2.11.1\tools\Squirrel.exe"); + +dotnet build -c Release -p:UseClowd=2.11.1 + +./nuget pack LegacyTestApp.nuspec -OutputDirectory bin -BasePath bin/Release/net48 + +Squirrel releasify -p bin/LegacyTestApp.1.0.0.nupkg \ No newline at end of file diff --git a/test/LegacyTestApp/BuildClowdV3.ps1 b/test/LegacyTestApp/BuildClowdV3.ps1 new file mode 100644 index 00000000..c7577a70 --- /dev/null +++ b/test/LegacyTestApp/BuildClowdV3.ps1 @@ -0,0 +1,9 @@ + + +dotnet build -c Release -p:UseClowd=3.0.210-g5f9f594 + +./nuget pack LegacyTestApp.nuspec -OutputDirectory bin -BasePath bin/Release/net48 + +dotnet tool install csq --version 3.0.210-g5f9f594 --tool-path bin/csq + +./bin/csq/csq.exe --csq-version 3.0.210-g5f9f594 releasify -p bin/LegacyTestApp.1.0.0.nupkg \ No newline at end of file diff --git a/test/LegacyTestApp/BuildSquirrelWin.ps1 b/test/LegacyTestApp/BuildSquirrelWin.ps1 new file mode 100644 index 00000000..625a1e11 --- /dev/null +++ b/test/LegacyTestApp/BuildSquirrelWin.ps1 @@ -0,0 +1,9 @@ + + +Set-Alias Squirrel ($env:USERPROFILE + "\.nuget\packages\squirrel.windows\2.0.1\tools\Squirrel.com"); + +dotnet build -c Release + +./nuget pack LegacyTestApp.nuspec -OutputDirectory bin -BasePath bin/Release/net48 + +Squirrel --releasify bin/LegacyTestApp.1.0.0.nupkg --no-msi \ No newline at end of file diff --git a/test/LegacyTestApp/LegacyTestApp.csproj b/test/LegacyTestApp/LegacyTestApp.csproj new file mode 100644 index 00000000..c6319487 --- /dev/null +++ b/test/LegacyTestApp/LegacyTestApp.csproj @@ -0,0 +1,29 @@ + + + + WinExe + net48 + latest + + + + + + + + Exe + CLOWD + + + + + + + + + + + + + + diff --git a/test/LegacyTestApp/LegacyTestApp.exe.squirrel b/test/LegacyTestApp/LegacyTestApp.exe.squirrel new file mode 100644 index 00000000..56a6051c --- /dev/null +++ b/test/LegacyTestApp/LegacyTestApp.exe.squirrel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/test/LegacyTestApp/LegacyTestApp.nuspec b/test/LegacyTestApp/LegacyTestApp.nuspec new file mode 100644 index 00000000..8813a516 --- /dev/null +++ b/test/LegacyTestApp/LegacyTestApp.nuspec @@ -0,0 +1,12 @@ + + + + LegacyTestApp + Velopack + 1.0.0 + LegacyTestApp + + + + + \ No newline at end of file diff --git a/test/LegacyTestApp/Program.cs b/test/LegacyTestApp/Program.cs new file mode 100644 index 00000000..15a33043 --- /dev/null +++ b/test/LegacyTestApp/Program.cs @@ -0,0 +1,83 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using Squirrel; +using Squirrel.SimpleSplat; + +[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] + +namespace LegacyTestApp +{ + internal class Program + { + static int Main(string[] args) + { +#if CLOWD + SquirrelAwareApp.HandleEvents( + onInitialInstall: (v, t) => debugFile("args.txt", String.Join(" ", args)), + onAppUpdate: (v, t) => debugFile("args.txt", String.Join(" ", args)), + onAppUninstall: (v, t) => debugFile("args.txt", String.Join(" ", args)), + onEveryRun: (v, t, f) => debugFile("args.txt", String.Join(" ", args)) + ); +#else + SquirrelAwareApp.HandleEvents( + onInitialInstall: v => debugFile("args.txt", String.Join(" ", args)), + onAppUpdate: v => debugFile("args.txt", String.Join(" ", args)), + onAppUninstall: v => debugFile("args.txt", String.Join(" ", args)), + onFirstRun: () => debugFile("args.txt", String.Join(" ", args)) + ); +#endif + + try { + + SquirrelLogger.Register(); + + if (args.Length == 1 && args[0] == "version") { + using var um = new UpdateManager(""); + Console.WriteLine(um.CurrentlyInstalledVersion()?.ToString() ?? "unknown_version"); + return 0; + } + + if (args.Length == 2) { + if (args[0] == "check") { + using var um = new UpdateManager(args[1]); + var info = um.CheckForUpdate().GetAwaiter().GetResult(); + if (info == null || info.ReleasesToApply == null || info.FutureReleaseEntry == null || info.ReleasesToApply.Count == 0) { + Console.WriteLine("no updates"); + return 0; + } else { + Console.WriteLine("update: " + info.FutureReleaseEntry.Version); + return 0; + } + } + + if (args[0] == "download") { + using var um = new UpdateManager(args[1]); + var entry = um.UpdateApp().GetAwaiter().GetResult(); + return entry == null ? -1 : 0; + } + + if (args[0] == "apply") { + UpdateManager.RestartApp(); + return 0; + } + } + + } catch (Exception ex) { + Console.WriteLine("exception: " + ex.ToString()); + if (Debugger.IsAttached) throw; + return -1; + } + + Console.WriteLine("Unhandled args: " + String.Join(", ", args)); + return -1; + } + + static void debugFile(string name, string message) + { + var path = Path.Combine(AppContext.BaseDirectory, "..", name); + File.AppendAllText(path, message + Environment.NewLine); + } + } +} diff --git a/test/LegacyTestApp/SquirrelLogger.cs b/test/LegacyTestApp/SquirrelLogger.cs new file mode 100644 index 00000000..a80de5f5 --- /dev/null +++ b/test/LegacyTestApp/SquirrelLogger.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LegacyTestApp +{ + internal class SquirrelLogger : Squirrel.SimpleSplat.ILogger + { + protected SquirrelLogger() + { + } + + public Squirrel.SimpleSplat.LogLevel Level { get; set; } + + public static void Register() + { + Squirrel.SimpleSplat.SquirrelLocator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Squirrel.SimpleSplat.ILogger)); + } + + public void Write(string message, Squirrel.SimpleSplat.LogLevel logLevel) + { + Console.WriteLine(message); + } + } +} diff --git a/test/LegacyTestApp/buildall.bat b/test/LegacyTestApp/buildall.bat new file mode 100644 index 00000000..927a9934 --- /dev/null +++ b/test/LegacyTestApp/buildall.bat @@ -0,0 +1,20 @@ +rmdir /s /q bin +rmdir /s /q obj +rmdir /s /q releases + +powershell -executionpolicy bypass ./BuildSquirrelWin.ps1 +copy /Y Releases\Setup.exe ..\fixtures\LegacyTestApp-SquirrelWinV2-Setup.exe + +rmdir /s /q bin +rmdir /s /q obj +rmdir /s /q releases + +powershell -executionpolicy bypass ./BuildClowdV2.ps1 +copy /Y releases\LegacyTestAppSetup.exe ..\fixtures\LegacyTestApp-ClowdV2-Setup.exe + +rmdir /s /q bin +rmdir /s /q obj +rmdir /s /q releases + +powershell -executionpolicy bypass ./BuildClowdV3.ps1 +copy /Y releases\LegacyTestAppSetup.exe ..\fixtures\LegacyTestApp-ClowdV3-Setup.exe \ No newline at end of file diff --git a/test/LegacyTestApp/nuget.exe b/test/LegacyTestApp/nuget.exe new file mode 100644 index 00000000..70909263 Binary files /dev/null and b/test/LegacyTestApp/nuget.exe differ diff --git a/test/fixtures/LegacyTestApp-ClowdV2-Setup.exe b/test/fixtures/LegacyTestApp-ClowdV2-Setup.exe new file mode 100644 index 00000000..a92b7a26 Binary files /dev/null and b/test/fixtures/LegacyTestApp-ClowdV2-Setup.exe differ diff --git a/test/fixtures/LegacyTestApp-ClowdV3-Setup.exe b/test/fixtures/LegacyTestApp-ClowdV3-Setup.exe new file mode 100644 index 00000000..ce9cfd05 Binary files /dev/null and b/test/fixtures/LegacyTestApp-ClowdV3-Setup.exe differ diff --git a/test/fixtures/LegacyTestApp-SquirrelWinV2-Setup.exe b/test/fixtures/LegacyTestApp-SquirrelWinV2-Setup.exe new file mode 100644 index 00000000..a805b020 Binary files /dev/null and b/test/fixtures/LegacyTestApp-SquirrelWinV2-Setup.exe differ