diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index ccff2b02b..c97a23c54 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -331,6 +331,20 @@ function Get-DotNetCoreSdkVersions { return $dotNetCoreSdkVersion } +function Get-DotnetTools { + $env:PATH = "/etc/skel/.dotnet/tools:$($env:PATH)" + + $dotnetTools = (Get-ToolsetContent).dotnet.tools + + $toolsList = @() + + ForEach ($dotnetTool in $dotnetTools) { + $toolsList += $dotnetTool.name + " " + (Invoke-Expression $dotnetTool.getversion) + } + + return $toolsList +} + function Get-CachedDockerImages { $toolsetJson = Get-ToolsetContent $images = $toolsetJson.docker.images diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 38452bfcf..3fac0b716 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -230,6 +230,10 @@ $markdown += New-MDList -Style Unordered -Lines @( (Get-DotNetCoreSdkVersions) ) +$markdown += New-MDHeader ".NET tools" -Level 3 +$tools = Get-DotnetTools +$markdown += New-MDList -Lines $tools -Style Unordered + $markdown += New-MDHeader "Databases" -Level 3 $markdown += New-MDList -Style Unordered -Lines (@( (Get-PostgreSqlVersion), diff --git a/images/linux/scripts/installers/dotnetcore-sdk.sh b/images/linux/scripts/installers/dotnetcore-sdk.sh index bcbcde99c..69af71797 100644 --- a/images/linux/scripts/installers/dotnetcore-sdk.sh +++ b/images/linux/scripts/installers/dotnetcore-sdk.sh @@ -11,6 +11,7 @@ source $HELPER_SCRIPTS/os.sh # Ubuntu 20 doesn't support EOL versions LATEST_DOTNET_PACKAGES=$(get_toolset_value '.dotnet.aptPackages[]') DOTNET_VERSIONS=$(get_toolset_value '.dotnet.versions[]') +DOTNET_TOOLS=$(get_toolset_value '.dotnet.tools[].name') # Disable telemetry export DOTNET_CLI_TELEMETRY_OPTOUT=1 @@ -67,4 +68,10 @@ setEtcEnvironmentVariable DOTNET_NOLOGO 1 setEtcEnvironmentVariable DOTNET_MULTILEVEL_LOOKUP 0 prependEtcEnvironmentPath '$HOME/.dotnet/tools' +# install dotnet tools +for dotnet_tool in ${DOTNET_TOOLS[@]}; do + echo "Installing dotnet tool $dotnet_tool" + dotnet tool install $dotnet_tool --tool-path '/etc/skel/.dotnet/tools' +done + invoke_tests "DotnetSDK" diff --git a/images/linux/scripts/tests/DotnetSDK.Tests.ps1 b/images/linux/scripts/tests/DotnetSDK.Tests.ps1 index 61eb7bf94..d2d90dadd 100644 --- a/images/linux/scripts/tests/DotnetSDK.Tests.ps1 +++ b/images/linux/scripts/tests/DotnetSDK.Tests.ps1 @@ -1,8 +1,9 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -Describe "Dotnet" { +Describe "Dotnet and tools" { BeforeAll { + $env:PATH = "/etc/skel/.dotnet/tools:$($env:PATH)" $dotnetSDKs = dotnet --list-sdks | ConvertTo-Json $dotnetRuntimes = dotnet --list-runtimes | ConvertTo-Json } @@ -28,4 +29,14 @@ Describe "Dotnet" { } } } + + Context "Dotnet tools" { + $dotnetTools = (Get-ToolsetContent).dotnet.tools + $testCases = $dotnetTools | ForEach-Object { @{ ToolName = $_.name; TestInstance = $_.test }} + + It " is available" -TestCases $testCases { + "$TestInstance" | Should -ReturnZeroExitCode + } + } + } \ No newline at end of file diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 1f4915c8c..c91e95ae3 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -254,6 +254,9 @@ "2.1", "3.1", "5.0" + ], + "tools": [ + { "name": "nbgv", "test": "nbgv --version", "getversion" : "nbgv --version" } ] }, "clang": { diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 0947c7cf7..c2b212ed2 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -254,6 +254,9 @@ "2.1", "3.1", "5.0" + ], + "tools": [ + { "name": "nbgv", "test": "nbgv --version", "getversion" : "nbgv --version" } ] }, "clang": { diff --git a/images/win/scripts/Installers/Install-DotnetSDK.ps1 b/images/win/scripts/Installers/Install-DotnetSDK.ps1 index 1b802e24f..6a4ced456 100644 --- a/images/win/scripts/Installers/Install-DotnetSDK.ps1 +++ b/images/win/scripts/Installers/Install-DotnetSDK.ps1 @@ -108,6 +108,16 @@ function InstallAllValidSdks() } } +function InstallTools() +{ + $dotnetTools = (Get-ToolsetContent).dotnet.tools + + ForEach ($dotnetTool in $dotnetTools) + { + dotnet tool install $($dotnetTool.name) --tool-path "C:\Users\Default.dotnet\tools" --add-source https://api.nuget.org/v3/index.json | Out-Null + } +} + function RunPostInstallationSteps() { # Add dotnet to PATH @@ -129,5 +139,6 @@ function RunPostInstallationSteps() InstallAllValidSdks RunPostInstallationSteps +InstallTools Invoke-PesterTests -TestFile "DotnetSDK" \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 68b838640..172244c4b 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -200,6 +200,18 @@ function Get-DotnetSdks { } } +function Get-DotnetTools { + $env:Path += ";C:\Users\Default.dotnet\tools" + $dotnetTools = (Get-ToolsetContent).dotnet.tools + + $toolsList = @() + + foreach ($dotnetTool in $dotnetTools) { + $toolsList += $dotnetTool.name + " " + (Invoke-Expression $dotnetTool.getversion) + } + return $toolsList +} + function Get-DotnetRuntimes { $runtimesRawList = dotnet --list-runtimes $runtimesRawList | Group-Object {$_.Split()[0]} | ForEach-Object { diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 1e0d7abf4..2f9d0f65e 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -261,6 +261,10 @@ $markdown += "``Location $($frameworks.Path)``" $markdown += New-MDNewLine $markdown += New-MDList -Lines $frameworks.Versions -Style Unordered +$markdown += New-MDHeader ".NET tools" -Level 3 +$tools = Get-DotnetTools +$markdown += New-MDList -Lines $tools -Style Unordered + # PowerShell Tools $markdown += New-MDHeader "PowerShell Tools" -Level 3 $markdown += New-MDList -Lines (Get-PowershellCoreVersion) -Style Unordered diff --git a/images/win/scripts/Tests/DotnetSDK.Tests.ps1 b/images/win/scripts/Tests/DotnetSDK.Tests.ps1 index 903be2870..3ad3e7420 100644 --- a/images/win/scripts/Tests/DotnetSDK.Tests.ps1 +++ b/images/win/scripts/Tests/DotnetSDK.Tests.ps1 @@ -1,6 +1,7 @@ $dotnetVersions = (Get-ToolsetContent).dotnet.versions +$dotnetTools = (Get-ToolsetContent).dotnet.tools -Describe "Dotnet SDK" { +Describe "Dotnet SDK and tools" { Context "Default" { It "Default Dotnet SDK is available" { @@ -21,4 +22,13 @@ Describe "Dotnet SDK" { } } } -} \ No newline at end of file + + Context "Dotnet tools" { + $env:Path += ";C:\Users\Default.dotnet\tools" + $testCases = $dotnetTools | ForEach-Object { @{ ToolName = $_.name; TestInstance = $_.test }} + + It " is available" -TestCases $testCases { + "$TestInstance" | Should -ReturnZeroExitCode + } + } +} diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index a1b063d7d..0a35fcfc1 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -387,6 +387,9 @@ "3.1", "5.0" ], + "tools": [ + { "name": "nbgv", "test": "nbgv --version", "getversion": "nbgv --version" } + ], "warmup": true }, "choco": { diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index d87af251c..fd0681769 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -422,6 +422,9 @@ "3.1", "5.0" ], + "tools": [ + { "name": "nbgv", "test": "nbgv --version", "getversion": "nbgv --version" } + ], "warmup": true }, "choco": { diff --git a/images/win/toolsets/toolset-2022.json b/images/win/toolsets/toolset-2022.json index c0ad5f95f..1a73b3f7c 100644 --- a/images/win/toolsets/toolset-2022.json +++ b/images/win/toolsets/toolset-2022.json @@ -283,6 +283,9 @@ "3.1", "5.0" ], + "tools": [ + { "name": "nbgv", "test": "nbgv --version", "getversion": "nbgv --version" } + ], "warmup": false }, "choco": {