Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mastersign committed Aug 13, 2019
2 parents bd7cdc5 + 3900026 commit 80dd2e1
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 42 deletions.
4 changes: 2 additions & 2 deletions BenchManager/BenchCLI/Commands/AppInstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ protected override void InitializeArgumentParser(ArgumentParser parser)
{
parser.Description
.Begin(BlockType.Paragraph)
.Text("The ").Keyword(Name).Text(" command installes the specified app, regardless of its activation state.")
.Text("The ").Keyword(Name).Text(" command installs the specified app, regardless of its activation state.")
.End(BlockType.Paragraph)
.Paragraph("Missing app resources are downloaded automatically.");
.Paragraph("Missing app resources are downloaded automatically. Deactivated dependencies are not installed.");

var positionalAppId = new PositionalArgument(POSITIONAL_APP_ID,
ArgumentValidation.IsIdString,
Expand Down
4 changes: 2 additions & 2 deletions BenchManager/BenchCLI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.22.2.0")]
[assembly: AssemblyFileVersion("0.22.2.0")]
[assembly: AssemblyVersion("0.22.3.0")]
[assembly: AssemblyFileVersion("0.22.3.0")]
4 changes: 2 additions & 2 deletions BenchManager/BenchDashboard/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.22.2.0")]
[assembly: AssemblyFileVersion("0.22.2.0")]
[assembly: AssemblyVersion("0.22.3.0")]
[assembly: AssemblyFileVersion("0.22.3.0")]
3 changes: 2 additions & 1 deletion BenchManager/BenchLib/BenchTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ public static ActionResult DoInstallApps(IBenchManager man,

/// <summary>
/// Runs the Bench task of installing a specific app, including all of its dependencies.
/// Only not deactivated dependencies are installed.
/// </summary>
/// <param name="man">The Bench manager.</param>
/// <param name="appId">The ID of the targeted app.</param>
Expand All @@ -825,7 +826,7 @@ public static ActionResult DoInstallApps(IBenchManager man,
var app = man.Config.Apps[appId];
if (app == null) throw new ArgumentException("App not found: " + appId, "appId");
var dependencies = Seq(man.Config.Apps.GetApps(app.FindAllDependencies()))
.Filter(a => a.IsActive)
.Filter(a => !a.IsDeactivated || a == app) // remove deactivated dependencies
.ToList();
return RunTasks(man,
dependencies,
Expand Down
1 change: 1 addition & 0 deletions BenchManager/BenchLib/DefaultBenchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ private bool RunAction(BenchTaskForOne action, string appId)
/// <summary>
/// Installs the specified app, in case it is not already installed.
/// This also downloads missing app resources.
/// Deactivated dependencies are not installed.
/// </summary>
/// <returns><c>true</c> if the execution of the task was successful; otherwise <c>false</c>.</returns>
public bool InstallApp(string appId) => RunAction(BenchTasks.DoInstallApps, appId);
Expand Down
46 changes: 43 additions & 3 deletions BenchManager/BenchLib/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using WshShell = IWshRuntimeLibrary.WshShell;
using WshShortcut = IWshRuntimeLibrary.WshShortcut;
using static Mastersign.Sequence.Sequence;
using System.Threading;

namespace Mastersign.Bench
{
Expand All @@ -16,6 +17,9 @@ public static class FileSystem
{
private static WshShell wshShell;

private const int UNAUTHORIZED_RETRY_LIMIT = 20;
private const int UNAUTHORIZED_RETRY_INTERVAL_MS = 100;

/// <summary>
/// Returns an instance of the COM object <c>WshShell</c>.
/// </summary>
Expand Down Expand Up @@ -115,14 +119,50 @@ private static void ForceDeleteDirectory(string targetDir)
ForceDeleteDirectory(dir);
}

Directory.Delete(targetDir, false);
// poll to work around short time locks from anti virus software
for (int i = 0; i < UNAUTHORIZED_RETRY_LIMIT; i++)
{
try
{
Directory.Delete(targetDir, true);
return;
}
catch (UnauthorizedAccessException)
{
if (i >= UNAUTHORIZED_RETRY_LIMIT - 1) throw;
Thread.Sleep(UNAUTHORIZED_RETRY_INTERVAL_MS);
}
catch (DirectoryNotFoundException)
{
// directory was already deleted
return;
}
}
}

private static void ForceDeleteFile(string targetFile)
{
targetFile = NormalizePath(targetFile);
File.SetAttributes(targetFile, FileAttributes.Normal);
File.Delete(targetFile);
// poll to work around short time locks from anti virus software
for (int i = 0; i < UNAUTHORIZED_RETRY_LIMIT; i++)
{
try
{
File.Delete(targetFile);
return;
}
catch (UnauthorizedAccessException)
{
if (i >= UNAUTHORIZED_RETRY_LIMIT - 1) throw;
Thread.Sleep(UNAUTHORIZED_RETRY_INTERVAL_MS);
}
catch (FileNotFoundException)
{
// file was already deleted
return;
}
}
}

/// <summary>
Expand Down Expand Up @@ -195,7 +235,7 @@ public static void CopyDir(string sourceDir, string targetDir, bool subDirs,
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
if (excludeFiles != null &&
if (excludeFiles != null &&
Seq(excludeFiles).Any(fileName => string.Equals(file.Name, fileName, StringComparison.OrdinalIgnoreCase)))
{
continue;
Expand Down
4 changes: 2 additions & 2 deletions BenchManager/BenchLib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.22.2.0")]
[assembly: AssemblyFileVersion("0.22.2.0")]
[assembly: AssemblyVersion("0.22.3.0")]
[assembly: AssemblyFileVersion("0.22.3.0")]
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ Add a link to the GitHub diff like

[Unreleased]: https://github.com/winbench/bench/compare/master...dev

## [0.22.3] - 2019-08-13

[0.22.3]: https://github.com/winbench/bench/compare/v0.22.2...v0.22.3

### Fixed
* Fixed installing single non activated app
([#141](https://github.com/winbench/bench/issues/141))
* Added polling in `Mastersign.Bench.PurgeDir()`
to wait max 2 seconds incase antivirus check locks files or folders

### Changed
* Removed notification messages of PowerShell remoting host

## [0.22.2] - 2019-04-02

[0.22.2]: https://github.com/winbench/bench/compare/v0.22.1...v0.22.2
Expand Down
30 changes: 20 additions & 10 deletions auto/lib/PsExecHost.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
param ($Token = "Bench.Default", $WaitMessage = ">>>>")
param (
[string]$Token = "Bench.Default",
[string]$WaitMessage = ">>>>",
[switch]$WithNotification
)

$scriptsDir = [IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Definition)
$rootDir = Resolve-Path "$scriptsDir\..\.."
Expand All @@ -9,12 +13,18 @@ $Script:BenchEnv = New-Object Mastersign.Bench.BenchEnvironment ($global:BenchCo

function _PrintWaitingMessage()
{
if ($WaitMessage)
if ($WaitMessage)
{
Write-Host $WaitMessage
}
}

function _PrintNotification($msg) {
if ($WithNotification) {
Write-Host $msg
}
}

function _ParseShellArguments([string]$argStr)
{
$sb = New-Object System.Text.StringBuilder
Expand Down Expand Up @@ -101,24 +111,24 @@ function _ExecutionHandler([string]$cwd, [string]$cmd, [string]$cmdArgs)

function _ReloadHandler()
{
Write-Host "Reloading Bench configuration..."
_PrintNotification "Reloading Bench configuration..."
$rootDir = $global:BenchConfig.BenchRootDir
$global:BenchConfig = New-Object Mastersign.Bench.BenchConfiguration ($rootDir)
$Script:BenchEnv = New-Object Mastersign.Bench.BenchEnvironment ($global:BenchConfig)
}

$server = New-Object Mastersign.Bench.RemoteExecHost.RemoteExecHostServer @($token)
Write-Host "PowerShell execution host started."
_PrintNotification "PowerShell execution host started."

while($server)
while($server)
{
_PrintWaitingMessage
$rcmd = [Mastersign.Bench.RemoteExecHost.RemoteExecutionFacade]::WaitForCommand()
switch ($rcmd.Type)
{
"Ping"
{
Write-Host "Remoting interface available."
_PrintNotification "Remoting interface available."
$rcmd.NotifyResult("OK")
}
"Execution"
Expand All @@ -129,15 +139,15 @@ while($server)
_ExecutionHandler $cwd $exe $exeArgs
$rcmd.NotifyResult($Script:executionResult)
}
"Reload"
{
_ReloadHandler
"Reload"
{
_ReloadHandler
}
"Shutdown"
{
$server.Dispose()
$server = $null
Write-Host "PowerShell execution host shut down."
_PrintNotification "PowerShell execution host shut down."
exit
}
}
Expand Down
7 changes: 6 additions & 1 deletion build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $mode = $Mode
$target = "Clean;Build"
$verbosity = $MsBuildVerbosity
# $msbuild = "$env:SystemRoot\Microsoft.NET\Framework\v$clrVersion\MSBuild.exe"
$msbuild = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
$msbuild = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe"
$nugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$nuget4Url = "https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe"
$solutionDir = "BenchManager" # relative to root dir
Expand Down Expand Up @@ -155,6 +155,11 @@ foreach ($artifact in $buildArtifacts)
Copy-Artifact "$rootDir\$solutionDir\$artifact" "$rootDir\$buildTargetDir"
}

if ($Mode -eq "Debug") {
cp "$rootDir\res\Invoke-AppSetupTest.ps1" "$rootDir\$buildTargetDir\tas.ps1"
cp "$rootDir\res\Invoke-AppVersionCheck.ps1" "$rootDir\$buildTargetDir\cav.ps1"
}

$today = [DateTime]::Now.ToString("yyyy-MM-dd")

if (!$NoRelease)
Expand Down
22 changes: 22 additions & 0 deletions res/Invoke-AppSetupTest.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
param ( $appId )

#
# Is supposed to be copied to <Bench Root>\auto\bin to work properly
#

if (!$appId.Contains(".")) { $appId = "Bench." + $appId }

$ErrorActionPreference = "Stop"

$thisDir = Split-Path $MyInvocation.MyCommand.Path -Parent

bench manage load-app-libs
if (!$?) { exit $LastExitCode }
bench --verbose app download $appId
if (!$?) { exit $LastExitCode }
bench --verbose app uninstall $appId
if (!$?) { exit $LastExitCode }
bench --verbose app install $appId
if (!$?) { exit $LastExitCode }

explorer "-e,`"$(bench app property $appId Dir)`""
Loading

0 comments on commit 80dd2e1

Please sign in to comment.