diff --git a/CHANGELOG.md b/CHANGELOG.md index 997af2e7..c410ce4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Fixed an is where -ReplaceToast on Show-UDToast would not replace a toast (https://github.com/ironmansoftware/universal-dashboard/issues/1449) by [adamdriscoll](https://github.com/adamdriscoll) +- Changed web.config to use PowerShell.exe rather than UD.Server.exe by [adamdriscoll](https://github.com/adamdriscoll) ### Changed (Enterprise) - Fixed issue where the login button wouldn't change font color by [adamdriscoll](https://github.com/adamdriscoll) +### Removed + +- Removed Publish-UDDashboard by [adamdriscoll](https://github.com/adamdriscoll) +- Removed UniversalDashboard.Server.exe by [adamdriscoll](https://github.com/adamdriscoll) + ## 2.8.3 - (1-31-2020) ### Added diff --git a/src/CorFlags.exe b/src/CorFlags.exe deleted file mode 100644 index c054e1a4..00000000 Binary files a/src/CorFlags.exe and /dev/null differ diff --git a/src/UniversalDashboard.Server/DashboardManager.cs b/src/UniversalDashboard.Server/DashboardManager.cs deleted file mode 100644 index 3eddd58f..00000000 --- a/src/UniversalDashboard.Server/DashboardManager.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.IO; -using System.Management.Automation; -using System.Reflection; -using System.Linq; -using System.Diagnostics; - -namespace UniversalDashboard -{ - class DashboardManager - { - private Server _server; - private readonly bool _dontSetExecutionPolicy; - - public DashboardManager(bool dontSetExecutionPolicy) - { - _dontSetExecutionPolicy = dontSetExecutionPolicy; - } - - public void Start() - { - var assemblyBasePath = Path.GetDirectoryName(typeof(Program).GetTypeInfo().Assembly.Location); - var dashboardScript = Path.Combine(assemblyBasePath, "..", "dashboard.ps1"); - - Log($"Starting Universal Dashboard service. {Environment.NewLine} Dashboard Script: {dashboardScript} {Environment.NewLine} Assembly Base Path: {dashboardScript}", false); - - try - { - using(var powerShell = PowerShell.Create()) - { - var modulePath = Path.Combine(assemblyBasePath, "..\\UniversalDashboard.Community.psd1"); - - if (!_dontSetExecutionPolicy) - { - powerShell.AddStatement().AddScript("Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process"); - } - - powerShell.AddStatement().AddScript($"Import-Module '{modulePath}'"); - powerShell.AddStatement().AddScript($". '{dashboardScript}'"); - - _server = powerShell.Invoke().FirstOrDefault()?.BaseObject as Server; - - if (powerShell.HadErrors) { - foreach(var error in powerShell.Streams.Error) { - Log($"Error starting dashboard: {Environment.NewLine} {error.ToString()} {Environment.NewLine} {error.ScriptStackTrace}", true); - } - } - } - } - catch (Exception ex) - { - Log($"Error starting dashboard: {Environment.NewLine} {ex.ToString()}", true); - } - - if (_server == null || !_server.Running) - { - throw new Exception("Failed to start dashboard"); - } - } - - public void Stop() { - _server.Stop(); - } - - private void CreateEventSource() { - #if NET472 - try - { - if (!EventLog.SourceExists("Universal Dashboard")) - { - EventLog.CreateEventSource("Universal Dashboard", "Application"); - } - } - catch (Exception ex) - { - Console.WriteLine("Failed to create event source: " + ex.Message); - } - #endif - } - - private void Log(string message, bool error) - { - #if NET472 - try - { - EventLog eventLog = new EventLog(); - eventLog.Source = "Universal Dashboard"; - eventLog.WriteEntry(message, error ? EventLogEntryType.Error : EventLogEntryType.Information); - } - catch - { - - } - #endif - Console.WriteLine(message); - } - } -} diff --git a/src/UniversalDashboard.Server/Program.cs b/src/UniversalDashboard.Server/Program.cs deleted file mode 100644 index ac677f25..00000000 --- a/src/UniversalDashboard.Server/Program.cs +++ /dev/null @@ -1,37 +0,0 @@ -using UniversalDashboard; -using UniversalDashboard.Services; -using System; -using System.IO; -using System.Management.Automation; -using System.Management.Automation.Runspaces; -using System.Reflection; -using System.Linq; -using UniversalDashboard.Models; -using DasMulli.Win32.ServiceUtils; -using System.Diagnostics; -using System.Threading; - -namespace UniversalDashboard -{ - class Program - { - private const string RunAsServiceFlag = "--run-as-service"; - private const string NoExecutionPolicy = "--dont-set-execution-policy"; - - static void Main(string[] args) - { - var dontSetExecutionPolicy = args.Contains(NoExecutionPolicy); - - if (args.Contains(RunAsServiceFlag)) - { - var service = new UniversalDashboardService(dontSetExecutionPolicy); - var serviceHost = new Win32ServiceHost(service); - serviceHost.Run(); - } - else { - var dashboardManager = new DashboardManager(dontSetExecutionPolicy); - dashboardManager.Start(); - } - } - } -} diff --git a/src/UniversalDashboard.Server/Properties/launchSettings.json b/src/UniversalDashboard.Server/Properties/launchSettings.json deleted file mode 100644 index 217bf118..00000000 --- a/src/UniversalDashboard.Server/Properties/launchSettings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "profiles": { - "UniversalDashboard": { - "commandName": "Project" - } - } -} \ No newline at end of file diff --git a/src/UniversalDashboard.Server/UniversalDashboard.Server.csproj b/src/UniversalDashboard.Server/UniversalDashboard.Server.csproj deleted file mode 100644 index 9dfb69a5..00000000 --- a/src/UniversalDashboard.Server/UniversalDashboard.Server.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - Exe - net472;netstandard2.0 - - - - - - - - - - - diff --git a/src/UniversalDashboard.Server/Win32Service.cs b/src/UniversalDashboard.Server/Win32Service.cs deleted file mode 100644 index 7a8b4ea2..00000000 --- a/src/UniversalDashboard.Server/Win32Service.cs +++ /dev/null @@ -1,28 +0,0 @@ -using DasMulli.Win32.ServiceUtils; - -namespace UniversalDashboard -{ - class UniversalDashboardService : IWin32Service - { - public string ServiceName => "Universal Dashboard"; - private DashboardManager _dashboardManager; - - private readonly bool _dontSetExecutionPolicy; - - public UniversalDashboardService(bool dontSetExecutionPolicy) - { - _dontSetExecutionPolicy = dontSetExecutionPolicy; - } - - public void Start(string[] startupArguments, ServiceStoppedCallback serviceStoppedCallback) - { - _dashboardManager = new DashboardManager(_dontSetExecutionPolicy); - _dashboardManager.Start(); - } - - public void Stop() - { - _dashboardManager.Stop(); - } - } -} \ No newline at end of file diff --git a/src/UniversalDashboard.UITest/Integration/PublishDashboard.Tests.ps1 b/src/UniversalDashboard.UITest/Integration/PublishDashboard.Tests.ps1 deleted file mode 100644 index 6281b241..00000000 --- a/src/UniversalDashboard.UITest/Integration/PublishDashboard.Tests.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -param([Switch]$Release) - -. "$PSScriptRoot\..\TestFramework.ps1" -$ModulePath = Get-ModulePath -Release:$Release -$BrowserPort = Get-BrowserPort -Release:$Release - -Import-Module $ModulePath -Force - -if (-not $Release) { - Write-Warning "Publish tests must run in a release build" - return -} - -$tempDashboard = Join-Path ([IO.Path]::GetTempPath()) "dashboard.ps1" - -Describe "Publish-UDDashboard" { - sc.exe stop UniversalDashboard - sc.exe delete UniversalDashboard - - Remove-Item $tempDashboard -Force -ErrorAction SilentlyContinue - $deploymentPath = Join-Path ([IO.Path]::GetTempPath()) "service" - - It "should publish a dashboard with just a dashboard file" { - "Import-Module '$ModulePath'; Start-UDDashboard -Port 10000 -Dashboard (New-UDDashboard -Title 'Test' -Content {})" | Out-File $tempDashboard - - Publish-UDDashboard -DashboardFile $tempDashboard - - Start-Sleep 3 - - (Invoke-WebRequest http://localhost:10000).StatusCode | Should be 200 - } - - sc.exe stop UniversalDashboard - sc.exe delete UniversalDashboard - Remove-Item $tempDashboard -Force -ErrorAction SilentlyContinue - - It "should publish a dashboard with target path" { - "Import-Module '$ModulePath'; Start-UDDashboard -Port 10000 -Dashboard (New-UDDashboard -Title 'Test' -Content {})" | Out-File $tempDashboard - - Publish-UDDashboard -DashboardFile $tempDashboard -TargetPath $deploymentPath - - Start-Sleep 3 - - (Invoke-WebRequest http://localhost:10000).StatusCode | Should be 200 - } - - sc.exe stop UniversalDashboard - sc.exe delete UniversalDashboard - Remove-Item $tempDashboard -Force -ErrorAction SilentlyContinue - Remove-Item $deploymentPath -Force -ErrorAction SilentlyContinue -Recurse - - It "should delete service and recreate service" { - "Import-Module '$ModulePath'; Start-UDDashboard -Port 10000 -Dashboard (New-UDDashboard -Title 'Test' -Content {})" | Out-File $tempDashboard - - $Error.Clear() - - Publish-UDDashboard -DashboardFile $tempDashboard - - Start-Sleep 10 - - Publish-UDDashboard -DashboardFile $tempDashboard - - Start-Sleep 10 - - (Invoke-WebRequest http://localhost:10000).StatusCode | Should be 200 - $Error.Length | Should be 1 - - Start-Sleep 10 - } - - sc.exe stop UniversalDashboard - sc.exe delete UniversalDashboard - Remove-Item $tempDashboard -Force -ErrorAction SilentlyContinue - Remove-Item $deploymentPath -Force -ErrorAction SilentlyContinue -Recurse - - It "should set service start type to manual" { - "Import-Module '$ModulePath'; Start-UDDashboard -Port 10000 -Dashboard (New-UDDashboard -Title 'Test' -Content {})" | Out-File $tempDashboard - - $Error.Clear() - - Publish-UDDashboard -DashboardFile $tempDashboard -Manual - - (Get-Service UniversalDashboard).StartType | should be "Manual" - } - - sc.exe delete UniversalDashboard - Remove-Item $tempDashboard -Force -ErrorAction SilentlyContinue - Remove-Item $deploymentPath -Force -ErrorAction SilentlyContinue -Recurse -} \ No newline at end of file diff --git a/src/UniversalDashboard.UITest/Integration/webconfig.tests.ps1 b/src/UniversalDashboard.UITest/Integration/webconfig.tests.ps1 deleted file mode 100644 index b1c2d88f..00000000 --- a/src/UniversalDashboard.UITest/Integration/webconfig.tests.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -Describe "web.config" { - It "has correct framework version" { - $webconfig = Get-Content (Join-Path $PSScriptRoot "..\..\web.config") -Raw - $webconfig.Contains("net472") | Should be $true - } -} \ No newline at end of file diff --git a/src/UniversalDashboard.UITest/Manifest.Tests.ps1 b/src/UniversalDashboard.UITest/Manifest.Tests.ps1 index fcd037f6..7cd4c50a 100644 --- a/src/UniversalDashboard.UITest/Manifest.Tests.ps1 +++ b/src/UniversalDashboard.UITest/Manifest.Tests.ps1 @@ -62,7 +62,6 @@ Describe "Manifest" { Get-Command 'Out-UDGridData' -ErrorAction SilentlyContinue | Should not be $null Get-Command 'Out-UDMonitorData' -ErrorAction SilentlyContinue | Should not be $null Get-Command 'Out-UDTableData' -ErrorAction SilentlyContinue | Should not be $null - Get-Command 'Publish-UDDashboard' -ErrorAction SilentlyContinue | Should not be $null Get-Command 'Remove-UDCookie' -ErrorAction SilentlyContinue | Should not be $null Get-Command 'Set-UDContentType' -ErrorAction SilentlyContinue | Should not be $null Get-Command 'Set-UDCookie' -ErrorAction SilentlyContinue | Should not be $null @@ -120,7 +119,7 @@ Describe "Manifest" { Get-Command 'New-UDGridLayout' -ErrorAction SilentlyContinue | Should not be $null Get-Command 'Clear-UDCache' -ErrorAction SilentlyContinue | Should not be $null - (Get-Command -Module UniversalDashboard.Community | Measure-Object).Count | should be 129 + (Get-Command -Module UniversalDashboard.Community | Measure-Object).Count | should be 128 } It "should require .NET 4.7" -Skip { diff --git a/src/UniversalDashboard.sln b/src/UniversalDashboard.sln index 5a42abf3..254d2b97 100644 --- a/src/UniversalDashboard.sln +++ b/src/UniversalDashboard.sln @@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{A666D7E6 build.ps1 = build.ps1 EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversalDashboard.Server", "UniversalDashboard.Server\UniversalDashboard.Server.csproj", "{ECA5AC7B-9166-470A-B99C-234241794D3E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversalDashboard.Common", "UniversalDashboard.Common\UniversalDashboard.Common.csproj", "{0EE93AE9-7C10-48D4-B804-CCC0C8CA39B0}" EndProject Global @@ -30,10 +28,6 @@ Global {08412C9A-7ADD-4D7A-AFC6-68D64F044A07}.Debug|Any CPU.Build.0 = Debug|Any CPU {08412C9A-7ADD-4D7A-AFC6-68D64F044A07}.Release|Any CPU.ActiveCfg = Release|Any CPU {08412C9A-7ADD-4D7A-AFC6-68D64F044A07}.Release|Any CPU.Build.0 = Release|Any CPU - {ECA5AC7B-9166-470A-B99C-234241794D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ECA5AC7B-9166-470A-B99C-234241794D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ECA5AC7B-9166-470A-B99C-234241794D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ECA5AC7B-9166-470A-B99C-234241794D3E}.Release|Any CPU.Build.0 = Release|Any CPU {0EE93AE9-7C10-48D4-B804-CCC0C8CA39B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0EE93AE9-7C10-48D4-B804-CCC0C8CA39B0}.Debug|Any CPU.Build.0 = Debug|Any CPU {0EE93AE9-7C10-48D4-B804-CCC0C8CA39B0}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/UniversalDashboard/New-UDModuleManifest.ps1 b/src/UniversalDashboard/New-UDModuleManifest.ps1 index 1282e7b7..aa0c9226 100644 --- a/src/UniversalDashboard/New-UDModuleManifest.ps1 +++ b/src/UniversalDashboard/New-UDModuleManifest.ps1 @@ -81,7 +81,6 @@ $manifestParameters = @{ "New-UDSwitch", "New-UDRadio", "New-UDTextbox", - "Publish-UDDashboard", "New-UDImage" "New-UDFab" "New-UDFabButton" diff --git a/src/UniversalDashboard/UniversalDashboardServer.psm1 b/src/UniversalDashboard/UniversalDashboardServer.psm1 index 000745cc..efedf61f 100644 --- a/src/UniversalDashboard/UniversalDashboardServer.psm1 +++ b/src/UniversalDashboard/UniversalDashboardServer.psm1 @@ -1461,86 +1461,6 @@ function Get-UDCacheData { [Microsoft.Extensions.Caching.Memory.CacheExtensions]::Get($MemoryCache, $Key) } -function Publish-UDDashboard { - [CmdletBinding(DefaultParameterSetName = 'Service')] - param( - [Parameter(ParameterSetName = 'Service')] - [Switch]$Manual, - [Parameter(Mandatory = $true)] - [string]$DashboardFile, - [Parameter()] - [string]$TargetPath = $PSScriptRoot, - [Parameter(ParameterSetName = 'Service')] - [Switch]$DontSetExecutionPolicy - ) - - $DashboardFile = Resolve-Path $DashboardFile - - if (-not (Test-Path $DashboardFile)) { - throw "$DashboardFile does not exist" - } - - if ((Get-Item $DashboardFile).Name -ne "dashboard.ps1") { - throw "DashboardFile must be named dashboard.ps1" - } - - $TargetDashboardFile = $DashboardFile - - if ($PSBoundParameters.ContainsKey("TargetPath")) { - if (-not (Test-Path $TargetPath)) { - Write-Verbose "Directory $TargetPath does not exist. Creating target directory." - - New-Item $TargetPath -Type Directory | Out-Null - } - - $SourcePath = $PSScriptRoot - - Write-Verbose "Copying Universal Dashboard module from $SourcePath -> $TargetPath" - Get-ChildItem $SourcePath | ForEach-Object { - Copy-Item $_.FullName $TargetPath -Recurse -Force - } - - $DashboardFileName = Split-Path $DashboardFile -Leaf - $TargetDashboardFile = Join-Path $TargetPath $DashboardFileName - } - else - { - $ModulePath = Split-Path (Get-Module UniversalDashboard.Community).Path - $TargetDashboardFile = [IO.Path]::Combine($ModulePath, "dashboard.ps1") - } - - Write-Verbose "Copying dashboard file from $DashboardFile -> $TargetPath" - Copy-Item $DashboardFile $TargetDashboardFile -Force - - if ($PSCmdlet.ParameterSetName -eq 'Service') { - - $ServiceStart = 'auto' - if ($Manual) { - $ServiceStart = 'demand' - } - - if ((Get-Service -Name UniversalDashboard -ErrorAction SilentlyContinue) -ne $null) { - Write-Verbose "Removing dashboard service" - sc.exe delete UniversalDashboard - } - - Write-Verbose "Creating service UniversalDashboard" - - $binPath = [System.IO.Path]::Combine($TargetPath, "net472", "UniversalDashboard.Server.exe") - - $args = "$binPath --run-as-service"; - if ($DontSetExecutionPolicy) - { - $args += " --dont-set-execution-policy" - } - - sc.exe create UniversalDashboard DisplayName= "PowerShell Universal Dashboard" binPath= "$args" start= "$ServiceStart" - - Write-Verbose "Starting service UniversalDashboard" - sc.exe start UniversalDashboard - } -} - class ValidationErrorMessage : Attribute { ValidationErrorMessage([string]$Message) { $this.Message = $Message diff --git a/src/build.ps1 b/src/build.ps1 index f1562610..971e6d0f 100644 --- a/src/build.ps1 +++ b/src/build.ps1 @@ -95,14 +95,6 @@ Copy-Item "$PSScriptRoot\UniversalDashboard\bin\$Configuration\net472\publish\*" Copy-Item "$PSScriptRoot\client\src\public\*" $client -Recurse -Copy-Item "$PSScriptRoot\UniversalDashboard.Server\bin\$Configuration\netstandard2.0\publish\UniversalDashboard.Server.dll" $netstandard20 -Copy-Item "$PSScriptRoot\UniversalDashboard.Server\bin\$Configuration\netstandard2.0\publish\UniversalDashboard.Server.deps.json" $netstandard20 -Copy-Item "$PSScriptRoot\UniversalDashboard.Server\bin\$Configuration\netstandard2.0\publish\DasMulli.Win32.ServiceUtils.dll" $netstandard20 - -Copy-Item "$PSScriptRoot\UniversalDashboard.Server\bin\$Configuration\net472\publish\UniversalDashboard.Server.exe" $net472 -Copy-Item "$PSScriptRoot\UniversalDashboard.Server\bin\$Configuration\net472\publish\UniversalDashboard.Server.exe.config" $net472 -Copy-Item "$PSScriptRoot\UniversalDashboard.Server\bin\$Configuration\net472\publish\DasMulli.Win32.ServiceUtils.dll" $net472 - Copy-Item "$PSScriptRoot\web.config" $outputDirectory Copy-Item "$PSScriptRoot\UniversalDashboard\UniversalDashboard.psm1" $outputDirectory Copy-Item "$PSScriptRoot\UniversalDashboard\UniversalDashboardServer.psm1" $outputDirectory @@ -118,8 +110,6 @@ Copy-Item "$PSScriptRoot\UniversalDashboard.MaterialUI\output\UniversalDashboard # End Copy Child Modules -. "$PSScriptRoot\CorFlags.exe" /32BITREQ- "$outputDirectory\net472\UniversalDashboard.Server.exe" - . (Join-Path $PSScriptRoot 'UniversalDashboard\New-UDModuleManifest.ps1') -outputDirectory $outputDirectory if (-not $Minimal) { diff --git a/src/web.config b/src/web.config index e2949b15..3fa349e2 100644 --- a/src/web.config +++ b/src/web.config @@ -10,7 +10,7 @@ - +