Update build to not copy source to working directory (#1745)
This commit is contained in:
+16
-32
@@ -1,8 +1,8 @@
|
|||||||
properties {
|
properties {
|
||||||
$zipFileName = "Json110r2.zip"
|
$zipFileName = "Json110r3.zip"
|
||||||
$majorVersion = "11.0"
|
$majorVersion = "11.0"
|
||||||
$majorWithReleaseVersion = "11.0.2"
|
$majorWithReleaseVersion = "11.0.3"
|
||||||
$nugetPrerelease = $null
|
$nugetPrerelease = "beta1"
|
||||||
$version = GetVersion $majorWithReleaseVersion
|
$version = GetVersion $majorWithReleaseVersion
|
||||||
$packageId = "Newtonsoft.Json"
|
$packageId = "Newtonsoft.Json"
|
||||||
$signAssemblies = $false
|
$signAssemblies = $false
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
$treatWarningsAsErrors = $false
|
$treatWarningsAsErrors = $false
|
||||||
$workingName = if ($workingName) {$workingName} else {"Working"}
|
$workingName = if ($workingName) {$workingName} else {"Working"}
|
||||||
$netCliChannel = "2.0"
|
$netCliChannel = "2.0"
|
||||||
$netCliVersion = "2.1.4"
|
$netCliVersion = "2.1.301"
|
||||||
$nugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
$nugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||||
|
|
||||||
$baseDir = resolve-path ..
|
$baseDir = resolve-path ..
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
$docDir = "$baseDir\Doc"
|
$docDir = "$baseDir\Doc"
|
||||||
$releaseDir = "$baseDir\Release"
|
$releaseDir = "$baseDir\Release"
|
||||||
$workingDir = "$baseDir\$workingName"
|
$workingDir = "$baseDir\$workingName"
|
||||||
$workingSourceDir = "$workingDir\Src"
|
|
||||||
|
|
||||||
$nugetPath = "$buildDir\Temp\nuget.exe"
|
$nugetPath = "$buildDir\Temp\nuget.exe"
|
||||||
$vswhereVersion = "2.3.2"
|
$vswhereVersion = "2.3.2"
|
||||||
@@ -78,20 +77,7 @@ task Build -depends Clean {
|
|||||||
$script:msBuildPath = GetMsBuildPath
|
$script:msBuildPath = GetMsBuildPath
|
||||||
Write-Host "MSBuild path $script:msBuildPath"
|
Write-Host "MSBuild path $script:msBuildPath"
|
||||||
|
|
||||||
Write-Host "Copying source to working source directory $workingSourceDir"
|
$projectPath = "$sourceDir\Newtonsoft.Json\Newtonsoft.Json.csproj"
|
||||||
robocopy $sourceDir $workingSourceDir /MIR /NFL /NDL /NP /XD bin obj TestResults AppPackages $packageDirs .vs artifacts /XF *.suo *.user *.lock.json | Out-Default
|
|
||||||
Copy-Item -Path $baseDir\LICENSE.md -Destination $workingDir\
|
|
||||||
mkdir "$workingDir\Build" -Force
|
|
||||||
|
|
||||||
$xml = [xml](Get-Content "$workingSourceDir\Newtonsoft.Json\Newtonsoft.Json.csproj")
|
|
||||||
Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/PackageId" -value $packageId
|
|
||||||
Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/VersionPrefix" -value $majorWithReleaseVersion
|
|
||||||
Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/VersionSuffix" -value $nugetPrerelease
|
|
||||||
Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/AssemblyVersion" -value ($majorVersion + '.0.0')
|
|
||||||
Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/FileVersion" -value $version
|
|
||||||
$xml.save("$workingSourceDir\Newtonsoft.Json\Newtonsoft.Json.csproj")
|
|
||||||
|
|
||||||
$projectPath = "$workingSourceDir\Newtonsoft.Json\Newtonsoft.Json.csproj"
|
|
||||||
|
|
||||||
NetCliBuild
|
NetCliBuild
|
||||||
}
|
}
|
||||||
@@ -102,7 +88,7 @@ task Package -depends Build {
|
|||||||
{
|
{
|
||||||
$finalDir = $build.Framework
|
$finalDir = $build.Framework
|
||||||
|
|
||||||
$sourcePath = "$workingSourceDir\Newtonsoft.Json\bin\Release\$finalDir"
|
$sourcePath = "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir"
|
||||||
|
|
||||||
if (!(Test-Path -path $sourcePath))
|
if (!(Test-Path -path $sourcePath))
|
||||||
{
|
{
|
||||||
@@ -114,14 +100,10 @@ task Package -depends Build {
|
|||||||
|
|
||||||
if ($buildNuGet)
|
if ($buildNuGet)
|
||||||
{
|
{
|
||||||
Write-Host -ForegroundColor Green "Creating NuGet package"
|
Write-Host -ForegroundColor Green "Copy NuGet package"
|
||||||
|
|
||||||
$targetFrameworks = ($script:enabledBuilds | Select-Object @{Name="Framework";Expression={$_.Framework}} | select -expand Framework) -join ";"
|
|
||||||
|
|
||||||
exec { & $script:msBuildPath "/t:pack" "/v:$msbuildVerbosity" "/p:IncludeSource=true" "/p:Configuration=Release" "/p:TargetFrameworks=`"$targetFrameworks`"" "/m" "$workingSourceDir\Newtonsoft.Json\Newtonsoft.Json.csproj" }
|
|
||||||
|
|
||||||
mkdir $workingDir\NuGet
|
mkdir $workingDir\NuGet
|
||||||
move -Path $workingSourceDir\Newtonsoft.Json\bin\Release\*.nupkg -Destination $workingDir\NuGet
|
move -Path $sourceDir\Newtonsoft.Json\bin\Release\*.nupkg -Destination $workingDir\NuGet
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Build documentation: $buildDocumentation"
|
Write-Host "Build documentation: $buildDocumentation"
|
||||||
@@ -144,7 +126,7 @@ task Package -depends Build {
|
|||||||
Copy-Item -Path $docDir\readme.txt -Destination $workingDir\Package\
|
Copy-Item -Path $docDir\readme.txt -Destination $workingDir\Package\
|
||||||
Copy-Item -Path $docDir\license.txt -Destination $workingDir\Package\
|
Copy-Item -Path $docDir\license.txt -Destination $workingDir\Package\
|
||||||
|
|
||||||
robocopy $workingSourceDir $workingDir\Package\Source\Src /MIR /NFL /NDL /NJS /NC /NS /NP /XD bin obj TestResults AppPackages .vs artifacts /XF *.suo *.user *.lock.json | Out-Default
|
robocopy $sourceDir $workingDir\Package\Source\Src /MIR /NFL /NDL /NJS /NC /NS /NP /XD bin obj TestResults AppPackages .vs artifacts /XF *.suo *.user *.lock.json | Out-Default
|
||||||
robocopy $buildDir $workingDir\Package\Source\Build /MIR /NFL /NDL /NJS /NC /NS /NP /XD Temp /XF runbuild.txt | Out-Default
|
robocopy $buildDir $workingDir\Package\Source\Build /MIR /NFL /NDL /NJS /NC /NS /NP /XD Temp /XF runbuild.txt | Out-Default
|
||||||
robocopy $docDir $workingDir\Package\Source\Doc /MIR /NFL /NDL /NJS /NC /NS /NP | Out-Default
|
robocopy $docDir $workingDir\Package\Source\Doc /MIR /NFL /NDL /NJS /NC /NS /NP | Out-Default
|
||||||
robocopy $toolsDir $workingDir\Package\Source\Tools /MIR /NFL /NDL /NJS /NC /NS /NP | Out-Default
|
robocopy $toolsDir $workingDir\Package\Source\Tools /MIR /NFL /NDL /NJS /NC /NS /NP | Out-Default
|
||||||
@@ -162,7 +144,7 @@ task Test -depends Build {
|
|||||||
|
|
||||||
function NetCliBuild()
|
function NetCliBuild()
|
||||||
{
|
{
|
||||||
$projectPath = "$workingSourceDir\Newtonsoft.Json.sln"
|
$projectPath = "$sourceDir\Newtonsoft.Json.sln"
|
||||||
$libraryFrameworks = ($script:enabledBuilds | Select-Object @{Name="Framework";Expression={$_.Framework}} | select -expand Framework) -join ";"
|
$libraryFrameworks = ($script:enabledBuilds | Select-Object @{Name="Framework";Expression={$_.Framework}} | select -expand Framework) -join ";"
|
||||||
$testFrameworks = ($script:enabledBuilds | Select-Object @{Name="Resolved";Expression={if ($_.TestFramework -ne $null) { $_.TestFramework } else { $_.Framework }}} | select -expand Resolved) -join ";"
|
$testFrameworks = ($script:enabledBuilds | Select-Object @{Name="Resolved";Expression={if ($_.TestFramework -ne $null) { $_.TestFramework } else { $_.Framework }}} | select -expand Resolved) -join ";"
|
||||||
|
|
||||||
@@ -176,7 +158,9 @@ function NetCliBuild()
|
|||||||
Write-Host -ForegroundColor Green "Building $libraryFrameworks in $projectPath"
|
Write-Host -ForegroundColor Green "Building $libraryFrameworks in $projectPath"
|
||||||
Write-Host
|
Write-Host
|
||||||
|
|
||||||
exec { & $script:msBuildPath "/t:build" "/v:$msbuildVerbosity" $projectPath "/p:Configuration=Release" "/p:LibraryFrameworks=`"$libraryFrameworks`"" "/p:TestFrameworks=`"$testFrameworks`"" "/p:AssemblyOriginatorKeyFile=$signKeyPath" "/p:SignAssembly=$signAssemblies" "/p:TreatWarningsAsErrors=$treatWarningsAsErrors" "/p:AdditionalConstants=$additionalConstants" "/m" }
|
$assemblyVersion = $majorVersion + '.0.0'
|
||||||
|
|
||||||
|
exec { & $script:msBuildPath "/t:build" "/v:$msbuildVerbosity" $projectPath "/p:IncludeSource=true" "/p:Configuration=Release" "/p:LibraryFrameworks=`"$libraryFrameworks`"" "/p:TestFrameworks=`"$testFrameworks`"" "/p:AssemblyOriginatorKeyFile=$signKeyPath" "/p:SignAssembly=$signAssemblies" "/p:TreatWarningsAsErrors=$treatWarningsAsErrors" "/p:AdditionalConstants=$additionalConstants" "/p:GeneratePackageOnBuild=$buildNuGet" "/p:PackageId=$packageId" "/p:VersionPrefix=$majorWithReleaseVersion" "/p:VersionSuffix=$nugetPrerelease" "/p:AssemblyVersion=$assemblyVersion" "/p:FileVersion=$version" "/m" }
|
||||||
}
|
}
|
||||||
|
|
||||||
function EnsureNuGetExists()
|
function EnsureNuGetExists()
|
||||||
@@ -208,8 +192,8 @@ function GetMsBuildPath()
|
|||||||
|
|
||||||
function NetCliTests($build)
|
function NetCliTests($build)
|
||||||
{
|
{
|
||||||
$projectPath = "$workingSourceDir\Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.csproj"
|
$projectPath = "$sourceDir\Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.csproj"
|
||||||
$location = "$workingSourceDir\Newtonsoft.Json.Tests"
|
$location = "$sourceDir\Newtonsoft.Json.Tests"
|
||||||
$testDir = if ($build.TestFramework -ne $null) { $build.TestFramework } else { $build.Framework }
|
$testDir = if ($build.TestFramework -ne $null) { $build.TestFramework } else { $build.Framework }
|
||||||
|
|
||||||
exec { .\Tools\Dotnet\dotnet-install.ps1 -Channel $netCliChannel -Version $netCliVersion | Out-Default }
|
exec { .\Tools\Dotnet\dotnet-install.ps1 -Channel $netCliChannel -Version $netCliVersion | Out-Default }
|
||||||
@@ -237,7 +221,7 @@ function NUnitTests($build)
|
|||||||
{
|
{
|
||||||
$testDir = if ($build.TestFramework -ne $null) { $build.TestFramework } else { $build.Framework }
|
$testDir = if ($build.TestFramework -ne $null) { $build.TestFramework } else { $build.Framework }
|
||||||
$framework = $build.NUnitFramework
|
$framework = $build.NUnitFramework
|
||||||
$testRunDir = "$workingSourceDir\Newtonsoft.Json.Tests\bin\Release\$testDir"
|
$testRunDir = "$sourceDir\Newtonsoft.Json.Tests\bin\Release\$testDir"
|
||||||
|
|
||||||
Write-Host -ForegroundColor Green "Running NUnit tests $testDir"
|
Write-Host -ForegroundColor Green "Running NUnit tests $testDir"
|
||||||
Write-Host
|
Write-Host
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"projects": [ "src" ],
|
"projects": [ "src" ],
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "2.1.4"
|
"version": "2.1.301"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user