-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathPrepare template project for packing.ps1
27 lines (24 loc) · 1.45 KB
/
Prepare template project for packing.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
$starWarsApiProjPath = "samples/star-wars-api/star-wars-api.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.AspNetCore" Version="$($version)" />
<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
$packageReferences = $starWarsApiProj.SelectSingleNode("//ItemGroup[@Label='PackageReferences']")
foreach($packageReference in $fsharpPackages.DocumentElement.ChildNodes){
$innerNode = $starWarsApiProj.ImportNode($packageReference,$true)
$packageReferences.AppendChild($innerNode)
}
$starWarsApiProj.Save($starWarsApiProjPath)