-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathPrepare template project for packing.ps1
More file actions
28 lines (25 loc) · 1.64 KB
/
Prepare template project for packing.ps1
File metadata and controls
28 lines (25 loc) · 1.64 KB
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
$starWarsApiProjPath = "samples/star-wars-api/FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj"
[xml]$starWarsApiProj = Get-Content -Path $starWarsApiProjPath
$starWarsApiProjRefNode = $starWarsApiProj.SelectSingleNode("//ItemGroup[@Label='ProjectReferences']")
$starWarsApiProjRefNode.ParentNode.RemoveChild($starWarsApiProjRefNode) | Out-Null
$dirBuildTargetsPath = "Directory.Build.targets"
[xml]$dirBuildTargets = Get-Content -Path $dirBuildTargetsPath
$version = $dirBuildTargets.SelectSingleNode("//PropertyGroup[@Label='NuGet']/Version").InnerText
[xml]$fsharpPackages = @"
<ItemGroup Label="PackageReferences">
<PackageReference Include="FSharp.Data.GraphQL.Server.Middleware" Version="$($version)" />
<PackageReference Include="FSharp.Data.GraphQL.Server.Relay" Version="$($version)" />
<PackageReference Include="FSharp.Data.GraphQL.Server" Version="$($version)" />
<PackageReference Include="FSharp.Data.GraphQL.Shared" Version="$($version)" />
</ItemGroup>
"@
$packagesPropsPath = "Packages.props"
[xml]$packagesProps = Get-Content -Path $packagesPropsPath
$giraffeVersion = $packagesProps.SelectSingleNode("//PackageReference[@Update='Giraffe']/@Version")
$starWarsApiProj.SelectSingleNode("//ItemGroup[@Label='PackageReferences']/PackageReference[@Include='Giraffe']").SetAttribute("Version",$giraffeVersion.Value)
$packageReferences = $starWarsApiProj.SelectSingleNode("//ItemGroup[@Label='PackageReferences']")
foreach($packageReference in $fsharpPackages.DocumentElement.ChildNodes){
$innerNode = $starWarsApiProj.ImportNode($packageReference,$true)
$packageReferences.AppendChild($innerNode)
}
$starWarsApiProj.Save($starWarsApiProjPath)