From c328f465e3c014d827b3b40fba8b3a6447744866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Both?= Date: Fri, 27 Dec 2019 21:01:37 +0100 Subject: [PATCH] Step 1 towards DSC community owned module and Azure pipelines --- .MetaTestOptIn.json | 6 - .codecov.yml | 24 -- .../ISSUE_TEMPLATE/Problem_with_resource.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .gitignore | 2 +- .markdownlint.json | 10 + CHANGELOG.MD | 107 +++++++ CODE_OF_CONDUCT.md | 6 + GitVersion.yml | 38 +++ LICENSE | 4 +- README.md | 265 +---------------- RequiredModules.psd1 | 20 ++ Resolve-Dependency.ps1 | 258 +++++++++++++++++ Resolve-Dependency.psd1 | 10 + appveyor.yml | 42 --- build.ps1 | 266 ++++++++++++++++++ build.yaml | 112 ++++++++ .../MSFT_xRDGatewayConfiguration.psm1 | 0 .../MSFT_xRDGatewayConfiguration.schema.mof | 0 .../MSFT_xRDLicenseConfiguration.psm1 | 0 .../MSFT_xRDLicenseConfiguration.schema.mof | 0 .../MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 | 0 .../MSFT_xRDRemoteApp.schema.mof | 0 .../MSFT_xRDServer/MSFT_xRDServer.psm1 | 0 .../MSFT_xRDServer/MSFT_xRDServer.schema.mof | 0 .../MSFT_xRDSessionCollection.psm1 | 0 .../MSFT_xRDSessionCollection.schema.mof | 0 ...SFT_xRDSessionCollectionConfiguration.psm1 | 0 ...DSessionCollectionConfiguration.schema.mof | 0 .../MSFT_xRDSessionDeployment.psm1 | 0 .../MSFT_xRDSessionDeployment.schema.mof | 0 .../xRemoteDesktopSessionHostCommon.psm1 | 0 source/build.psd1 | 6 + .../about_xRemoteDesktopSessionHost.help.txt | 26 ++ .../xRemoteDesktopSessionHost.psd1 | 40 +-- .../MSFT_xRDGatewayConfiguration.tests.ps1 | 0 .../MSFT_xRDLicenseConfiguration.tests.ps1 | 0 .../Unit/MSFT_xRDRemoteApp.tests.ps1 | 0 .../Unit/MSFT_xRDServer.tests.ps1 | 0 .../Unit/MSFT_xRDSessionCollection.tests.ps1 | 0 ...RDSessionCollectionConfiguration.tests.ps1 | 0 .../Unit/MSFT_xRDSessionDeployment.tests.ps1 | 0 .../Unit/xRemoteDesktopSessionHost.tests.ps1 | 0 43 files changed, 893 insertions(+), 353 deletions(-) delete mode 100644 .MetaTestOptIn.json delete mode 100644 .codecov.yml create mode 100644 .markdownlint.json create mode 100644 CHANGELOG.MD create mode 100644 CODE_OF_CONDUCT.md create mode 100644 GitVersion.yml create mode 100644 RequiredModules.psd1 create mode 100644 Resolve-Dependency.ps1 create mode 100644 Resolve-Dependency.psd1 delete mode 100644 appveyor.yml create mode 100644 build.ps1 create mode 100644 build.yaml rename {DSCResources => source/DSCResources}/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDServer/MSFT_xRDServer.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDServer/MSFT_xRDServer.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.schema.mof (100%) rename xRemoteDesktopSessionHostCommon.psm1 => source/Modules/xRemoteDesktopSessionHostCommon.psm1 (100%) create mode 100644 source/build.psd1 create mode 100644 source/en-US/about_xRemoteDesktopSessionHost.help.txt rename xRemoteDesktopSessionHost.psd1 => source/xRemoteDesktopSessionHost.psd1 (52%) rename {Tests => tests}/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_xRDRemoteApp.tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_xRDServer.tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_xRDSessionCollection.tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_xRDSessionDeployment.tests.ps1 (100%) rename {Tests => tests}/Unit/xRemoteDesktopSessionHost.tests.ps1 (100%) diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json deleted file mode 100644 index 3074e38..0000000 --- a/.MetaTestOptIn.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "Common Tests - Validate Markdown Files", - "Common Tests - Validate Example Files", - "Common Tests - Validate Module Files", - "Common Tests - Validate Script Files" -] diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 29a05dd..0000000 --- a/.codecov.yml +++ /dev/null @@ -1,24 +0,0 @@ -codecov: - notify: - require_ci_to_pass: no - -comment: - layout: "reach, diff" - behavior: default - -coverage: - range: 50..80 - round: down - precision: 0 - - status: - project: - default: - # Set the overall project code coverage requirement to 70% - target: 70 - patch: - default: - # Set the pull request requirement to not regress overall coverage by more than 5% - # and let codecov.io set the goal for the code changed in the patch. - target: auto - threshold: 5 diff --git a/.github/ISSUE_TEMPLATE/Problem_with_resource.md b/.github/ISSUE_TEMPLATE/Problem_with_resource.md index 2431f65..159e81c 100644 --- a/.github/ISSUE_TEMPLATE/Problem_with_resource.md +++ b/.github/ISSUE_TEMPLATE/Problem_with_resource.md @@ -54,4 +54,4 @@ about: If you have a problem, bug, or enhancement with a resource in this resour $PSVersionTable --> -#### Version of the DSC module that was used ('dev' if using current dev branch) +#### Version of the DSC module that was used diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 84e1ea8..f49bae5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -34,7 +34,7 @@ Change to [x] for each task in the task list that applies to your PR. For those task that don't apply to you PR, leave those as is. --> -- [ ] Added an entry under the Unreleased section of the change log in the README.md. +- [ ] Added an entry under the Unreleased section of file CHANGELOG.md. Entry should say what was changed, and how that affects users (if applicable). - [ ] Resource documentation added/updated in README.md. - [ ] Resource parameter descriptions added/updated in README.md, schema.mof diff --git a/.gitignore b/.gitignore index aa44cee..3109c57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .vs -DSCResource.Tests +output/* diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..87b7da5 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,10 @@ +{ + "default": true, + "MD029": { + "style": "one" + }, + "MD013": true, + "MD024": false, + "MD034": false, + "no-hard-tabs": true +} diff --git a/CHANGELOG.MD b/CHANGELOG.MD new file mode 100644 index 0000000..e165f7d --- /dev/null +++ b/CHANGELOG.MD @@ -0,0 +1,107 @@ +# Change log for xRemoteDesktopSessionHost + +The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- xRemoteDesktopSessionHost + - Added automatic release with a new CI pipeline. + +### Changed + +- Changes to xRDSessionDeployment + - Fixing Get-TargetResource to target the connection broker, instead of + assuming localhost +- Changes to xRDServer + - Changed resouce key from Server alone to Role + Server. + This allows the resource to be used multiple times for different roles on + the same server. (Issue #62) + +### Deprecated + +- None + +### Removed + +- None + +### Fixed + +- None + +### Security + +- None + +## 1.9.0.0 + +- Changes to xRDRemoteApp + - Fixing typo in parameter name when calling the function ValidateCustomModeParameters (issue #50). +- Changes to xRDSessionDeployment + - When RDMS service does not exist the Get-TargetResource will no longer throw an error (issue #47). +- Rename Tests/Unit folder to use upper case on first letter. +- Update appveyor.yml to use the default template. +- Added default template files .codecov.yml, .gitattributes, and .gitignore, and + .vscode folder. +- xRDSessionCollectionConfiguration: + - Changed CollectionName variable validation max length to 256 +- xRDSessionCollection + - Changed CollectionName variable validation max length to 256 +- xRDRemoteApp + - Changed CollectionName variable validation max length to 256 + +## 1.8.0.0 + +- Changes to xRDSessionDeployment + - Fixed issue where an initial deployment failed due to a convert to lowercase (issue #39). + - Added unit tests to test Get, Test and Set results in this resource. +- Change to xRDRemoteApp + - Fixed issue where this resource ignored the CollectionName provided in the parameters (issue #41). + - Changed key values in schema.mof to only Alias and CollectionName, DisplayName and FilePath are not key values. + - Added Ensure property (Absent or Present) to enable removal of RemoteApps. + - Added unit tests to test Get, Test and Set results in this resource. + +## 1.7.0.0 + +- Added additional resources, copied from the [Azure RDS quickstart templates](https://github.com/Azure/RDS-Templates). +- xRDSessionCollection: + - Fixed call to Add-RDSessionHost in Set-TargetResource by properly removing CollectionDescription from PSBoundParameters (issue #28) + - Fixed bug on Get-TargetResource that did return any collection instead of the one collection the user asked for (issue #27) + - Added unit tests to test Get, Test and Set results in this resource + +## 1.6.0.0 + +- xRDSessionCollectionConfiguration: Add support to configure UserProfileDisks on Windows Server 2016 + +## 1.5.0.0 + +- Fix issue where DSC configuration gets into a reboot loop because sessionhost does not match (casing) and RDMS service is not started in time + +## 1.4.0.0 + +- Updated CollectionName parameter to validate length between 1 and 15 characters, and added tests to verify. + +## 1.3.0.0 + +- Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey. + +## 1.2.0.0 + +- Fixed an issue with version checks where OS version greater than 9 would fail (Windows 10/Server 2016) + +## 1.1.0.0 + +- Fixed encoding + +## 1.0.1 + +## 1.0.0.0 + +- Initial release with the following resources + - xRDSessionDeployment + - xRDSessionCollection + - xRDSessionCollectionConfiguration + - xRDRemoteApp diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..1d5c9ea --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,6 @@ +# Code of conduct + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional +questions or comments. diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..38b671b --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,38 @@ +mode: ContinuousDelivery +next-version: 0.90 +major-version-bump-message: '\s?(breaking|major|breaking\schange)' +minor-version-bump-message: '\s?(add|feature|minor)' +patch-version-bump-message: '\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}' +branches: + master: + tag: preview + pull-request: + tag: PR + feature: + tag: useBranchName + increment: Minor + regex: f(eature(s)?)?[/-] + source-branches: ['master'] + hotfix: + tag: fix + increment: Patch + regex: (hot)?fix(es)?[/-] + source-branches: ['master'] + +ignore: + sha: [] +merge-message-formats: {} + + +# feature: +# tag: useBranchName +# increment: Minor +# regex: f(eature(s)?)?[/-] +# source-branches: ['master'] +# hotfix: +# tag: fix +# increment: Patch +# regex: (hot)?fix(es)?[/-] +# source-branches: ['master'] diff --git a/LICENSE b/LICENSE index bc0fd0b..f4c3ee9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 Microsoft Corporation. +Copyright (c) DSC Community contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/README.md b/README.md index e30fd2b..65c52d4 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,27 @@ # xRemoteDesktopSessionHost -The **xRemoteDesktopSessionHost** module contains the **xRDSessionDeployment**, **xRDSessionCollection**, **xRDSessionCollectionConfiguration**, and **xRDRemoteApp** resources, allowing creation and configuration of a Remote Desktop Session Host (RDSH) instance. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. - -## Branches - -### master +[![Build Status](https://dev.azure.com/dsccommunity/xRemoteDesktopSessionHost/_apis/build/status/dsccommunity.xRemoteDesktopSessionHost?branchName=master)](https://dev.azure.com/dsccommunity/xRemoteDesktopSessionHost/_build/latest?definitionId={definitionId}&branchName=master) +![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/dsccommunity/xRemoteDesktopSessionHost/{definitionId}/master) +[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/xRemoteDesktopSessionHost/{definitionId}/master)](https://dsccommunity.visualstudio.com/xRemoteDesktopSessionHost/_test/analytics?definitionId={definitionId}&contextType=build) +[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/xRemoteDesktopSessionHost?label=xRemoteDesktopSessionHost%20Preview)](https://www.powershellgallery.com/packages/xRemoteDesktopSessionHost/) +[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/xRemoteDesktopSessionHost?label=xRemoteDesktopSessionHost)](https://www.powershellgallery.com/packages/xRemoteDesktopSessionHost/) -[![Build status](https://ci.appveyor.com/api/projects/status/ly6w6vaavkshrpg8/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xremotedesktopsessionhost/branch/master) -[![codecov](https://codecov.io/gh/PowerShell/xRemoteDesktopSessionHost/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/xRemoteDesktopSessionHost/branch/master) +The **xRemoteDesktopSessionHost** module contains the **xRDSessionDeployment**, **xRDSessionCollection**, **xRDSessionCollectionConfiguration**, and **xRDRemoteApp** resources, allowing creation and configuration of a Remote Desktop Session Host (RDSH) instance. -This is the branch containing the latest release - no contributions should be made -directly to this branch. +## Code of Conduct -### dev +This project has adopted this [Code of Conduct](CODE_OF_CONDUCT.md). -[![Build status](https://ci.appveyor.com/api/projects/status/ly6w6vaavkshrpg8/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/xremotedesktopsessionhost/branch/dev) -[![codecov](https://codecov.io/gh/PowerShell/xRemoteDesktopSessionHost/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/xRemoteDesktopSessionHost/branch/dev) +## Releases -This is the development branch to which contributions should be proposed by contributors -as pull requests. This development branch will periodically be merged to the master -branch, and be released to [PowerShell Gallery](https://www.powershellgallery.com/). +For each merge to the branch `master` a preview release will be +deployed to [PowerShell Gallery](https://www.powershellgallery.com/). +Periodically a release version tag will be pushed which will deploy a +full release to [PowerShell Gallery](https://www.powershellgallery.com/). ## Contributing -Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). ## Resources @@ -118,235 +113,3 @@ Please check out common DSC Resources [contributing guidelines](https://github.c * **ConnectionBroker**: Specifies the Remote Desktop Connection Broker (RD Connection Broker) server for a Remote Desktop deployment. * **LicenseServers**: An array of servers to use for RD licensing * **LicenseMode**: The RD licensing mode to use. PerUser, PerDevice, or NotConfigured. - -## Versions - -### Unreleased - -* Changes to xRDServer - * Changed resouce key from Server alone to Role + Server. - This allows the resource to be used multiple times for different roles on the same server. (Issue #62) -* Changes to xRDSessionDeployment - * Fixing Get-TargetResource to target the connection broker, instead of assuming localhost - -### 1.9.0.0 - -* Changes to xRDRemoteApp - * Fixing typo in parameter name when calling the function ValidateCustomModeParameters (issue #50). -* Changes to xRDSessionDeployment - * When RDMS service does not exist the Get-TargetResource will no longer throw an error (issue #47). -* Rename Tests/Unit folder to use upper case on first letter. -* Update appveyor.yml to use the default template. -* Added default template files .codecov.yml, .gitattributes, and .gitignore, and - .vscode folder. -* xRDSessionCollectionConfiguration: - * Changed CollectionName variable validation max length to 256 -* xRDSessionCollection - * Changed CollectionName variable validation max length to 256 -* xRDRemoteApp - * Changed CollectionName variable validation max length to 256 - -### 1.8.0.0 - -* Changes to xRDSessionDeployment - * Fixed issue where an initial deployment failed due to a convert to lowercase (issue #39). - * Added unit tests to test Get, Test and Set results in this resource. -* Change to xRDRemoteApp - * Fixed issue where this resource ignored the CollectionName provided in the parameters (issue #41). - * Changed key values in schema.mof to only Alias and CollectionName, DisplayName and FilePath are not key values. - * Added Ensure property (Absent or Present) to enable removal of RemoteApps. - * Added unit tests to test Get, Test and Set results in this resource. - -### 1.7.0.0 - -* Added additional resources, copied from the [Azure RDS quickstart templates](https://github.com/Azure/RDS-Templates). -* xRDSessionCollection: - * Fixed call to Add-RDSessionHost in Set-TargetResource by properly removing CollectionDescription from PSBoundParameters (issue #28) - * Fixed bug on Get-TargetResource that did return any collection instead of the one collection the user asked for (issue #27) - * Added unit tests to test Get, Test and Set results in this resource - -### 1.6.0.0 - -* xRDSessionCollectionConfiguration: Add support to configure UserProfileDisks on Windows Server 2016 - -### 1.5.0.0 - -* Fix issue where DSC configuration gets into a reboot loop because sessionhost does not match (casing) and RDMS service is not started in time - -### 1.4.0.0 - -* Updated CollectionName parameter to validate length between 1 and 15 characters, and added tests to verify. - -### 1.3.0.0 - -* Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey. - -### 1.2.0.0 - -* Fixed an issue with version checks where OS version greater than 9 would fail (Windows 10/Server 2016) - -### 1.1.0.0 - -* Fixed encoding - -### 1.0.1 - -### 1.0.0.0 - -* Initial release with the following resources - * **xRDSessionDeployment** - * **xRDSessionCollection** - * **xRDSessionCollectionConfiguration** - * **xRDRemoteApp** - -## Examples - -### End to End - -```powershell -param ( -[string]$brokerFQDN, -[string]$webFQDN, -[string]$collectionName, -[string]$collectionDescription -) - -$localhost = [System.Net.Dns]::GetHostByName((hostname)).HostName - -if (!$collectionName) {$collectionName = "Tenant Jump Box"} -if (!$collectionDescription) {$collectionDescription = "Remote Desktop instance for accessing an isolated network environment."} - -Configuration RemoteDesktopSessionHost -{ - param - ( - - # Connection Broker Name - [Parameter(Mandatory)] - [String]$collectionName, - - # Connection Broker Description - [Parameter(Mandatory)] - [String]$collectionDescription, - - # Connection Broker Node Name - [String]$connectionBroker, - - # Web Access Node Name - [String]$webAccessServer - ) - Import-DscResource -Module xRemoteDesktopSessionHost - if (!$connectionBroker) {$connectionBroker = $localhost} - if (!$connectionWebAccessServer) {$webAccessServer = $localhost} - - Node "localhost" - { - - LocalConfigurationManager - { - RebootNodeIfNeeded = $true - } - - WindowsFeature Remote-Desktop-Services - { - Ensure = "Present" - Name = "Remote-Desktop-Services" - } - - WindowsFeature RDS-RD-Server - { - Ensure = "Present" - Name = "RDS-RD-Server" - } - - WindowsFeature Desktop-Experience - { - Ensure = "Present" - Name = "Desktop-Experience" - } - - WindowsFeature RSAT-RDS-Tools - { - Ensure = "Present" - Name = "RSAT-RDS-Tools" - IncludeAllSubFeature = $true - } - - if ($localhost -eq $connectionBroker) { - WindowsFeature RDS-Connection-Broker - { - Ensure = "Present" - Name = "RDS-Connection-Broker" - } - } - - if ($localhost -eq $webAccessServer) { - WindowsFeature RDS-Web-Access - { - Ensure = "Present" - Name = "RDS-Web-Access" - } - } - - WindowsFeature RDS-Licensing - { - Ensure = "Present" - Name = "RDS-Licensing" - } - - xRDSessionDeployment Deployment - { - SessionHost = $localhost - ConnectionBroker = if ($ConnectionBroker) {$ConnectionBroker} else {$localhost} - WebAccessServer = if ($WebAccessServer) {$WebAccessServer} else {$localhost} - DependsOn = "[WindowsFeature]Remote-Desktop-Services", "[WindowsFeature]RDS-RD-Server" - } - - xRDSessionCollection Collection - { - CollectionName = $collectionName - CollectionDescription = $collectionDescription - SessionHost = $localhost - ConnectionBroker = if ($ConnectionBroker) {$ConnectionBroker} else {$localhost} - DependsOn = "[xRDSessionDeployment]Deployment" - } - xRDSessionCollectionConfiguration CollectionConfiguration - { - CollectionName = $collectionName - CollectionDescription = $collectionDescription - ConnectionBroker = if ($ConnectionBroker) {$ConnectionBroker} else {$localhost} - TemporaryFoldersDeletedOnExit = $false - SecurityLayer = "SSL" - DependsOn = "[xRDSessionCollection]Collection" - } - xRDRemoteApp Calc - { - CollectionName = $collectionName - DisplayName = "Calculator" - FilePath = "C:\Windows\System32\calc.exe" - Alias = "calc" - DependsOn = "[xRDSessionCollection]Collection" - } - xRDRemoteApp Mstsc - { - CollectionName = $collectionName - DisplayName = "Remote Desktop" - FilePath = "C:\Windows\System32\mstsc.exe" - Alias = "mstsc" - DependsOn = "[xRDSessionCollection]Collection" - } - } -} - -write-verbose "Creating configuration with parameter values:" -write-verbose "Collection Name: $collectionName" -write-verbose "Collection Description: $collectionDescription" -write-verbose "Connection Broker: $brokerFQDN" -write-verbose "Web Access Server: $webFQDN" - -RemoteDesktopSessionHost -collectionName $collectionName -collectionDescription $collectionDescription -connectionBroker $brokerFQDN -webAccessServer $webFQDN -OutputPath .\RDSDSC\ - -Set-DscLocalConfigurationManager -verbose -path .\RDSDSC\ - -Start-DscConfiguration -wait -force -verbose -path .\RDSDSC\ -``` diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 new file mode 100644 index 0000000..9735e2b --- /dev/null +++ b/RequiredModules.psd1 @@ -0,0 +1,20 @@ +@{ + # Set up a mini virtual environment... + PSDependOptions = @{ + AddToPath = $True + Target = 'output\RequiredModules' + Parameters = @{ + } + } + + invokeBuild = 'latest' + PSScriptAnalyzer = 'latest' + pester = 'latest' + Plaster = 'latest' + ModuleBuilder = 'latest' + ChangelogManagement = 'latest' + Sampler = 'latest' + + #required for DSC authoring + # xDscResourceDesigner = 'latest' +} diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 new file mode 100644 index 0000000..56a2c73 --- /dev/null +++ b/Resolve-Dependency.ps1 @@ -0,0 +1,258 @@ +<#PSScriptInfo + +.VERSION 0.1.0 + +.GUID fc162bd7-b649-4398-bff0-180bc473920f + +.AUTHOR Gael Colas + +.COMPANYNAME SynEdgy Ltd + +.COPYRIGHT SynEdgy All rights Reserved + +.TAGS bootstrap pipeline CI CI/CD + +.LICENSEURI + +.PROJECTURI https://github.com/gaelcolas/sampler + +.RELEASENOTES + # This is where the ChangeLog should be + +#> +[CmdletBinding()] +param( + + [String]$DependencyFile = 'RequiredModules.psd1', + + # Path for PSDepend to be bootstrapped and save other dependencies. + # Can also be CurrentUser or AllUsers if you wish to install the modules in such scope + # Default to $PWD.Path/output/modules + $PSDependTarget = (Join-Path $PSScriptRoot './output/RequiredModules'), + + # URI to use for Proxy when attempting to Bootstrap PackageProvider & PowerShellGet + [uri]$Proxy, + + # Credential to contact the Proxy when provided + [PSCredential]$ProxyCredential, + + # Scope to bootstrap the PackageProvider and PSGet if not available + [ValidateSet('CurrentUser', 'AllUsers')] + $Scope = 'CurrentUser', + + # Gallery to use when bootstrapping PackageProvider, PSGet and when calling PSDepend (can be overridden in Dependency files) + [String]$Gallery = 'PSGallery', + + # Credentials to use with the Gallery specified above + [Parameter()] + [PSCredential]$GalleryCredential, + + + # Allow you to use a locally installed version of PowerShellGet older than 1.6.0 (not recommended, default to $False) + [switch]$AllowOldPowerShellGetModule, + + # Allow you to specify a minimum version fo PSDepend, if you're after specific features. + [String]$MinimumPSDependVersion, + + [Switch]$AllowPrerelease, + + [Switch]$WithYAML +) + +# Load Defaults for parameters values from Resolve-Dependency.psd1 if not provided as parameter +try { + Write-Verbose -Message "Importing Bootstrap default parameters from '$PSScriptRoot/Resolve-Dependency.psd1'." + $ResolveDependencyDefaults = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1' -Resolve -ErrorAction Stop) + $ParameterToDefault = $MyInvocation.MyCommand.ParameterSets.Where{ $_.Name -eq $PSCmdlet.ParameterSetName}.Parameters.Keys + if ($ParameterToDefault.Count -eq 0) { + $ParameterToDefault = $MyInvocation.MyCommand.Parameters.Keys + } + # Set the parameters available in the Parameter Set, or it's not possible to choose yet, so all parameters are an option + foreach ($ParamName in $ParameterToDefault) { + if (-Not $PSBoundParameters.Keys.Contains($ParamName) -and $ResolveDependencyDefaults.ContainsKey($ParamName)) { + Write-Verbose -Message "Setting $ParamName with $($ResolveDependencyDefaults[$ParamName])" + try { + $variableValue = $ResolveDependencyDefaults[$ParamName] + if($variableValue -is [string]) { + $variableValue = $ExecutionContext.InvokeCommand.ExpandString($variableValue) + } + $PSBoundParameters.Add($ParamName, $variableValue) + Set-Variable -Name $ParamName -value $variableValue -Force -ErrorAction SilentlyContinue + } + catch { + Write-Verbose -Message "Error adding default for $ParamName : $($_.Exception.Message)" + } + } + } +} +catch { + Write-Warning -Message "Error attempting to import Bootstrap's default parameters from $(Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1'): $($_.Exception.Message)." +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 0 -CurrentOperation "NuGet Bootstrap" + +if (!(Get-PackageProvider -Name NuGet -ForceBootstrap -ErrorAction SilentlyContinue)) { + $providerBootstrapParams = @{ + Name = 'nuget' + force = $true + ForceBootstrap = $true + ErrorAction = 'Stop' + } + + switch ($PSBoundParameters.Keys) { + 'Proxy' { + $providerBootstrapParams.Add('Proxy', $Proxy) + } + 'ProxyCredential' { + $providerBootstrapParams.Add('ProxyCredential', $ProxyCredential) + } + 'Scope' { + $providerBootstrapParams.Add('Scope', $Scope) + } + } + + if ($AllowPrerelease) { + $providerBootstrapParams.Add('AllowPrerelease', $true) + } + + Write-Information "Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed)" + $null = Install-PackageProvider @providerBootstrapParams + $latestNuGetVersion = (Get-PackageProvider -Name NuGet -ListAvailable | Select-Object -First 1).Version.ToString() + Write-Information "Bootstrap: Importing NuGet Package Provider version $latestNuGetVersion to current session." + $Null = Import-PackageProvider -Name NuGet -RequiredVersion $latestNuGetVersion -Force +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 10 -CurrentOperation "Ensuring Gallery $Gallery is trusted" + +# Fail if the given PSGallery is not Registered +$Policy = (Get-PSRepository $Gallery -ErrorAction Stop).InstallationPolicy +Set-PSRepository -Name $Gallery -InstallationPolicy Trusted -ErrorAction Ignore +try { + + Write-Progress -Activity "Bootstrap:" -PercentComplete 25 -CurrentOperation "Checking PowerShellGet" + # Ensure the module is loaded and retrieve the version you have + $PowerShellGetVersion = (Import-Module PowerShellGet -PassThru -ErrorAction SilentlyContinue).Version + + Write-Verbose "Bootstrap: The PowerShellGet version is $PowerShellGetVersion" + # Versions below 1.6.0 are considered old, unreliable & not recommended + if (!$PowerShellGetVersion -or ($PowerShellGetVersion -lt [System.version]'1.6.0' -and !$AllowOldPowerShellGetModule)) { + Write-Progress -Activity "Bootstrap:" -PercentComplete 40 -CurrentOperation "Installing newer version of PowerShellGet" + $InstallPSGetParam = @{ + Name = 'PowerShellGet' + Force = $True + SkipPublisherCheck = $true + AllowClobber = $true + Scope = $Scope + Repository = $Gallery + } + + switch ($PSBoundParameters.Keys) { + 'Proxy' { + $InstallPSGetParam.Add('Proxy', $Proxy) + } + 'ProxyCredential' { + $InstallPSGetParam.Add('ProxyCredential', $ProxyCredential) + } + 'GalleryCredential' { + $InstallPSGetParam.Add('Credential', $GalleryCredential) + } + } + + Install-Module @InstallPSGetParam + Remove-Module PowerShellGet -force -ErrorAction SilentlyContinue + Import-Module PowerShellGet -Force + $NewLoadedVersion = (Get-Module PowerShellGet).Version.ToString() + Write-Information "Bootstrap: PowerShellGet version loaded is $NewLoadedVersion" + Write-Progress -Activity "Bootstrap:" -PercentComplete 60 -CurrentOperation "Installing newer version of PowerShellGet" + } + + # Try to import the PSDepend module from the available modules + try { + $ImportPSDependParam = @{ + Name = 'PSDepend' + ErrorAction = 'Stop' + Force = $true + } + + if ($MinimumPSDependVersion) { + $ImportPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + $null = Import-Module @ImportPSDependParam + } + catch { + # PSDepend module not found, installing or saving it + if ($PSDependTarget -in 'CurrentUser', 'AllUsers') { + Write-Debug "PSDepend module not found. Attempting to install from Gallery $Gallery" + Write-Warning "Installing PSDepend in $PSDependTarget Scope" + $InstallPSDependParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Force = $true + Scope = $PSDependTarget + SkipPublisherCheck = $true + AllowClobber = $true + } + + if ($MinimumPSDependVersion) { + $InstallPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Installing PSDepend from $Gallery" + Install-Module @InstallPSDependParam + } + else { + Write-Debug "PSDepend module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Path = $PSDependTarget + } + + if ($MinimumPSDependVersion) { + $SaveModuleParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Saving & Importing PSDepend from $Gallery to $Scope" + Save-Module @SaveModuleParam + } + } + finally { + Write-Progress -Activity "Bootstrap:" -PercentComplete 100 -CurrentOperation "Loading PSDepend" + # We should have successfully bootstrapped PSDepend. Fail if not available + Import-Module PSDepend -ErrorAction Stop + } + + if ($WithYAML) { + if (-Not (Get-Module -ListAvailable -Name 'PowerShell-Yaml')) { + Write-Verbose "PowerShell-Yaml module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PowerShell-Yaml' + Repository = $Gallery + Path = $PSDependTarget + } + + Save-Module @SaveModuleParam + Import-Module "PowerShell-Yaml" -ErrorAction Stop + } + else { + Write-Verbose "PowerShell-Yaml is already available" + } + } + + Write-Progress -Activity "PSDepend:" -PercentComplete 0 -CurrentOperation "Restoring Build Dependencies" + if (Test-Path $DependencyFile) { + $PSDependParams = @{ + Force = $true + Path = $DependencyFile + } + + # TODO: Handle when the Dependency file is in YAML, and -WithYAML is specified + Invoke-PSDepend @PSDependParams + } + Write-Progress -Activity "PSDepend:" -PercentComplete 100 -CurrentOperation "Dependencies restored" -Completed +} +finally { + # Reverting the Installation Policy for the given gallery + Set-PSRepository -Name $Gallery -InstallationPolicy $Policy + Write-Verbose "Project Bootstrapped, returning to Invoke-Build" +} diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 new file mode 100644 index 0000000..d193a17 --- /dev/null +++ b/Resolve-Dependency.psd1 @@ -0,0 +1,10 @@ +@{ # Defaults Parameter value to be loaded by the Resolve-Dependency command (unless set in Bound Parameters) + #PSDependTarget = './output/modules' + #Proxy = '' + #ProxyCredential = '$MyCredentialVariable' #TODO: find a way to support credentials in build (resolve variable) + Gallery = 'PSGallery' + # AllowOldPowerShellGetModule = $true + #MinimumPSDependVersion = '0.3.0' + AllowPrerelease = $false + WithYAML = $true # Will also bootstrap PowerShell-Yaml to read other config files +} diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 86055fa..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,42 +0,0 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# - -version: 1.3.{build}.0 -environment: - gallery_api: - secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv - -install: - - git clone https://github.com/PowerShell/DscResource.Tests - - ps: Write-Verbose -Message "PowerShell version $($PSVersionTable.PSVersion)" -Verbose - - ps: Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - - ps: Invoke-AppveyorInstallTask - -#---------------------------------# -# build configuration # -#---------------------------------# - -build: false - -#---------------------------------# -# test configuration # -#---------------------------------# - -test_script: - - ps: | - Invoke-AppveyorTestScriptTask -CodeCoverage -CodeCovIo - -# scripts to run before deployment -after_test: - - ps: | - Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorAfterTestTask - -#---------------------------------# -# deployment configuration # -#---------------------------------# - -deploy_script: - - ps: | - Invoke-AppVeyorDeployTask diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..9d7650d --- /dev/null +++ b/build.ps1 @@ -0,0 +1,266 @@ +<# + +.DESCRIPTION + Bootstrap and build script for PowerShell module pipeline + +#> +[CmdletBinding()] +param( + + [Parameter(Position = 0)] + [string[]]$Tasks = '.', + + [Parameter()] + [validateScript( + { Test-Path -Path $_ } + )] + $BuildConfig = './build.yaml', + + # A Specific folder to build the artefact into. + [Parameter()] + $OutputDirectory = 'output', + + # Can be a path (relative to $PSScriptRoot or absolute) to tell Resolve-Dependency & PSDepend where to save the required modules, + # or use CurrentUser, AllUsers to target where to install missing dependencies + # You can override the value for PSDepend in the Build.psd1 build manifest + # This defaults to $OutputDirectory/modules (by default: ./output/modules) + [Parameter()] + $RequiredModulesDirectory = $(Join-Path 'output' 'RequiredModules'), + + # Filter which tags to run when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [string[]] + [parameter()] + $PesterTag, + + # Filter which tags to exclude when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [string[]] + [parameter()] + $PesterExcludeTag, + + $CodeCoverageThreshold = 50, + + [Parameter()] + [Alias('bootstrap')] + [switch]$ResolveDependency, + + [parameter(DontShow)] + [AllowNull()] + $BuildInfo +) + +# The BEGIN block (at the end of this file) handles the Bootstrap of the Environment before Invoke-Build can run the tasks +# if the -ResolveDependency (aka Bootstrap) is specified, the modules are already available, and can be auto loaded + +Process { + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') { + # Only run the process block through InvokeBuild (Look at the Begin block at the bottom of this script) + return + } + + # Execute the Build Process from the .build.ps1 path. + Push-Location -Path $PSScriptRoot -StackName BeforeBuild + + try { + Write-Host -ForeGroundColor magenta "[build] Parsing defined tasks" + + # Load Default BuildInfo if not provided as parameter + if (!$PSBoundParameters.ContainsKey('BuildInfo')) { + try { + if (Test-Path $BuildConfig) { + $ConfigFile = (Get-Item -Path $BuildConfig) + Write-Host "[build] Loading Configuration from $ConfigFile" + $BuildInfo = switch -Regex ($ConfigFile.Extension) { + # Native Support for PSD1 + '\.psd1' { + Import-PowerShellDataFile -Path $BuildConfig + } + # Support for yaml when module PowerShell-Yaml is available + '\.[yaml|yml]' { + Import-Module -ErrorAction Stop -Name 'powershell-yaml' + ConvertFrom-Yaml -Yaml (Get-Content -Raw $ConfigFile) + } + # Native Support for JSON and JSONC (by Removing comments) + '\.[json|jsonc]' { + $JSONC = (Get-Content -Raw -Path $ConfigFile) + $JSON = $JSONC -replace '(?m)\s*//.*?$' -replace '(?ms)/\*.*?\*/' + # This should probably be converted to hashtable for splatting + $JSON | ConvertFrom-Json + } + default { + Write-Error "Extension '$_' not supported. using @{}" + @{ } + } + } + } + else { + Write-Host -Object "Configuration file $BuildConfig not found" -ForegroundColor Red + $BuildInfo = @{ } + } + } + catch { + Write-Host -Object "Error loading data from $ConfigFile" -ForegroundColor Red + $BuildInfo = @{ } + Write-Error $_.Exception.Message + } + } + + # If the Invoke-Build Task Header is specified in the Build Info, set it + if ($BuildInfo.TaskHeader) { + Set-BuildHeader ([scriptblock]::Create($BuildInfo.TaskHeader)) + } + + # Import Tasks from modules via their exported aliases when defined in BUild Manifest + # https://github.com/nightroman/Invoke-Build/tree/master/Tasks/Import#example-2-import-from-a-module-with-tasks + if ($BuildInfo.containsKey('ModuleBuildTasks')) { + foreach ($Module in $BuildInfo['ModuleBuildTasks'].Keys) { + try { + $LoadedModule = Import-Module $Module -PassThru -ErrorAction Stop + foreach ($TaskToExport in $BuildInfo['ModuleBuildTasks'].($Module)) { + $LoadedModule.ExportedAliases.GetEnumerator().Where{ + # using -like to support wildcard + Write-Host -ForegroundColor DarkGray "`t Loading $($_.Key)..." + $_.Key -like $TaskToExport + }.ForEach{ + # Dot sourcing the Tasks via their exported aliases + . (get-alias $_.Key) + } + } + } + catch { + Write-Host -ForegroundColor Red -Object "Could not load tasks for module $Module." + Write-Error $_ + } + } + } + + # Loading Build Tasks defined in the .build/ folder (will override the ones imported above if same task name) + Get-ChildItem -Path ".build/" -Recurse -Include *.ps1 -ErrorAction Ignore | Foreach-Object { + "Importing file $($_.BaseName)" | Write-Verbose + . $_.FullName + } + + # Synopsis: Empty task, useful to test the bootstrap process + task noop { } + + # Define default task sequence ("."), can be overridden in the $BuildInfo + task . { + Write-Build Yellow "No sequence currently defined for the default task" + } + + # Load Invoke-Build task sequences/workflows from $BuildInfo + foreach ($Workflow in $BuildInfo.BuildWorkflow.keys) { + Write-Verbose "Creating Build Workflow '$Workflow' with tasks $($BuildInfo.BuildWorkflow.($Workflow) -join ', ')" + $WorkflowItem = $BuildInfo.BuildWorkflow.($Workflow) + if ($WorkflowItem.Trim() -match '^\{(?[\w\W]*)\}$') { + $WorkflowItem = [ScriptBlock]::Create($Matches['sb']) + } + Write-Host -ForegroundColor DarkGray "Adding $Workflow" + task $Workflow $WorkflowItem + } + + Write-Host -ForeGroundColor magenta "[build] Executing requested workflow: $($Tasks -join ', ')" + + } + finally { + Pop-Location -StackName BeforeBuild + } +} + +Begin { + # Bootstrapping the environment before using Invoke-Build as task runner + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') { + Write-Host -foregroundColor Green "[pre-build] Starting Build Init" + Push-Location $PSScriptRoot -StackName BuildModule + } + + if ($RequiredModulesDirectory -in @('CurrentUser', 'AllUsers')) { + # Installing modules instead of saving them + Write-Host -foregroundColor Green "[pre-build] Required Modules will be installed for $RequiredModulesDirectory, not saved." + # Tell Resolve-Dependency to use provided scope as the -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesDirectory + } + else { + if (-Not (Split-Path -IsAbsolute -Path $OutputDirectory)) { + $OutputDirectory = Join-Path -Path $PSScriptRoot -ChildPath $OutputDirectory + } + + # Resolving the absolute path to save the required modules to + if (-Not (Split-Path -IsAbsolute -Path $RequiredModulesDirectory)) { + $RequiredModulesDirectory = Join-Path -Path $PSScriptRoot -ChildPath $RequiredModulesDirectory + } + + # Create the output/modules folder if not exists, or resolve the Absolute path otherwise + if (Resolve-Path $RequiredModulesDirectory -ErrorAction SilentlyContinue) { + Write-Debug "[pre-build] Required Modules path already exist at $RequiredModulesDirectory" + $RequiredModulesPath = Convert-Path $RequiredModulesDirectory + } + else { + Write-Host -foregroundColor Green "[pre-build] Creating required modules directory $RequiredModulesDirectory." + $RequiredModulesPath = (New-Item -ItemType Directory -Force -Path $RequiredModulesDirectory).FullName + } + + # Prepending $RequiredModulesPath folder to PSModulePath to resolve from this folder FIRST + if ($RequiredModulesDirectory -notIn @('CurrentUser', 'AllUsers') -and + (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $RequiredModulesDirectory)) { + Write-Host -foregroundColor Green "[pre-build] Prepending '$RequiredModulesDirectory' folder to PSModulePath" + $Env:PSModulePath = $RequiredModulesDirectory + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Prepending $OutputDirectory folder to PSModulePath to resolve built module from this folder + if (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $OutputDirectory) { + Write-Host -foregroundColor Green "[pre-build] Prepending '$OutputDirectory' folder to PSModulePath" + $Env:PSModulePath = $OutputDirectory + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Tell Resolve-Dependency to use $RequiredModulesPath as -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesPath + } + + if ($ResolveDependency) { + Write-Host -Object "[pre-build] Resolving dependencies." -foregroundColor Green + $ResolveDependencyParams = @{ } + + # If BuildConfig is a Yaml file, bootstrap powershell-yaml via ResolveDependency + if ($BuildConfig -match '\.[yaml|yml]$') { + $ResolveDependencyParams.add('WithYaml', $True) + } + + # TODO: 3 way merge: BoundParameter over BuildInfo over Scope variables (i.e. defaults from args) + $ResolveDependencyAvailableParams = (get-command -Name '.\Resolve-Dependency.ps1').parameters.keys + foreach ($CmdParameter in $ResolveDependencyAvailableParams) { + + # The parameter has been explicitly used for calling the .build.ps1 + if ($MyInvocation.BoundParameters.ContainsKey($CmdParameter)) { + $ParamValue = $MyInvocation.BoundParameters.ContainsKey($CmdParameter) + Write-Debug " adding $CmdParameter :: $ParamValue [from user-provided parameters to Build.ps1]" + $ResolveDependencyParams.Add($CmdParameter, $ParamValue) + } + # Use defaults parameter value from Build.ps1, if any + else { + if ($ParamValue = Get-Variable -Name $CmdParameter -ValueOnly -ErrorAction Ignore) { + Write-Debug " adding $CmdParameter :: $ParamValue [from default Build.ps1 variable]" + $ResolveDependencyParams.add($CmdParameter, $ParamValue) + } + } + } + + Write-Host -foregroundColor Green "[pre-build] Starting bootstrap process." + .\Resolve-Dependency.ps1 @ResolveDependencyParams + } + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') { + Write-Verbose "Bootstrap completed. Handing back to InvokeBuild." + if ($PSBoundParameters.ContainsKey('ResolveDependency')) { + Write-Verbose "Dependency already resolved. Removing task" + $null = $PSBoundParameters.Remove('ResolveDependency') + } + Write-Host -foregroundColor Green "[build] Starting build with InvokeBuild." + Invoke-Build @PSBoundParameters -Task $Tasks -File $MyInvocation.MyCommand.Path + Pop-Location -StackName BuildModule + return + } +} diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..012c0a9 --- /dev/null +++ b/build.yaml @@ -0,0 +1,112 @@ +--- +#################################################### +# ModuleBuilder Configuration # +#################################################### +# Path to the Module Manifest to build (where path will be resolved from) +# SourcePath: ./Sampler/Sampler.psd1 +# Output Directory where ModuleBuilder will build the Module, relative to module manifest +# OutputDirectory: ../output/Sampler +CopyDirectories: + - en-US +# SemVer: '1.2.3' +# Suffix to add to Root module PSM1 after merge (here, the Set-Alias exporting IB tasks) +# suffix: suffix.ps1 +VersionedOutputDirectory: true + +#################################################### +# ModuleBuilder Submodules Configuration # +#################################################### + +# NestedModule: +# HelperSubmodule: # This is the first submodule to build into the output +# Path: ./Sampler/Modules/HelperSubmodule/HelperSubmodule.psd1 +# # $ModuleVersionFolder is trimmed (remove -.*) and OutputDirectory expanded (the only one) +# OutputDirectory: ./output/Sampler/$ModuleVersionFolder/Modules/HelperSubmodule +# VersionedOutputDirectory: false +# # suffix: +# # prefix: + + +#################################################### +# Sampler Pipeline Configuration # +#################################################### +# Defining 'Workflows' (suite of InvkeBuild tasks) to be run using their alias +BuildWorkflow: + '.': # "." is the default Invoke-Build workflow. It is called when no -Tasks is specified to the build.ps1 + - build + - test + + build: + - Clean + - Build_Module_ModuleBuilder + - Build_NestedModules_ModuleBuilder + - Create_changelog_release_output + + pack: + - package_module_nupkg + + # defining test task to be run when invoking `./build.ps1 -Tasks test` + test: + - Pester_Tests_Stop_On_Fail + - Pester_if_Code_Coverage_Under_Threshold + + publish: + - Publish_release_to_GitHub + - publish_module_to_gallery # runs if nuget is not available + + +#################################################### +# PESTER Configuration # +#################################################### + +Pester: #Passthru, OutputFile, CodeCoverageOutputFile not supported + OutputFormat: NUnitXML + # Will look at every *.ps1 & *.psm1 under ModulePath, excepts when $_.FullName -match (Join-Path $ProjectPath $ExcludeFromCodeCoverageItem) + ExcludeFromCodeCoverage: + - tasks + - Template + # Default is to use the tests folder in the project folder or source folder (if present) + # can use it to prioritize: tests/QA, tests/Unit, tests/Integration + Script: + # - tests/QA/module.tests.ps1 + # - tests/QA + # - tests/Unit + # - tests/Integration + ExcludeTag: + Tag: + CodeCoverageThreshold: 50 # Set to 0 to bypass + + +Resolve-Dependency: #Parameters for Resolve-Dependency + #PSDependTarget: ./output/modules + #Proxy: '' + #ProxyCredential: + Gallery: 'PSGallery' + # AllowOldPowerShellGetModule: true + #MinimumPSDependVersion = '0.3.0' + AllowPrerelease: false + Verbose: false + +ModuleBuildTasks: + # - ModuleName: 'alias to search' + Sampler: + - '*.build.Sampler.ib.tasks' # this means: import (dot source) all aliases ending with .ib.tasks exported by sampler module + +# Invoke-Build Header to be used to 'decorate' the terminal output of the tasks. +TaskHeader: | + param($Path) + "" + "=" * 79 + Write-Build Cyan "`t`t`t$($Task.Name.replace("_"," ").ToUpper())" + Write-Build DarkGray "$(Get-BuildSynopsis $Task)" + "-" * 79 + Write-Build DarkGray " $Path" + Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)" + "" + +GitHubConfig: + GitHubFilesToAdd: + - 'CHANGELOG.md' + GitHubConfigUserName: gaelcolas + GitHubConfigUserEmail: gaelcolas@synedgy.com + UpdateChangelogOnPrerelease: false diff --git a/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 b/source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 similarity index 100% rename from DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 rename to source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 diff --git a/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.schema.mof b/source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.schema.mof similarity index 100% rename from DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.schema.mof rename to source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.schema.mof diff --git a/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 b/source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 similarity index 100% rename from DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 rename to source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 diff --git a/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.schema.mof b/source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.schema.mof similarity index 100% rename from DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.schema.mof rename to source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.schema.mof diff --git a/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 b/source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 similarity index 100% rename from DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 rename to source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 diff --git a/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof b/source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof similarity index 100% rename from DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof rename to source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof diff --git a/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 b/source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 similarity index 100% rename from DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 rename to source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 diff --git a/DSCResources/MSFT_xRDServer/MSFT_xRDServer.schema.mof b/source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.schema.mof similarity index 100% rename from DSCResources/MSFT_xRDServer/MSFT_xRDServer.schema.mof rename to source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.schema.mof diff --git a/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 b/source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 similarity index 100% rename from DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 rename to source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 diff --git a/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.schema.mof b/source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.schema.mof similarity index 100% rename from DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.schema.mof rename to source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.schema.mof diff --git a/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 b/source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 similarity index 100% rename from DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 rename to source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 diff --git a/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.schema.mof b/source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.schema.mof similarity index 100% rename from DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.schema.mof rename to source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.schema.mof diff --git a/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 b/source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 similarity index 100% rename from DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 rename to source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 diff --git a/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.schema.mof b/source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.schema.mof similarity index 100% rename from DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.schema.mof rename to source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.schema.mof diff --git a/xRemoteDesktopSessionHostCommon.psm1 b/source/Modules/xRemoteDesktopSessionHostCommon.psm1 similarity index 100% rename from xRemoteDesktopSessionHostCommon.psm1 rename to source/Modules/xRemoteDesktopSessionHostCommon.psm1 diff --git a/source/build.psd1 b/source/build.psd1 new file mode 100644 index 0000000..05afd40 --- /dev/null +++ b/source/build.psd1 @@ -0,0 +1,6 @@ +@{ + Path = 'xRemoteDesktopSessionHost.psd1' #or build breaks on Linux +} +# Waiting for ModuleBuilder to do away with this file +# when all parameters are provided to the function + diff --git a/source/en-US/about_xRemoteDesktopSessionHost.help.txt b/source/en-US/about_xRemoteDesktopSessionHost.help.txt new file mode 100644 index 0000000..f7aea54 --- /dev/null +++ b/source/en-US/about_xRemoteDesktopSessionHost.help.txt @@ -0,0 +1,26 @@ +TOPIC + about_xRemoteDesktopSessionHost + +SHORT DESCRIPTION + DSC resources to manage Remote Desktop Services Hosts + +LONG DESCRIPTION + This module is meant to enable DSC configured RDSH (Remote Desktop Session Hosts). + It allows for setting up a connection broker, configuring licensing and deployment + of remote applications. + +EXAMPLES + See the examples in the Examples folder. + +NOTE: + Thank you to all those who contributed to this module, by writing code, sharing opinions, and provided feedback. + +TROUBLESHOOTING NOTE: + Look out on the Github repository for issues and new releases. + +SEE ALSO + - https://github.com/dsccommunity/xRemoteDesktopSessionHost + +KEYWORDS + DSC, RDS, RDSH, RemoteDesktop + diff --git a/xRemoteDesktopSessionHost.psd1 b/source/xRemoteDesktopSessionHost.psd1 similarity index 52% rename from xRemoteDesktopSessionHost.psd1 rename to source/xRemoteDesktopSessionHost.psd1 index 90d5edd..cc47016 100644 --- a/xRemoteDesktopSessionHost.psd1 +++ b/source/xRemoteDesktopSessionHost.psd1 @@ -1,18 +1,18 @@ @{ -# Version number of this module. -moduleVersion = '1.9.0.0' +# Version number of this module. This is controlled by gitversion. +moduleVersion = '0.0.1' # ID used to uniquely identify this module GUID = 'b42ff085-bd2b-4232-90ba-02b4c780e2d9' # Author of this module -Author = 'Microsoft Corporation' +Author = 'DSC Community' # Company or vendor of this module -CompanyName = 'Microsoft Corporation' +CompanyName = 'DSC Community' # Copyright statement for this module -Copyright = '(c) 2014 Microsoft Corporation. All rights reserved.' +Copyright = 'Copyright the DSC Community contributors. All rights reserved.' # Description of the functionality provided by this module Description = 'Module with DSC Resources for Remote Desktop Session Host' @@ -24,10 +24,10 @@ PowerShellVersion = '4.0' CLRVersion = '4.0' # Functions to export from this module -FunctionsToExport = '*' +FunctionsToExport = @() # Cmdlets to export from this module -CmdletsToExport = '*' +CmdletsToExport = @() RootModule = 'xRemoteDesktopSessionHostCommon.psm1' @@ -39,32 +39,22 @@ PrivateData = @{ # Tags applied to this module. These help with module discovery in online galleries. Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') + IconUri = 'https://dsccommunity.org/images/DSC_Logo_300p.png' + # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/xRemoteDesktopSessionHost/blob/master/LICENSE' + LicenseUri = 'https://github.com/dsccommunity/xRemoteDesktopSessionHost/blob/master/LICENSE' + + # Set to a prerelease string value if the release should be a prerelease. + Prerelease = '' # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShell/xRemoteDesktopSessionHost' + ProjectUri = 'https://github.com/dsccommunity/xRemoteDesktopSessionHost' # A URL to an icon representing this module. # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = '* Changes to xRDRemoteApp - * Fixing typo in parameter name when calling the function ValidateCustomModeParameters (issue 50). -* Changes to xRDSessionDeployment - * When RDMS service does not exist the Get-TargetResource will no longer throw an error (issue 47). -* Rename Tests/Unit folder to use upper case on first letter. -* Update appveyor.yml to use the default template. -* Added default template files .codecov.yml, .gitattributes, and .gitignore, and - .vscode folder. -* xRDSessionCollectionConfiguration: - * Changed CollectionName variable validation max length to 256 -* xRDSessionCollection - * Changed CollectionName variable validation max length to 256 -* xRDRemoteApp - * Changed CollectionName variable validation max length to 256 - -' + ReleaseNotes = '' } # End of PSData hashtable diff --git a/Tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 b/tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 rename to tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 diff --git a/Tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 b/tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 rename to tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 diff --git a/Tests/Unit/MSFT_xRDRemoteApp.tests.ps1 b/tests/Unit/MSFT_xRDRemoteApp.tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_xRDRemoteApp.tests.ps1 rename to tests/Unit/MSFT_xRDRemoteApp.tests.ps1 diff --git a/Tests/Unit/MSFT_xRDServer.tests.ps1 b/tests/Unit/MSFT_xRDServer.tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_xRDServer.tests.ps1 rename to tests/Unit/MSFT_xRDServer.tests.ps1 diff --git a/Tests/Unit/MSFT_xRDSessionCollection.tests.ps1 b/tests/Unit/MSFT_xRDSessionCollection.tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_xRDSessionCollection.tests.ps1 rename to tests/Unit/MSFT_xRDSessionCollection.tests.ps1 diff --git a/Tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 b/tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 rename to tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 diff --git a/Tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 b/tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 rename to tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 diff --git a/Tests/Unit/xRemoteDesktopSessionHost.tests.ps1 b/tests/Unit/xRemoteDesktopSessionHost.tests.ps1 similarity index 100% rename from Tests/Unit/xRemoteDesktopSessionHost.tests.ps1 rename to tests/Unit/xRemoteDesktopSessionHost.tests.ps1