forked from cefsharp/CefSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateNugetPackages.ps1
64 lines (44 loc) · 2.4 KB
/
UpdateNugetPackages.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#requires -Version 5
# Update projects files
# I haven't found a clean solution that allows for using just nuget.exe and dotnet.exe to do this
# Update the vcxproj files first
# Update the .Net csproj files modifying the xml file directly
$CefVersion = '95.7.14'
function RemoveEnsureNuGetPackageBuildImports
{
param([Parameter(Position = 0, ValueFromPipeline = $true)][string] $FileName)
$xml = [xml](Get-Content $FileName)
$target = $xml.Project.Target | Where-Object {$_."Name" -eq "EnsureNuGetPackageBuildImports"}
if($target -ne $null)
{
$target.ParentNode.RemoveChild($target)
$xml.Save( $FileName )
}
}
$vcxprojFiles = @('CefSharp.Core.Runtime\CefSharp.Core.Runtime.vcxproj','CefSharp.BrowserSubprocess.Core\CefSharp.BrowserSubprocess.Core.vcxproj')
foreach($file in $vcxprojFiles)
{
..\nuget update $file -Id cef.sdk -Version $CefVersion
RemoveEnsureNuGetPackageBuildImports (Resolve-Path $file)
}
$vcxprojFiles = @('CefSharp.Core.Runtime\CefSharp.Core.Runtime.netcore.vcxproj', 'CefSharp.BrowserSubprocess.Core\CefSharp.BrowserSubprocess.Core.netcore.vcxproj')
foreach($file in $vcxprojFiles)
{
..\nuget update $file -Id cef.sdk -Version $CefVersion
RemoveEnsureNuGetPackageBuildImports (Resolve-Path $file)
}
#Read the newly updated version number from the packages.CefSharp.Core.Runtime.config
$CefSharpCorePackagesXml = [xml](Get-Content (Resolve-Path 'CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.config'))
$RedistVersion = $CefSharpCorePackagesXml.SelectSingleNode("//packages/package[@id='cef.sdk']/@version").value
$csprojFiles = @('CefSharp.WinForms.Example\CefSharp.WinForms.Example.netcore.csproj','CefSharp.Wpf.Example\CefSharp.Wpf.Example.netcore.csproj','CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.netcore.csproj', 'CefSharp.Test\CefSharp.Test.netcore.csproj', 'CefSharp.WinForms.Example\CefSharp.WinForms.Example.csproj','CefSharp.Wpf.Example\CefSharp.Wpf.Example.csproj','CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.csproj', 'CefSharp.Test\CefSharp.Test.csproj')
#Loop through the net core example projects and update the package version number
foreach($file in $csprojFiles)
{
$file = Resolve-Path $file
$xml = New-Object xml
$xml.PreserveWhitespace = $true
$xml.Load($file)
$packRef = $xml.Project.ItemGroup.PackageReference | Where-Object {$_."Include" -eq "chromiumembeddedframework.runtime"}
$packRef.Version = $RedistVersion
$xml.Save( $file )
}