mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Test project builds again
This commit is contained in:
37
.github/workflows/build.yml
vendored
37
.github/workflows/build.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: Build Squirrel
|
name: Build Squirrel
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [ push, pull_request ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOTNET_VERSION: '6.0.202'
|
DOTNET_VERSION: '6.0.202'
|
||||||
@@ -17,30 +17,11 @@ jobs:
|
|||||||
uses: actions/setup-dotnet@v1
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||||
# - name: Install NGBV
|
|
||||||
# run: dotnet tool install --tool-path . nbgv
|
|
||||||
- name: Build
|
- name: Build
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: .\build.ps1
|
run: .\build.ps1
|
||||||
# - name: Create NuGet Package
|
- name: Test
|
||||||
# shell: pwsh
|
run: dotnet test test\Squirrel.Tests.csproj -l "console;verbosity=detailed"
|
||||||
# run: .\pack.ps1
|
|
||||||
# - name: Test
|
|
||||||
# run: dotnet test test\Squirrel.Tests.csproj -l "console;verbosity=detailed"
|
|
||||||
# - name: "Upload Tools"
|
|
||||||
# uses: actions/upload-artifact@v3
|
|
||||||
# with:
|
|
||||||
# path: .\build\SquirrelTools*.zip
|
|
||||||
# if-no-files-found: error
|
|
||||||
# https://stackoverflow.com/questions/63817052/github-actions-run-step-only-for-certain-pull-request-base-branches
|
|
||||||
# - name: "Upload NuGet Package"
|
|
||||||
# uses: actions/upload-artifact@v3
|
|
||||||
# with:
|
|
||||||
# path: .\build\Clowd.Squirrel*.nupkg
|
|
||||||
# if-no-files-found: error
|
|
||||||
# - name: Publish to GitHub Packages
|
|
||||||
# if: ${{ github.ref == 'ref/head/develop' }}
|
|
||||||
# run: dotnet nuget push .\build\Clowd.Squirrel*.nupkg
|
|
||||||
- name: Upload Windows Artifacts
|
- name: Upload Windows Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -54,7 +35,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: tools
|
name: tools
|
||||||
path: squirrel-win-x64.zip
|
path: squirrel-win-x64.zip
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
name: Build OSX
|
name: Build OSX
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
@@ -75,12 +56,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: osx-build
|
name: osx-build
|
||||||
path: ./publish/*
|
path: ./publish/*
|
||||||
|
|
||||||
|
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
|
||||||
package-macos:
|
package-macos:
|
||||||
name: Package OSX
|
name: Package OSX
|
||||||
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/cs/xplat' }}
|
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/cs/xplat' }}
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
needs: [build-macos]
|
needs: [ build-macos ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Download MacOS Artifacts
|
- name: Download MacOS Artifacts
|
||||||
@@ -122,12 +104,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: tools
|
name: tools
|
||||||
path: squirrel-osx-x64.zip
|
path: squirrel-osx-x64.zip
|
||||||
|
|
||||||
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
|
|
||||||
deploy:
|
deploy:
|
||||||
name: "Deploy"
|
name: "Deploy"
|
||||||
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/cs/xplat' }}
|
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/cs/xplat' }}
|
||||||
needs: [build-windows, package-macos]
|
needs: [ build-windows, package-macos ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
@@ -275,12 +275,36 @@ namespace Squirrel
|
|||||||
/// Creates a new Platform and tries to auto-detect the application details from
|
/// Creates a new Platform and tries to auto-detect the application details from
|
||||||
/// the current context.
|
/// the current context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AppDescWindows()
|
public AppDescWindows() : this(SquirrelRuntimeInfo.EntryExePath)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new windows application platform at the specified app directory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appDir">The location of the application.</param>
|
||||||
|
/// <param name="appId">The unique ID of the application.</param>
|
||||||
|
public AppDescWindows(string appDir, string appId)
|
||||||
{
|
{
|
||||||
if (!SquirrelRuntimeInfo.IsWindows)
|
if (!SquirrelRuntimeInfo.IsWindows)
|
||||||
throw new NotSupportedException("Cannot instantiate AppDescWindows on a non-Windows system.");
|
throw new NotSupportedException("Cannot instantiate AppDescWindows on a non-Windows system.");
|
||||||
|
|
||||||
|
AppId = appId;
|
||||||
|
RootAppDir = appDir;
|
||||||
|
var updateExe = Path.Combine(appDir, "Update.exe");
|
||||||
|
var ver = GetLatestVersion();
|
||||||
|
|
||||||
var ourPath = SquirrelRuntimeInfo.EntryExePath;
|
if (File.Exists(updateExe) && ver != null) {
|
||||||
|
UpdateExePath = updateExe;
|
||||||
|
CurrentlyInstalledVersion = ver.Version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal AppDescWindows(string ourPath)
|
||||||
|
{
|
||||||
|
if (!SquirrelRuntimeInfo.IsWindows)
|
||||||
|
throw new NotSupportedException("Cannot instantiate AppDescWindows on a non-Windows system.");
|
||||||
|
|
||||||
var myDir = Path.GetDirectoryName(ourPath);
|
var myDir = Path.GetDirectoryName(ourPath);
|
||||||
|
|
||||||
// Am I update.exe at the application root?
|
// Am I update.exe at the application root?
|
||||||
@@ -320,24 +344,6 @@ namespace Squirrel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new windows application platform at the specified app directory.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="appDir">The location of the application.</param>
|
|
||||||
/// <param name="appId">The unique ID of the application.</param>
|
|
||||||
public AppDescWindows(string appDir, string appId)
|
|
||||||
{
|
|
||||||
AppId = appId;
|
|
||||||
RootAppDir = appDir;
|
|
||||||
var updateExe = Path.Combine(appDir, "Update.exe");
|
|
||||||
var ver = GetLatestVersion();
|
|
||||||
|
|
||||||
if (File.Exists(updateExe) && ver != null) {
|
|
||||||
UpdateExePath = updateExe;
|
|
||||||
CurrentlyInstalledVersion = ver.Version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
152
src/Squirrel/Internal/DeltaPackage.cs
Normal file
152
src/Squirrel/Internal/DeltaPackage.cs
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Contracts;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Squirrel.Bsdiff;
|
||||||
|
using Squirrel.SimpleSplat;
|
||||||
|
|
||||||
|
namespace Squirrel
|
||||||
|
{
|
||||||
|
internal class DeltaPackage : IEnableLogger
|
||||||
|
{
|
||||||
|
private readonly string _baseTempDir;
|
||||||
|
|
||||||
|
public DeltaPackage(string baseTempDir = null)
|
||||||
|
{
|
||||||
|
_baseTempDir = baseTempDir ?? Utility.GetDefaultTempBaseDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ApplyDeltaPackage(string basePackageZip, string deltaPackageZip, string outputFile, Action<int> progress = null)
|
||||||
|
{
|
||||||
|
progress = progress ?? (x => { });
|
||||||
|
|
||||||
|
Contract.Requires(deltaPackageZip != null);
|
||||||
|
Contract.Requires(!String.IsNullOrEmpty(outputFile) && !File.Exists(outputFile));
|
||||||
|
|
||||||
|
using (Utility.GetTempDirectory(out var deltaPath, _baseTempDir))
|
||||||
|
using (Utility.GetTempDirectory(out var workingPath, _baseTempDir)) {
|
||||||
|
EasyZip.ExtractZipToDirectory(deltaPackageZip, deltaPath);
|
||||||
|
progress(25);
|
||||||
|
|
||||||
|
EasyZip.ExtractZipToDirectory(basePackageZip, workingPath);
|
||||||
|
progress(50);
|
||||||
|
|
||||||
|
var pathsVisited = new List<string>();
|
||||||
|
|
||||||
|
var deltaPathRelativePaths = new DirectoryInfo(deltaPath).GetAllFilesRecursively()
|
||||||
|
.Select(x => x.FullName.Replace(deltaPath + Path.DirectorySeparatorChar, ""))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
// Apply all of the .diff files
|
||||||
|
deltaPathRelativePaths
|
||||||
|
.Where(x => x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
.Where(x => !x.EndsWith(".shasum", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
.Where(x => !x.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
|
!deltaPathRelativePaths.Contains(x.Replace(".diff", ".bsdiff")))
|
||||||
|
.ForEach(file => {
|
||||||
|
pathsVisited.Add(Regex.Replace(file, @"\.(bs)?diff$", "").ToLowerInvariant());
|
||||||
|
applyDiffToFile(deltaPath, file, workingPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
progress(75);
|
||||||
|
|
||||||
|
// Delete all of the files that were in the old package but
|
||||||
|
// not in the new one.
|
||||||
|
new DirectoryInfo(workingPath).GetAllFilesRecursively()
|
||||||
|
.Select(x => x.FullName.Replace(workingPath + Path.DirectorySeparatorChar, "").ToLowerInvariant())
|
||||||
|
.Where(x => x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase) && !pathsVisited.Contains(x))
|
||||||
|
.ForEach(x => {
|
||||||
|
this.Log().Info("{0} was in old package but not in new one, deleting", x);
|
||||||
|
File.Delete(Path.Combine(workingPath, x));
|
||||||
|
});
|
||||||
|
|
||||||
|
progress(80);
|
||||||
|
|
||||||
|
// Update all the files that aren't in 'lib' with the delta
|
||||||
|
// package's versions (i.e. the nuspec file, etc etc).
|
||||||
|
deltaPathRelativePaths
|
||||||
|
.Where(x => !x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
.ForEach(x => {
|
||||||
|
this.Log().Info("Updating metadata file: {0}", x);
|
||||||
|
File.Copy(Path.Combine(deltaPath, x), Path.Combine(workingPath, x), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.Log().Info("Repacking into full package: {0}", outputFile);
|
||||||
|
|
||||||
|
EasyZip.CreateZipFromDirectory(outputFile, workingPath);
|
||||||
|
|
||||||
|
progress(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
void applyDiffToFile(string deltaPath, string relativeFilePath, string workingDirectory)
|
||||||
|
{
|
||||||
|
var inputFile = Path.Combine(deltaPath, relativeFilePath);
|
||||||
|
var finalTarget = Path.Combine(workingDirectory, Regex.Replace(relativeFilePath, @"\.(bs)?diff$", ""));
|
||||||
|
|
||||||
|
using var _d = Utility.GetTempFileName(out var tempTargetFile, _baseTempDir);
|
||||||
|
|
||||||
|
// NB: Zero-length diffs indicate the file hasn't actually changed
|
||||||
|
if (new FileInfo(inputFile).Length == 0) {
|
||||||
|
this.Log().Info("{0} exists unchanged, skipping", relativeFilePath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relativeFilePath.EndsWith(".bsdiff", StringComparison.InvariantCultureIgnoreCase)) {
|
||||||
|
using (var of = File.OpenWrite(tempTargetFile))
|
||||||
|
using (var inf = File.OpenRead(finalTarget)) {
|
||||||
|
this.Log().Info("Applying bsdiff to {0}", relativeFilePath);
|
||||||
|
BinaryPatchUtility.Apply(inf, () => File.OpenRead(inputFile), of);
|
||||||
|
}
|
||||||
|
|
||||||
|
verifyPatchedFile(relativeFilePath, inputFile, tempTargetFile);
|
||||||
|
} else if (relativeFilePath.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase)) {
|
||||||
|
this.Log().Info("Applying msdiff to {0}", relativeFilePath);
|
||||||
|
|
||||||
|
if (SquirrelRuntimeInfo.IsWindows) {
|
||||||
|
MsDeltaCompression.ApplyDelta(inputFile, finalTarget, tempTargetFile);
|
||||||
|
} else {
|
||||||
|
throw new InvalidOperationException("msdiff is not supported on non-windows platforms.");
|
||||||
|
}
|
||||||
|
verifyPatchedFile(relativeFilePath, inputFile, tempTargetFile);
|
||||||
|
} else {
|
||||||
|
using (var of = File.OpenWrite(tempTargetFile))
|
||||||
|
using (var inf = File.OpenRead(inputFile)) {
|
||||||
|
this.Log().Info("Adding new file: {0}", relativeFilePath);
|
||||||
|
inf.CopyTo(of);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(finalTarget)) File.Delete(finalTarget);
|
||||||
|
|
||||||
|
var targetPath = Directory.GetParent(finalTarget);
|
||||||
|
if (!targetPath.Exists) targetPath.Create();
|
||||||
|
|
||||||
|
File.Move(tempTargetFile, finalTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void verifyPatchedFile(string relativeFilePath, string inputFile, string tempTargetFile)
|
||||||
|
{
|
||||||
|
var shaFile = Regex.Replace(inputFile, @"\.(bs)?diff$", ".shasum");
|
||||||
|
var expectedReleaseEntry = ReleaseEntry.ParseReleaseEntry(File.ReadAllText(shaFile, Encoding.UTF8));
|
||||||
|
var actualReleaseEntry = ReleaseEntry.GenerateFromFile(tempTargetFile);
|
||||||
|
|
||||||
|
if (expectedReleaseEntry.Filesize != actualReleaseEntry.Filesize) {
|
||||||
|
this.Log().Warn("Patched file {0} has incorrect size, expected {1}, got {2}", relativeFilePath,
|
||||||
|
expectedReleaseEntry.Filesize, actualReleaseEntry.Filesize);
|
||||||
|
throw new ChecksumFailedException() { Filename = relativeFilePath };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expectedReleaseEntry.SHA1 != actualReleaseEntry.SHA1) {
|
||||||
|
this.Log().Warn("Patched file {0} has incorrect SHA1, expected {1}, got {2}", relativeFilePath,
|
||||||
|
expectedReleaseEntry.SHA1, actualReleaseEntry.SHA1);
|
||||||
|
throw new ChecksumFailedException() { Filename = relativeFilePath };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -277,8 +277,8 @@ namespace Squirrel
|
|||||||
|
|
||||||
private static string GetNextTempName(string tempDir)
|
private static string GetNextTempName(string tempDir)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < 100; i++) {
|
for (int i = 1; i < 10000; i++) {
|
||||||
string name = "temp" + i;
|
string name = "temp." + i;
|
||||||
var target = Path.Combine(tempDir, name);
|
var target = Path.Combine(tempDir, name);
|
||||||
|
|
||||||
FileSystemInfo info = null;
|
FileSystemInfo info = null;
|
||||||
@@ -301,7 +301,7 @@ namespace Squirrel
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"Unable to find free temp path. Has the temp directory exceeded it's maximum number of items?");
|
"Unable to find free temp path. Has the temp directory exceeded it's maximum number of items? (10000)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDisposable GetTempDirectory(out string newTempDirectory)
|
public static IDisposable GetTempDirectory(out string newTempDirectory)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Squirrel.NuGet
|
|||||||
throw new ArgumentException($"Invalid package Id '{id}', it must contain only alphanumeric characters, underscores, dashes, and dots.");
|
throw new ArgumentException($"Invalid package Id '{id}', it must contain only alphanumeric characters, underscores, dashes, and dots.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ThrowIfVersionNotSemverCompliant(string version, bool allowTags)
|
public static void ThrowIfVersionNotSemverCompliant(string version, bool allowTags = true)
|
||||||
{
|
{
|
||||||
if (SemanticVersion.TryParse(version, out var parsed)) {
|
if (SemanticVersion.TryParse(version, out var parsed)) {
|
||||||
if (parsed < new SemanticVersion(0, 0, 1)) {
|
if (parsed < new SemanticVersion(0, 0, 1)) {
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ using System.Diagnostics;
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Squirrel.SimpleSplat;
|
using Squirrel.SimpleSplat;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Squirrel.Bsdiff;
|
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using Squirrel.NuGet;
|
using Squirrel.NuGet;
|
||||||
|
|
||||||
@@ -193,7 +191,7 @@ namespace Squirrel
|
|||||||
var basePkg = Path.Combine(_config.PackagesDir, currentVersion.Filename);
|
var basePkg = Path.Combine(_config.PackagesDir, currentVersion.Filename);
|
||||||
var deltaPkg = Path.Combine(_config.PackagesDir, releasesToApply.First().Filename);
|
var deltaPkg = Path.Combine(_config.PackagesDir, releasesToApply.First().Filename);
|
||||||
|
|
||||||
return ApplyDeltaPackage(basePkg, deltaPkg,
|
return new DeltaPackage(_config.AppTempDir).ApplyDeltaPackage(basePkg, deltaPkg,
|
||||||
Regex.Replace(deltaPkg, @"-delta.nupkg$", ".nupkg", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant),
|
Regex.Replace(deltaPkg, @"-delta.nupkg$", ".nupkg", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant),
|
||||||
x => progress.ReportReleaseProgress(x));
|
x => progress.ReportReleaseProgress(x));
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
@@ -367,135 +365,5 @@ namespace Squirrel
|
|||||||
{
|
{
|
||||||
return File.Exists(Path.Combine(appFolderPath, ".dead"));
|
return File.Exists(Path.Combine(appFolderPath, ".dead"));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string ApplyDeltaPackage(string basePackageZip, string deltaPackageZip, string outputFile, Action<int> progress = null)
|
|
||||||
{
|
|
||||||
progress = progress ?? (x => { });
|
|
||||||
|
|
||||||
Contract.Requires(deltaPackageZip != null);
|
|
||||||
Contract.Requires(!String.IsNullOrEmpty(outputFile) && !File.Exists(outputFile));
|
|
||||||
|
|
||||||
using (Utility.GetTempDirectory(out var deltaPath, _config.AppTempDir))
|
|
||||||
using (Utility.GetTempDirectory(out var workingPath, _config.AppTempDir)) {
|
|
||||||
EasyZip.ExtractZipToDirectory(deltaPackageZip, deltaPath);
|
|
||||||
progress(25);
|
|
||||||
|
|
||||||
EasyZip.ExtractZipToDirectory(basePackageZip, workingPath);
|
|
||||||
progress(50);
|
|
||||||
|
|
||||||
var pathsVisited = new List<string>();
|
|
||||||
|
|
||||||
var deltaPathRelativePaths = new DirectoryInfo(deltaPath).GetAllFilesRecursively()
|
|
||||||
.Select(x => x.FullName.Replace(deltaPath + Path.DirectorySeparatorChar, ""))
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
// Apply all of the .diff files
|
|
||||||
deltaPathRelativePaths
|
|
||||||
.Where(x => x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
.Where(x => !x.EndsWith(".shasum", StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
.Where(x => !x.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase) ||
|
|
||||||
!deltaPathRelativePaths.Contains(x.Replace(".diff", ".bsdiff")))
|
|
||||||
.ForEach(file => {
|
|
||||||
pathsVisited.Add(Regex.Replace(file, @"\.(bs)?diff$", "").ToLowerInvariant());
|
|
||||||
applyDiffToFile(deltaPath, file, workingPath);
|
|
||||||
});
|
|
||||||
|
|
||||||
progress(75);
|
|
||||||
|
|
||||||
// Delete all of the files that were in the old package but
|
|
||||||
// not in the new one.
|
|
||||||
new DirectoryInfo(workingPath).GetAllFilesRecursively()
|
|
||||||
.Select(x => x.FullName.Replace(workingPath + Path.DirectorySeparatorChar, "").ToLowerInvariant())
|
|
||||||
.Where(x => x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase) && !pathsVisited.Contains(x))
|
|
||||||
.ForEach(x => {
|
|
||||||
this.Log().Info("{0} was in old package but not in new one, deleting", x);
|
|
||||||
File.Delete(Path.Combine(workingPath, x));
|
|
||||||
});
|
|
||||||
|
|
||||||
progress(80);
|
|
||||||
|
|
||||||
// Update all the files that aren't in 'lib' with the delta
|
|
||||||
// package's versions (i.e. the nuspec file, etc etc).
|
|
||||||
deltaPathRelativePaths
|
|
||||||
.Where(x => !x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
.ForEach(x => {
|
|
||||||
this.Log().Info("Updating metadata file: {0}", x);
|
|
||||||
File.Copy(Path.Combine(deltaPath, x), Path.Combine(workingPath, x), true);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.Log().Info("Repacking into full package: {0}", outputFile);
|
|
||||||
|
|
||||||
EasyZip.CreateZipFromDirectory(outputFile, workingPath);
|
|
||||||
|
|
||||||
progress(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return outputFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyDiffToFile(string deltaPath, string relativeFilePath, string workingDirectory)
|
|
||||||
{
|
|
||||||
var inputFile = Path.Combine(deltaPath, relativeFilePath);
|
|
||||||
var finalTarget = Path.Combine(workingDirectory, Regex.Replace(relativeFilePath, @"\.(bs)?diff$", ""));
|
|
||||||
|
|
||||||
using var _d = Utility.GetTempFileName(out var tempTargetFile, _config.AppTempDir);
|
|
||||||
|
|
||||||
// NB: Zero-length diffs indicate the file hasn't actually changed
|
|
||||||
if (new FileInfo(inputFile).Length == 0) {
|
|
||||||
this.Log().Info("{0} exists unchanged, skipping", relativeFilePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relativeFilePath.EndsWith(".bsdiff", StringComparison.InvariantCultureIgnoreCase)) {
|
|
||||||
using (var of = File.OpenWrite(tempTargetFile))
|
|
||||||
using (var inf = File.OpenRead(finalTarget)) {
|
|
||||||
this.Log().Info("Applying bsdiff to {0}", relativeFilePath);
|
|
||||||
BinaryPatchUtility.Apply(inf, () => File.OpenRead(inputFile), of);
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyPatchedFile(relativeFilePath, inputFile, tempTargetFile);
|
|
||||||
} else if (relativeFilePath.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase)) {
|
|
||||||
this.Log().Info("Applying msdiff to {0}", relativeFilePath);
|
|
||||||
|
|
||||||
if (SquirrelRuntimeInfo.IsWindows) {
|
|
||||||
MsDeltaCompression.ApplyDelta(inputFile, finalTarget, tempTargetFile);
|
|
||||||
} else {
|
|
||||||
throw new InvalidOperationException("msdiff is not supported on non-windows platforms.");
|
|
||||||
}
|
|
||||||
verifyPatchedFile(relativeFilePath, inputFile, tempTargetFile);
|
|
||||||
} else {
|
|
||||||
using (var of = File.OpenWrite(tempTargetFile))
|
|
||||||
using (var inf = File.OpenRead(inputFile)) {
|
|
||||||
this.Log().Info("Adding new file: {0}", relativeFilePath);
|
|
||||||
inf.CopyTo(of);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (File.Exists(finalTarget)) File.Delete(finalTarget);
|
|
||||||
|
|
||||||
var targetPath = Directory.GetParent(finalTarget);
|
|
||||||
if (!targetPath.Exists) targetPath.Create();
|
|
||||||
|
|
||||||
File.Move(tempTargetFile, finalTarget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void verifyPatchedFile(string relativeFilePath, string inputFile, string tempTargetFile)
|
|
||||||
{
|
|
||||||
var shaFile = Regex.Replace(inputFile, @"\.(bs)?diff$", ".shasum");
|
|
||||||
var expectedReleaseEntry = ReleaseEntry.ParseReleaseEntry(File.ReadAllText(shaFile, Encoding.UTF8));
|
|
||||||
var actualReleaseEntry = ReleaseEntry.GenerateFromFile(tempTargetFile);
|
|
||||||
|
|
||||||
if (expectedReleaseEntry.Filesize != actualReleaseEntry.Filesize) {
|
|
||||||
this.Log().Warn("Patched file {0} has incorrect size, expected {1}, got {2}", relativeFilePath,
|
|
||||||
expectedReleaseEntry.Filesize, actualReleaseEntry.Filesize);
|
|
||||||
throw new ChecksumFailedException() { Filename = relativeFilePath };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (expectedReleaseEntry.SHA1 != actualReleaseEntry.SHA1) {
|
|
||||||
this.Log().Warn("Patched file {0} has incorrect SHA1, expected {1}, got {2}", relativeFilePath,
|
|
||||||
expectedReleaseEntry.SHA1, actualReleaseEntry.SHA1);
|
|
||||||
throw new ChecksumFailedException() { Filename = relativeFilePath };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,9 @@ namespace Squirrel.Tests
|
|||||||
//Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "app-0.1.0")));
|
//Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "app-0.1.0")));
|
||||||
Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "current")));
|
Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "current")));
|
||||||
|
|
||||||
var version = Utility.GetAppVersionDirectories(Path.Combine(tempDir, pkgName)).Single();
|
var info = new AppDescWindows(Path.Combine(tempDir, pkgName), pkgName);
|
||||||
|
|
||||||
|
var version = info.GetVersions().Single();
|
||||||
Assert.True(version.IsCurrent);
|
Assert.True(version.IsCurrent);
|
||||||
Assert.Equal(new SemanticVersion(0, 1, 0), version.Manifest.Version);
|
Assert.Equal(new SemanticVersion(0, 1, 0), version.Manifest.Version);
|
||||||
|
|
||||||
@@ -216,9 +218,9 @@ namespace Squirrel.Tests
|
|||||||
await fixture.UpdateApp();
|
await fixture.UpdateApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utility.UpdateAndRetrieveCurrentFolder(Path.Combine(tempDir, pkgName), false);
|
info.UpdateAndRetrieveCurrentFolder(false);
|
||||||
|
|
||||||
var versions = Utility.GetAppVersionDirectories(Path.Combine(tempDir, pkgName)).ToArray();
|
var versions = info.GetVersions().ToArray();
|
||||||
Assert.Equal(2, versions.Count());
|
Assert.Equal(2, versions.Count());
|
||||||
Assert.Equal(new SemanticVersion(0, 2, 0), versions.Single(s => s.IsCurrent).Version);
|
Assert.Equal(new SemanticVersion(0, 2, 0), versions.Single(s => s.IsCurrent).Version);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Squirrel.Tests.TestHelpers;
|
|||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
|
using Squirrel.CommandLine;
|
||||||
|
|
||||||
namespace Squirrel.Tests
|
namespace Squirrel.Tests
|
||||||
{
|
{
|
||||||
@@ -21,13 +22,13 @@ namespace Squirrel.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void ApplyDeltaPackageSmokeTest()
|
public void ApplyDeltaPackageSmokeTest()
|
||||||
{
|
{
|
||||||
var basePackage = new ReleasePackage(IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.0.0.0-full.nupkg"));
|
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.0.0.0-full.nupkg");
|
||||||
var deltaPackage = new ReleasePackage(IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0-delta.nupkg"));
|
var deltaPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0-delta.nupkg");
|
||||||
var expectedPackageFile = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0-full.nupkg");
|
var expectedPackageFile = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0-full.nupkg");
|
||||||
var outFile = Path.GetTempFileName() + ".nupkg";
|
var outFile = Path.GetTempFileName() + ".nupkg";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var deltaBuilder = new DeltaPackageBuilder();
|
var deltaBuilder = new DeltaPackage();
|
||||||
deltaBuilder.ApplyDeltaPackage(basePackage, deltaPackage, outFile);
|
deltaBuilder.ApplyDeltaPackage(basePackage, deltaPackage, outFile);
|
||||||
|
|
||||||
var result = new ZipPackage(outFile);
|
var result = new ZipPackage(outFile);
|
||||||
@@ -57,12 +58,12 @@ namespace Squirrel.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void ApplyDeltaWithBothBsdiffAndNormalDiffDoesntFail()
|
public void ApplyDeltaWithBothBsdiffAndNormalDiffDoesntFail()
|
||||||
{
|
{
|
||||||
var basePackage = new ReleasePackage(IntegrationTestHelper.GetPath("fixtures", "slack-1.1.8-full.nupkg"));
|
var basePackage = IntegrationTestHelper.GetPath("fixtures", "slack-1.1.8-full.nupkg");
|
||||||
var deltaPackage = new ReleasePackage(IntegrationTestHelper.GetPath("fixtures", "slack-1.2.0-delta.nupkg"));
|
var deltaPackage = IntegrationTestHelper.GetPath("fixtures", "slack-1.2.0-delta.nupkg");
|
||||||
var outFile = Path.GetTempFileName() + ".nupkg";
|
var outFile = Path.GetTempFileName() + ".nupkg";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var deltaBuilder = new DeltaPackageBuilder();
|
var deltaBuilder = new DeltaPackage();
|
||||||
deltaBuilder.ApplyDeltaPackage(basePackage, deltaPackage, outFile);
|
deltaBuilder.ApplyDeltaPackage(basePackage, deltaPackage, outFile);
|
||||||
|
|
||||||
var result = new ZipPackage(outFile);
|
var result = new ZipPackage(outFile);
|
||||||
@@ -91,8 +92,8 @@ namespace Squirrel.Tests
|
|||||||
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
||||||
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
||||||
|
|
||||||
var baseFixture = new ReleasePackage(basePackage);
|
var baseFixture = new ReleasePackageBuilder(basePackage);
|
||||||
var fixture = new ReleasePackage(newPackage);
|
var fixture = new ReleasePackageBuilder(newPackage);
|
||||||
|
|
||||||
var tempFiles = Enumerable.Range(0, 3)
|
var tempFiles = Enumerable.Range(0, 3)
|
||||||
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
||||||
@@ -173,8 +174,8 @@ namespace Squirrel.Tests
|
|||||||
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
||||||
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
||||||
|
|
||||||
var baseFixture = new ReleasePackage(basePackage);
|
var baseFixture = new ReleasePackageBuilder(basePackage);
|
||||||
var fixture = new ReleasePackage(newPackage);
|
var fixture = new ReleasePackageBuilder(newPackage);
|
||||||
|
|
||||||
var tempFiles = Enumerable.Range(0, 3)
|
var tempFiles = Enumerable.Range(0, 3)
|
||||||
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
||||||
@@ -205,8 +206,8 @@ namespace Squirrel.Tests
|
|||||||
var sourceDir = IntegrationTestHelper.GetPath("fixtures", "packages");
|
var sourceDir = IntegrationTestHelper.GetPath("fixtures", "packages");
|
||||||
(new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();
|
(new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();
|
||||||
|
|
||||||
var baseFixture = new ReleasePackage(basePackage);
|
var baseFixture = new ReleasePackageBuilder(basePackage);
|
||||||
var fixture = new ReleasePackage(newPackage);
|
var fixture = new ReleasePackageBuilder(newPackage);
|
||||||
|
|
||||||
var tempFile = Path.GetTempPath() + Guid.NewGuid() + ".nupkg";
|
var tempFile = Path.GetTempPath() + Guid.NewGuid() + ".nupkg";
|
||||||
|
|
||||||
@@ -226,8 +227,8 @@ namespace Squirrel.Tests
|
|||||||
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
||||||
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
||||||
|
|
||||||
var baseFixture = new ReleasePackage(basePackage);
|
var baseFixture = new ReleasePackageBuilder(basePackage);
|
||||||
var fixture = new ReleasePackage(newPackage);
|
var fixture = new ReleasePackageBuilder(newPackage);
|
||||||
|
|
||||||
var tempFiles = Enumerable.Range(0, 3)
|
var tempFiles = Enumerable.Range(0, 3)
|
||||||
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
||||||
@@ -258,8 +259,8 @@ namespace Squirrel.Tests
|
|||||||
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
||||||
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");
|
||||||
|
|
||||||
var baseFixture = new ReleasePackage(basePackage);
|
var baseFixture = new ReleasePackageBuilder(basePackage);
|
||||||
var fixture = new ReleasePackage(newPackage);
|
var fixture = new ReleasePackageBuilder(newPackage);
|
||||||
|
|
||||||
var tempFiles = Enumerable.Range(0, 3)
|
var tempFiles = Enumerable.Range(0, 3)
|
||||||
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
.Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Squirrel.Tests.TestHelpers;
|
|||||||
using Xunit;
|
using Xunit;
|
||||||
using Squirrel.NuGet;
|
using Squirrel.NuGet;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
|
using Squirrel.CommandLine;
|
||||||
|
|
||||||
namespace Squirrel.Tests
|
namespace Squirrel.Tests
|
||||||
{
|
{
|
||||||
@@ -173,26 +174,26 @@ namespace Squirrel.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void GetLatestReleaseWithNullCollectionReturnsNull()
|
public void GetLatestReleaseWithNullCollectionReturnsNull()
|
||||||
{
|
{
|
||||||
Assert.Null(ReleaseEntry.GetPreviousRelease(
|
Assert.Null(ReleasePackageBuilder.GetPreviousRelease(
|
||||||
null, null, null));
|
null, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetLatestReleaseWithEmptyCollectionReturnsNull()
|
public void GetLatestReleaseWithEmptyCollectionReturnsNull()
|
||||||
{
|
{
|
||||||
Assert.Null(ReleaseEntry.GetPreviousRelease(
|
Assert.Null(ReleasePackageBuilder.GetPreviousRelease(
|
||||||
Enumerable.Empty<ReleaseEntry>(), null, null));
|
Enumerable.Empty<ReleaseEntry>(), null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void WhenCurrentReleaseMatchesLastReleaseReturnNull()
|
public void WhenCurrentReleaseMatchesLastReleaseReturnNull()
|
||||||
{
|
{
|
||||||
var package = new ReleasePackage("Espera-1.7.6-beta.nupkg");
|
var package = new ReleasePackageBuilder("Espera-1.7.6-beta.nupkg");
|
||||||
|
|
||||||
var releaseEntries = new[] {
|
var releaseEntries = new[] {
|
||||||
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg"))
|
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg"))
|
||||||
};
|
};
|
||||||
Assert.Null(ReleaseEntry.GetPreviousRelease(
|
Assert.Null(ReleasePackageBuilder.GetPreviousRelease(
|
||||||
releaseEntries, package, @"C:\temp\somefolder"));
|
releaseEntries, package, @"C:\temp\somefolder"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,14 +201,14 @@ namespace Squirrel.Tests
|
|||||||
public void WhenMultipleReleaseMatchesReturnEarlierResult()
|
public void WhenMultipleReleaseMatchesReturnEarlierResult()
|
||||||
{
|
{
|
||||||
var expected = SemanticVersion.Parse("1.7.5-beta");
|
var expected = SemanticVersion.Parse("1.7.5-beta");
|
||||||
var package = new ReleasePackage("Espera-1.7.6-beta.nupkg");
|
var package = new ReleasePackageBuilder("Espera-1.7.6-beta.nupkg");
|
||||||
|
|
||||||
var releaseEntries = new[] {
|
var releaseEntries = new[] {
|
||||||
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg")),
|
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg")),
|
||||||
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg"))
|
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg"))
|
||||||
};
|
};
|
||||||
|
|
||||||
var actual = ReleaseEntry.GetPreviousRelease(
|
var actual = ReleasePackageBuilder.GetPreviousRelease(
|
||||||
releaseEntries,
|
releaseEntries,
|
||||||
package,
|
package,
|
||||||
@"C:\temp\");
|
@"C:\temp\");
|
||||||
@@ -219,14 +220,14 @@ namespace Squirrel.Tests
|
|||||||
public void WhenMultipleReleasesFoundReturnPreviousVersion()
|
public void WhenMultipleReleasesFoundReturnPreviousVersion()
|
||||||
{
|
{
|
||||||
var expected = SemanticVersion.Parse("1.7.6-beta");
|
var expected = SemanticVersion.Parse("1.7.6-beta");
|
||||||
var input = new ReleasePackage("Espera-1.7.7-beta.nupkg");
|
var input = new ReleasePackageBuilder("Espera-1.7.7-beta.nupkg");
|
||||||
|
|
||||||
var releaseEntries = new[] {
|
var releaseEntries = new[] {
|
||||||
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg")),
|
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg")),
|
||||||
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg"))
|
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg"))
|
||||||
};
|
};
|
||||||
|
|
||||||
var actual = ReleaseEntry.GetPreviousRelease(
|
var actual = ReleasePackageBuilder.GetPreviousRelease(
|
||||||
releaseEntries,
|
releaseEntries,
|
||||||
input,
|
input,
|
||||||
@"C:\temp\");
|
@"C:\temp\");
|
||||||
@@ -238,14 +239,14 @@ namespace Squirrel.Tests
|
|||||||
public void WhenMultipleReleasesFoundInOtherOrderReturnPreviousVersion()
|
public void WhenMultipleReleasesFoundInOtherOrderReturnPreviousVersion()
|
||||||
{
|
{
|
||||||
var expected = SemanticVersion.Parse("1.7.6-beta");
|
var expected = SemanticVersion.Parse("1.7.6-beta");
|
||||||
var input = new ReleasePackage("Espera-1.7.7-beta.nupkg");
|
var input = new ReleasePackageBuilder("Espera-1.7.7-beta.nupkg");
|
||||||
|
|
||||||
var releaseEntries = new[] {
|
var releaseEntries = new[] {
|
||||||
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg")),
|
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg")),
|
||||||
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg"))
|
ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg"))
|
||||||
};
|
};
|
||||||
|
|
||||||
var actual = ReleaseEntry.GetPreviousRelease(
|
var actual = ReleasePackageBuilder.GetPreviousRelease(
|
||||||
releaseEntries,
|
releaseEntries,
|
||||||
input,
|
input,
|
||||||
@"C:\temp\");
|
@"C:\temp\");
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Xunit;
|
|||||||
using Squirrel.NuGet;
|
using Squirrel.NuGet;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
|
using Squirrel.CommandLine;
|
||||||
|
|
||||||
namespace Squirrel.Tests
|
namespace Squirrel.Tests
|
||||||
{
|
{
|
||||||
@@ -55,7 +56,7 @@ namespace Squirrel.Tests
|
|||||||
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
|
||||||
var outputPackage = Path.GetTempFileName() + ".nupkg";
|
var outputPackage = Path.GetTempFileName() + ".nupkg";
|
||||||
|
|
||||||
var fixture = new ReleasePackage(inputPackage);
|
var fixture = new ReleasePackageBuilder(inputPackage);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fixture.CreateReleasePackage(outputPackage);
|
fixture.CreateReleasePackage(outputPackage);
|
||||||
@@ -88,7 +89,7 @@ namespace Squirrel.Tests
|
|||||||
{
|
{
|
||||||
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.NoDependencies.1.0.0.0.nupkg");
|
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.NoDependencies.1.0.0.0.nupkg");
|
||||||
var outputPackage = Path.GetTempFileName() + ".nupkg";
|
var outputPackage = Path.GetTempFileName() + ".nupkg";
|
||||||
var fixture = new ReleasePackage(inputPackage);
|
var fixture = new ReleasePackageBuilder(inputPackage);
|
||||||
try {
|
try {
|
||||||
fixture.CreateReleasePackage(outputPackage);
|
fixture.CreateReleasePackage(outputPackage);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -101,7 +102,7 @@ namespace Squirrel.Tests
|
|||||||
{
|
{
|
||||||
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "ProjectDependsOnJsonDotNet.1.0.nupkg");
|
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "ProjectDependsOnJsonDotNet.1.0.nupkg");
|
||||||
var outputPackage = Path.GetTempFileName() + ".nupkg";
|
var outputPackage = Path.GetTempFileName() + ".nupkg";
|
||||||
var fixture = new ReleasePackage(inputPackage);
|
var fixture = new ReleasePackageBuilder(inputPackage);
|
||||||
try {
|
try {
|
||||||
Assert.Throws<InvalidOperationException>(() => fixture.CreateReleasePackage(outputPackage));
|
Assert.Throws<InvalidOperationException>(() => fixture.CreateReleasePackage(outputPackage));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -115,7 +116,7 @@ namespace Squirrel.Tests
|
|||||||
{
|
{
|
||||||
var dontcare = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0.nupkg");
|
var dontcare = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0.nupkg");
|
||||||
var inputSpec = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0.nuspec");
|
var inputSpec = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0.nuspec");
|
||||||
var fixture = new ReleasePackage(dontcare);
|
var fixture = new ReleasePackageBuilder(dontcare);
|
||||||
|
|
||||||
var targetFile = Path.GetTempFileName();
|
var targetFile = Path.GetTempFileName();
|
||||||
File.Copy(inputSpec, targetFile, true);
|
File.Copy(inputSpec, targetFile, true);
|
||||||
@@ -148,7 +149,7 @@ namespace Squirrel.Tests
|
|||||||
{
|
{
|
||||||
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "ProjectWithContent.1.0.0.0-beta.nupkg");
|
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "ProjectWithContent.1.0.0.0-beta.nupkg");
|
||||||
var outputPackage = Path.GetTempFileName() + ".zip";
|
var outputPackage = Path.GetTempFileName() + ".zip";
|
||||||
var fixture = new ReleasePackage(inputPackage);
|
var fixture = new ReleasePackageBuilder(inputPackage);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fixture.CreateReleasePackage(outputPackage);
|
fixture.CreateReleasePackage(outputPackage);
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ namespace Squirrel.Tests
|
|||||||
"Squirrel.Core.1.1.0.0-full.nupkg",
|
"Squirrel.Core.1.1.0.0-full.nupkg",
|
||||||
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, "theApp", "packages", x)));
|
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, "theApp", "packages", x)));
|
||||||
|
|
||||||
ReleaseEntry.BuildReleasesFile(Utility.PackageDirectoryForAppDir(appDir));
|
var info = new AppDescWindows(appDir, "theApp");
|
||||||
|
ReleaseEntry.BuildReleasesFile(info.PackagesDir);
|
||||||
|
|
||||||
var releasePath = Path.Combine(packageDir.FullName, "RELEASES");
|
var releasePath = Path.Combine(packageDir.FullName, "RELEASES");
|
||||||
File.Exists(releasePath).ShouldBeTrue();
|
File.Exists(releasePath).ShouldBeTrue();
|
||||||
@@ -162,7 +163,8 @@ namespace Squirrel.Tests
|
|||||||
});
|
});
|
||||||
|
|
||||||
// sync both release files
|
// sync both release files
|
||||||
ReleaseEntry.BuildReleasesFile(Utility.PackageDirectoryForAppDir(appDir));
|
var info = new AppDescWindows(appDir, "theApp");
|
||||||
|
ReleaseEntry.BuildReleasesFile(info.PackagesDir);
|
||||||
ReleaseEntry.BuildReleasesFile(remotePackages);
|
ReleaseEntry.BuildReleasesFile(remotePackages);
|
||||||
|
|
||||||
// check for an update
|
// check for an update
|
||||||
@@ -205,7 +207,8 @@ namespace Squirrel.Tests
|
|||||||
});
|
});
|
||||||
|
|
||||||
// sync both release files
|
// sync both release files
|
||||||
ReleaseEntry.BuildReleasesFile(Utility.PackageDirectoryForAppDir(appDir));
|
var info = new AppDescWindows(appDir, "theApp");
|
||||||
|
ReleaseEntry.BuildReleasesFile(info.PackagesDir);
|
||||||
ReleaseEntry.BuildReleasesFile(remotePackages);
|
ReleaseEntry.BuildReleasesFile(remotePackages);
|
||||||
|
|
||||||
UpdateInfo updateInfo;
|
UpdateInfo updateInfo;
|
||||||
@@ -244,7 +247,8 @@ namespace Squirrel.Tests
|
|||||||
});
|
});
|
||||||
|
|
||||||
// sync both release files
|
// sync both release files
|
||||||
ReleaseEntry.BuildReleasesFile(Utility.PackageDirectoryForAppDir(appDir));
|
var info = new AppDescWindows(appDir, "theApp");
|
||||||
|
ReleaseEntry.BuildReleasesFile(info.PackagesDir);
|
||||||
ReleaseEntry.BuildReleasesFile(remotePackages);
|
ReleaseEntry.BuildReleasesFile(remotePackages);
|
||||||
|
|
||||||
using (var mgr = new UpdateManager(remotePackages, "theApp", tempDir, new FakeDownloader())) {
|
using (var mgr = new UpdateManager(remotePackages, "theApp", tempDir, new FakeDownloader())) {
|
||||||
@@ -317,10 +321,11 @@ namespace Squirrel.Tests
|
|||||||
Directory.CreateDirectory(Path.Combine(tempDir, "theApp", "wrongDir"));
|
Directory.CreateDirectory(Path.Combine(tempDir, "theApp", "wrongDir"));
|
||||||
File.WriteAllText(Path.Combine(tempDir, "theApp", "Update.exe"), "1");
|
File.WriteAllText(Path.Combine(tempDir, "theApp", "Update.exe"), "1");
|
||||||
using (var fixture = new UpdateManager("http://lol", "theApp", tempDir)) {
|
using (var fixture = new UpdateManager("http://lol", "theApp", tempDir)) {
|
||||||
Assert.Null(fixture.CurrentlyInstalledVersion(Path.Combine(tempDir, "app.exe")));
|
Assert.Null(new AppDescWindows(Path.Combine(tempDir, "app.exe")).CurrentlyInstalledVersion);
|
||||||
Assert.Null(fixture.CurrentlyInstalledVersion(Path.Combine(tempDir, "theApp", "app.exe")));
|
Assert.Null(new AppDescWindows(Path.Combine(tempDir, "theApp", "app.exe")).CurrentlyInstalledVersion);
|
||||||
Assert.Null(fixture.CurrentlyInstalledVersion(Path.Combine(tempDir, "theApp", "wrongDir", "app.exe")));
|
Assert.Null(new AppDescWindows(Path.Combine(tempDir, "theApp", "wrongDir", "app.exe")).CurrentlyInstalledVersion);
|
||||||
Assert.Equal(new SemanticVersion(1, 0, 9), fixture.CurrentlyInstalledVersion(Path.Combine(tempDir, "theApp", "app-1.0.9", "app.exe")));
|
Assert.Equal(new SemanticVersion(1, 0, 9),
|
||||||
|
new AppDescWindows(Path.Combine(tempDir, "theApp", "app-1.0.9", "app.exe")).CurrentlyInstalledVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,4 +390,4 @@ namespace Squirrel.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,19 +65,6 @@ namespace Squirrel.Tests
|
|||||||
Console.WriteLine("Saved to " + path);
|
Console.WriteLine("Saved to " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData(10, 1)]
|
|
||||||
[InlineData(100, 1)]
|
|
||||||
[InlineData(0, 1)]
|
|
||||||
[InlineData(30000, 2)]
|
|
||||||
[InlineData(50000, 2)]
|
|
||||||
[InlineData(10000000, 3)]
|
|
||||||
public void TestTempNameGeneration(int index, int expectedLength)
|
|
||||||
{
|
|
||||||
string result = Utility.tempNameForIndex(index, "");
|
|
||||||
Assert.Equal(result.Length, expectedLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void RemoveByteOrderMarkerIfPresent()
|
public void RemoveByteOrderMarkerIfPresent()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user