From 2bc02bd9234e29dd6a6962d9224c9f034da629c0 Mon Sep 17 00:00:00 2001 From: Gijs Reijn Date: Wed, 13 Nov 2024 20:09:53 +0100 Subject: [PATCH 1/3] Removed unit test for prerelease version and VSCode temp folder --- .../Microsoft.Dotnet.Dsc/DotNetToolPackage.md | 17 +++++++++-------- .../Microsoft.DotNet.Dsc.psm1 | 1 + .../Microsoft.VSCode.Dsc.psm1 | 4 ++-- .../Microsoft.DotNet.Dsc.Tests.ps1 | 13 ------------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/resources/Help/Microsoft.Dotnet.Dsc/DotNetToolPackage.md b/resources/Help/Microsoft.Dotnet.Dsc/DotNetToolPackage.md index a84bcc70..d9e5d5e5 100644 --- a/resources/Help/Microsoft.Dotnet.Dsc/DotNetToolPackage.md +++ b/resources/Help/Microsoft.Dotnet.Dsc/DotNetToolPackage.md @@ -19,14 +19,14 @@ The `DotNetToolPackage` DSC Resource allows you to install, update, and uninstal ## PARAMETERS -| **Parameter** | **Attribute** | **DataType** | **Description** | **Allowed Values** | -| ------------------- | ------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | -| `PackageId` | Key | String | The ID of the .NET tool package to manage. | N/A | -| `Version` | Optional | String | The version of the .NET tool package to install. If not specified, the latest version will be installed. | N/A | -| `Commands` | Optional | String[] | An array of commands provided by the .NET tool package. | N/A | -| `Prerelease` | Optional | Boolean | Indicates whether to include prerelease versions of the .NET tool package. The default value is `$false`. | `$true`, `$false` | -| `ToolPathDirectory` | Optional | String | The directory where the .NET tool package will be installed. If not specified, the package will be installed globally. | Use custom directory when you have | -| `Exist` | Optional | Boolean | Indicates whether the package should exist. Defaults to `$true`. | `$true` or `$false` | +| **Parameter** | **Attribute** | **DataType** | **Description** | **Allowed Values** | +| ------------------- | ------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | +| `PackageId` | Key | String | The ID of the .NET tool package to manage. | N/A | +| `Version` | Optional | String | The version of the .NET tool package to install. If not specified, the latest version will be installed. | N/A | +| `Commands` | Optional | String[] | An array of commands provided by the .NET tool package. | N/A | +| `Prerelease` | Optional | Boolean | Indicates whether to include prerelease versions of the .NET tool package. The default value is `$false`. Note: If the prerelease version is lower than the current version, the highest version will be installed. | `$true`, `$false` | +| `ToolPathDirectory` | Optional | String | The directory where the .NET tool package will be installed. If not specified, the package will be installed globally. | Use custom directory when you have | +| `Exist` | Optional | Boolean | Indicates whether the package should exist. Defaults to `$true`. | `$true` or `$false` | ## EXAMPLES @@ -59,4 +59,5 @@ Invoke-DscResource -ModuleName Microsoft.DotNet.Dsc -Name DotNetToolPackage -Met } # This example installs the prerelease version of the .NET tool package 'PowerShell' in the 'C:\tools' directory. +# NOTE: When the version in the feed is for example v7.4.5-preview1 and the highest is v7.4.6, the highest will be installed. ``` diff --git a/resources/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.psm1 b/resources/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.psm1 index e79c6642..a99d9b6c 100644 --- a/resources/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.psm1 +++ b/resources/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.psm1 @@ -336,6 +336,7 @@ $DotNetCliPath = Get-DotNetPath } This example installs the prerelease version of the .NET tool package 'PowerShell' in the 'C:\tools' directory. + NOTE: When the version in the feed is for example v7.4.5-preview1 and the highest is v7.4.6, the highest will be installed. #> [DSCResource()] class DotNetToolPackage { diff --git a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 index 77a52b93..b097cd39 100644 --- a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 +++ b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 @@ -95,8 +95,8 @@ function Invoke-VSCode { [string]$Command ) - $stdErrTempFile = "$env:TEMP\$((New-Guid).Guid)" - $stdOutTempFile = "$env:TEMP\$((New-Guid).Guid)" + $stdErrTempFile = [System.IO.Path]::GetTempPath() + (New-Guid).Guid + $stdOutTempFile = [System.IO.Path]::GetTempPath() + (New-Guid).Guid $invocationSuccess = $true $processParams = @{ diff --git a/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 b/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 index 620dea67..8ce1bc36 100644 --- a/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 +++ b/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 @@ -43,19 +43,6 @@ Describe 'DSC operation capabilities' { $finalState.Version | Should -Not -BeNullOrEmpty } - It 'Sets desired package with prerelease' -Skip:(!$IsWindows) { - $parameters = @{ - PackageId = 'dotnet-ef' - PreRelease = $true - } - - Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters - - $finalState = Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Get -Property $parameters - $finalState.PackageId | Should -Be $parameters.PackageId - $finalState.PreRelease | Should -BeTrue - } - It 'Sets desired package with version' -Skip:(!$IsWindows) { $parameters = @{ PackageId = 'dotnet-reportgenerator-globaltool' From 04f6db267febbfd289ee7bf087a64ca4a3d799ab Mon Sep 17 00:00:00 2001 From: Gijs Reijn Date: Wed, 13 Nov 2024 21:47:35 +0100 Subject: [PATCH 2/3] Remarks Ryan --- resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 index b097cd39..c05fe6da 100644 --- a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 +++ b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 @@ -95,8 +95,8 @@ function Invoke-VSCode { [string]$Command ) - $stdErrTempFile = [System.IO.Path]::GetTempPath() + (New-Guid).Guid - $stdOutTempFile = [System.IO.Path]::GetTempPath() + (New-Guid).Guid + $stdErrTempFile = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath (New-Guid).Guid + $stdOutTempFile = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath (New-Guid).Guid $invocationSuccess = $true $processParams = @{ From f34d78d960d466dc16394dc214811281b7236183 Mon Sep 17 00:00:00 2001 From: Gijs Reijn Date: Thu, 14 Nov 2024 05:05:59 +0100 Subject: [PATCH 3/3] Fix test that I did not see --- tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 b/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 index 8ce1bc36..4b60c6c8 100644 --- a/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 +++ b/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 @@ -86,7 +86,7 @@ Describe 'DSC operation capabilities' { It 'Exports resources' -Skip:(!$IsWindows) { $obj = [DotNetToolPackage]::Export() - $obj.PackageId.Contains('dotnet-ef') | Should -Be $true + $obj.PackageId.Contains('gitversion.tool') | Should -Be $true $obj.PackageId.Contains('dotnet-reportgenerator-globaltool') | Should -Be $true }