Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ TestsResults*.xml
PowerShell.sln.DotSettings.user
*.msp
StyleCop.Cache

src/Modules
!src/Modules/Microsoft.AzureFunctions.PowerShellWorker
33 changes: 9 additions & 24 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ param(

$NeededTools = @{
DotnetSdk = ".NET SDK latest"
PowerShellGet = "PowerShellGet latest"
Pester = "Pester latest"
}

function needsDotnetSdk () {
Expand All @@ -33,34 +31,12 @@ function needsDotnetSdk () {
return $false
}

function needsPowerShellGet () {
$modules = Get-Module -ListAvailable -Name PowerShellGet | Where-Object Version -ge 1.6.0
if ($modules.Count -gt 0) {
return $false
}
return $true
}

function needsPester () {
$modules = Get-Module -ListAvailable -Name Pester
if ($modules.Count -gt 0) {
return $false
}
return $true
}

function getMissingTools () {
$missingTools = @()

if (needsDotnetSdk) {
$missingTools += $NeededTools.DotnetSdk
}
if (needsPowerShellGet) {
$missingTools += $NeededTools.PowerShellGet
}
if (needsPester) {
$missingTools += $NeededTools.Pester
}

return $missingTools
}
Expand All @@ -87,8 +63,17 @@ if($Clean) {
}

# Build step

# Install using PSDepend if it's available, otherwise use the backup script
if ((Get-Module -ListAvailable -Name PSDepend).Count -gt 0) {
Invoke-PSDepend -Force
} else {
& "$PSScriptRoot/tools/InstallDependencies.ps1"
}

dotnet build -c $Configuration
dotnet publish -c $Configuration

Push-Location package
dotnet pack -c $Configuration
Pop-Location
Expand Down
21 changes: 21 additions & 0 deletions requirements.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@{
# Packaged with the PowerShell Language Worker
'PowerShellGet' = @{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this file in the tools folder? I guess we can call Invoke-PSDepend "$PSScriptRoot/tools/requirements.psd1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We synced offline and think it should go in src

Version = '1.6.7'
Target = 'src/Modules'
}
'Microsoft.PowerShell.Archive' = @{
Version = '1.1.0.0'
Target = 'src/Modules'
}
'AzureRM' = @{
Version = '6.8.1'
Target = 'src/Modules'
}

# Dev dependencies
'Pester' = @{
Version = 'latest'
Target = 'CurrentUser'
}
}
26 changes: 26 additions & 0 deletions tools/InstallDependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#

$dependencies = Import-PowerShellDataFile "$PSScriptRoot/../requirements.psd1"

foreach ($key in $dependencies.Keys) {
$params = @{ Name = $key }

if ($dependencies[$key].Version -ne 'latest') {
$params.Version = $dependencies[$key].Version
}

if($dependencies[$key].Target -eq 'CurrentUser') {
$params.Scope = $dependencies[$key].Target
Install-Module @params
Comment thread
TylerLeonhardt marked this conversation as resolved.
Outdated
} else {
$params.Path = $dependencies[$key].Target
if (Test-Path $params.Path) {
Write-Host "'$key' - Module already installed"
} else {
Save-Module @params
}
}
}