Skip to content

Commit 195d63e

Browse files
committed
Work on dependecies update (#52)
1 parent 825bd7e commit 195d63e

File tree

2 files changed

+53
-46
lines changed

2 files changed

+53
-46
lines changed

appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ skip_branch_with_pr: true
1414

1515
test: off
1616

17-
pull_requests:
18-
do_not_increment_build_number: true
19-
2017
# Skipping commits affecting specific files
2118
skip_commits:
2219
files:
@@ -91,7 +88,6 @@ on_failure:
9188
& $env:APPVEYOR_BUILD_FOLDER\appveyor-discord.ps1 failure $env:APPVEYOR_DISCORD_WEBHOOK_URL
9289
9390
on_success:
94-
- dotnet tool install --global NuKeeper
9591
- ps: .\update-dependencies.ps1
9692

9793
cache:

update-dependencies.ps1

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ else
2323
"lib-Windows.Devices.Pwm",
2424
"lib-Windows.Devices.Spi",
2525
"lib-nanoFramework.Networking.Sntp",
26-
"lib-nanoFramework.Hardware.Stm32")
26+
"lib-nanoFramework.Hardware.Stm32",
27+
"lib-nanoFramework.System.Math")
2728

2829
ForEach($library in $librariesToUpdate)
2930
{
@@ -46,43 +47,40 @@ else
4647
# find solution file in repository
4748
$solutionFile = (Get-ChildItem -Path ".\" -Include "*.sln" -Recurse)
4849

49-
# run NuKeeper inspect
50-
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*')
51-
{
52-
# use NuGet ONLY for release and master branches
53-
$nukeeperInspect = NuKeeper inspect --source https://api.nuget.org/v3/index.json
54-
}
55-
else
56-
{
57-
# use NuGet and MyGet for all others
58-
$nukeeperInspect = NuKeeper inspect
59-
}
50+
# find packages.config
51+
$packagesConfig = (Get-ChildItem -Path ".\" -Include "packages.config" -Recurse)
6052

61-
"NuGet update inspection result:" | Write-Host -ForegroundColor Cyan
62-
$nukeeperInspect | Write-Host -ForegroundColor White
53+
# load packages.config as XML doc
54+
[xml]$packagesDoc = Get-Content $packagesConfig
6355

64-
$packageCountMatch = [regex]::Match($nukeeperInspect, "Found (\d) possible updates").captures.groups[1].value
65-
[int]$packageCount = 0
66-
[int]::TryParse($packageCountMatch, [ref]$packageCount)
56+
$nodes = $packagesDoc.SelectNodes("*").SelectNodes("*")
6757

68-
if ($packageCount -gt 0)
69-
{
70-
# get packages to update
71-
$packageListRaw = [regex]::Match($nukeeperInspect, "(?>possible updates([^$]*)Found)").captures.Groups[1].Value;
72-
[array]$packageList = $packageListRaw.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries).Replace([Environment]::NewLine, "")
58+
$packageList = @(,@())
7359

74-
# restore NuGet packages, need to do this before anything else
75-
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*')
76-
{
77-
# use NuGet ONLY for release and master branches
78-
nuget restore $solutionFile[0] -Source https://api.nuget.org/v3/index.json
79-
}
80-
else
60+
foreach ($node in $nodes)
61+
{
62+
# filter out NuProj packages
63+
if($node.id -notlike "NuProj*")
8164
{
82-
# use NuGet and MyGet for all others
83-
nuget restore $solutionFile[0] -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json
65+
if($packageList)
66+
{
67+
$packageList += , ($node.id, $node.version)
68+
}
69+
else
70+
{
71+
$packageList = , ($node.id, $node.version)
72+
}
8473
}
85-
74+
}
75+
76+
if ($packageList.length -gt 0)
77+
{
78+
"NuGet packages to update:" | Write-Host -ForegroundColor White
79+
$packageList | Write-Host -ForegroundColor White
80+
81+
# restore NuGet packages, need to do this before anything else
82+
nuget restore $solutionFile[0] -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json
83+
8684
# rename nfproj files to csproj
8785
Get-ChildItem -Path ".\" -Include "*.nfproj" -Recurse |
8886
Foreach-object {
@@ -95,25 +93,38 @@ else
9593
foreach ($package in $packageList)
9694
{
9795
# get package name and target version
98-
$packageDetails = [regex]::Match($package, "(.*)(( from)(.*)(to )(.*)( in))")
99-
$packageName = $packageDetails.captures.Groups[1].Value.Trim();
100-
$packageOriginVersion = $packageDetails.captures.Groups[4].Value.Trim();
101-
$packageTargetVersion = $packageDetails.captures.Groups[6].Value.Trim();
96+
$packageName = $package[0]
97+
$packageOriginVersion = $package[1]
10298

10399
# update package
104100
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*')
105101
{
106-
# use NuGet ONLY for release and master branches
107-
$updatePackage = nuget update $solutionFile[0].FullName -Source https://api.nuget.org/v3/index.json
102+
# don't allow prerelease for release and master branches
103+
$updatePackage = nuget update $solutionFile[0].FullName -Source https://api.nuget.org/v3/index.json -Source https://api.nuget.org/v3/index.json
108104
}
109105
else
110106
{
111-
# use NuGet and MyGet for all others
112-
$updatePackage = nuget update $solutionFile[0].FullName -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json
107+
# allow prerelease for all others
108+
$updatePackage = nuget update $solutionFile[0].FullName -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json -PreRelease
109+
}
110+
111+
# need to get target version
112+
# load packages.config as XML doc
113+
[xml]$packagesDoc = Get-Content $packagesConfig
114+
115+
$nodes = $packagesDoc.SelectNodes("*").SelectNodes("*")
116+
117+
foreach ($node in $nodes)
118+
{
119+
# find this package
120+
if($node.id -match $packageName)
121+
{
122+
$packageTargetVersion = $node.version
123+
}
113124
}
114125

115-
# grab csproj from update output
116-
$projectPath = [regex]::Match($updatePackage, "((project ')(.*)(', targeting))").captures.Groups[3].Value
126+
# find csproj
127+
$projectPath = (Get-ChildItem -Path ".\" -Include "*.csproj" -Recurse)
117128

118129
# replace NFMDP_PE_LoadHints
119130
$filecontent = Get-Content($projectPath)

0 commit comments

Comments
 (0)