-Changed build script to support NuGet profiles
This commit is contained in:
JamesNK
2011-04-22 03:11:42 +00:00
parent 2c190ec438
commit 21a2a7e4f7
5 changed files with 63 additions and 22 deletions
+20 -16
View File
@@ -1,10 +1,10 @@
properties {
$zipFileName = "Json40r2.zip"
$majorVersion = "4.2"
$majorVersion = "4.0.2"
$version = GetVersion $majorVersion
$signAssemblies = $false
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
$buildDocumentation = $false
$buildDocumentation = $true
$buildNuGet = $true
$baseDir = resolve-path ..
@@ -15,10 +15,10 @@
$releaseDir = "$baseDir\Release"
$workingDir = "$baseDir\Working"
$builds = @(
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "net40-client"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "net40-client,net40-full"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight"; NuGetDir = "sl4"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35-client"; Framework="net-2.0"},
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35-client,net35-full"; Framework="net-2.0"},
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"}
)
}
@@ -45,7 +45,7 @@ task Clean {
task Build -depends Clean {
Write-Host -ForegroundColor Green "Updating assembly version"
Write-Host
Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0.0') $version
Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0') $version
foreach ($build in $builds)
{
@@ -80,14 +80,6 @@ task Package -depends Merge {
Copy-Item -Path "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" -Destination $workingDir\Package\Bin\$finalDir -recurse
}
if ($buildDocumentation)
{
# Sandcastle has issues when compiling with .NET 4 MSBuild - http://shfb.codeplex.com/Thread/View.aspx?ThreadId=50652
exec { .$env:windir\Microsoft.NET\Framework\v3.5\MSBuild.exe "/t:Clean;Rebuild" /p:Configuration=Release "/p:DocumentationSourcePath=$workingDir\Package\Bin\Net" $docDir\doc.shfbproj } "Error building documentation. Check that you have Sandcastle, Sandcastle Help File Builder and HTML Help Workshop installed."
move -Path $workingDir\Documentation\Documentation.chm -Destination $workingDir\Package\Documentation.chm
move -Path $workingDir\Documentation\LastBuild.log -Destination $workingDir\Documentation.log
}
if ($buildNuGet)
{
New-Item -Path $workingDir\NuGet -ItemType Directory
@@ -97,15 +89,27 @@ task Package -depends Merge {
{
$name = $build.TestsName
$finalDir = $build.FinalDir
$frameworkDir = $build.NuGetDir
$frameworkDirs = $build.NuGetDir.Split(",")
Copy-Item -Path "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" -Destination $workingDir\NuGet\lib\$frameworkDir -recurse
foreach ($frameworkDir in $frameworkDirs)
{
Copy-Item -Path "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" -Destination $workingDir\NuGet\lib\$frameworkDir -recurse
}
}
exec { .\Tools\NuGet\NuGet.exe pack $workingDir\NuGet\Newtonsoft.Json.nuspec }
move -Path .\*.nupkg -Destination $workingDir\NuGet
}
if ($buildDocumentation)
{
# Sandcastle has issues when compiling with .NET 4 MSBuild - http://shfb.codeplex.com/Thread/View.aspx?ThreadId=50652
exec { .$env:windir\Microsoft.NET\Framework\v3.5\MSBuild.exe "/t:Clean;Rebuild" /p:Configuration=Release "/p:DocumentationSourcePath=$workingDir\Package\Bin\Net" $docDir\doc.shfbproj } "Error building documentation. Check that you have Sandcastle, Sandcastle Help File Builder and HTML Help Workshop installed."
move -Path $workingDir\Documentation\Documentation.chm -Destination $workingDir\Package\Documentation.chm
move -Path $workingDir\Documentation\LastBuild.log -Destination $workingDir\Documentation.log
}
Copy-Item -Path $docDir\readme.txt -Destination $workingDir\Package\
Copy-Item -Path $docDir\versions.txt -Destination $workingDir\Package\Bin\
@@ -188,7 +192,7 @@ function GetVersion($majorVersion)
$minute = $now.Minute
$revision = "{0:00}{1:00}" -f $hour, $minute
return $majorVersion + "." + $minor + "." + $revision
return $majorVersion + "." + $minor
}
function Update-AssemblyInfoFiles ([string] $sourceDir, [string] $assemblyVersionNumber, [string] $fileVersionNumber)
@@ -601,6 +601,41 @@ namespace Newtonsoft.Json.Tests.Linq
// Admin
}
[Test]
public void ImprovedDynamicLinqExample()
{
dynamic product = new JObject();
product.ProductName = "Elbow Grease";
product.Enabled = true;
product.Price = 4.90m;
product.StockCount = 9000;
product.StockValue = 44100;
// All Elbow Grease must go sale!
// 50% off price
product.Price = product.Price / 2;
product.StockValue = product.StockCount * product.Price;
product.ProductName = product.ProductName + " (SALE)";
string json = product.ToString();
// {
// "ProductName": "Elbow Grease (SALE)",
// "Enabled": true,
// "Price": 2.45,
// "StockCount": 9000,
// "StockValue": 22050.0
// }
Assert.AreEqual(@"{
""ProductName"": ""Elbow Grease (SALE)"",
""Enabled"": true,
""Price"": 2.45,
""StockCount"": 9000,
""StockValue"": 22050.0
}", json);
}
public class DynamicDictionary : DynamicObject
{
private readonly IDictionary<string, object> _values = new Dictionary<string, object>();
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyVersion("4.0.2.0")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.2.13610.1823")]
[assembly: AssemblyFileVersion("4.0.2.13622")]
#endif
@@ -108,9 +108,9 @@ using System.Security;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyVersion("4.0.2.0")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.2.13610.1823")]
[assembly: AssemblyFileVersion("4.0.2.13622")]
#endif
[assembly: CLSCompliant(true)]
@@ -21,12 +21,14 @@ namespace Newtonsoft.Json.Utilities
if (objA == null && objB != null)
return false;
// comparing an Int32 and Int64 both of the same value returns false
// make types the same then compare
if (objA.GetType() != objB.GetType())
{
if (ConvertUtils.IsInteger(objA) && ConvertUtils.IsInteger(objB))
return Convert.ToDecimal(objA).Equals(Convert.ToDecimal(objB));
return Convert.ToDecimal(objA, CultureInfo.CurrentCulture).Equals(Convert.ToDecimal(objB, CultureInfo.CurrentCulture));
else if ((objA is double || objA is float || objA is decimal) && (objB is double || objB is float || objB is decimal))
return MathUtils.ApproxEquals(Convert.ToDouble(objA), Convert.ToDouble(objB));
return MathUtils.ApproxEquals(Convert.ToDouble(objA, CultureInfo.CurrentCulture), Convert.ToDouble(objB, CultureInfo.CurrentCulture));
else
return false;
}