forked from cefsharp/CefSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateNugetPackages.ps1
99 lines (74 loc) · 3.35 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#requires -Version 5
[CmdletBinding()]
param(
[Parameter(Position = 1)]
[string] $CefVersion = "103.0.8",
[Parameter(Position = 2)]
[string] $CefSharpVersion = ""
)
# 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
Set-StrictMode -version latest;
$ErrorActionPreference = "Stop";
function DownloadNuget()
{
if(-not (Test-Path $nuget))
{
$client = New-Object System.Net.WebClient;
$client.DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', $nuget);
}
if(-not (Test-Path $nuget))
{
Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget"
}
}
function RemoveEnsureNuGetPackageBuildImports
{
param([Parameter(Position = 0, ValueFromPipeline = $true)][string] $FileName)
$xml = [xml](Get-Content $FileName)
$ns = new-object Xml.XmlNamespaceManager $xml.NameTable
$ns.AddNamespace("ns", $xml.DocumentElement.NamespaceURI)
$target = $xml.SelectSingleNode("//ns:Project/ns:Target[@Name='EnsureNuGetPackageBuildImports']", $ns);
if($null -ne $target)
{
$target.ParentNode.RemoveChild($target)
$xml.Save( $FileName )
}
}
if ($CefSharpVersion -eq "")
{
$CefSharpVersion = $CefVersion + "0"
}
$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition
$nuget = Join-Path $WorkingDir .\nuget\NuGet.exe
DownloadNuget
$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.SelectSingleNode("//Project/ItemGroup/PackageReference[@Include='chromiumembeddedframework.runtime']");
$packRef.Version = $RedistVersion
$xml.Save( $file )
}
.\build.ps1 -Target update-build-version -Version $CefSharpVersion -AssemblyVersion $CefSharpVersion