Permalink
Browse files

Copy some missing samples from the output build.

Remove projects that not exists in the samples solution.
Remove the samples.ps1 file which may confuse some people.
  • Loading branch information...
1 parent a763c2e commit e56fae273e5254b24ce5501d697cfa84c4892b05 @fitzchak fitzchak committed Jan 1, 2013
Showing with 142 additions and 212 deletions.
  1. +0 −68 Samples/Samples.ps1
  2. +126 −111 Utilities/Raven.Samples.PrepareForRelease/Program.cs
  3. +0 −17 build_utils.ps1
  4. +16 −16 default.ps1
View
@@ -1,68 +0,0 @@
-function Copy-RavenDB
-{
- param(
- [string]$dest
- )
-
- $raven = "..\..\Server" #release path
- if( (test-path $raven) -eq $false)
- {
- $raven = "..\..\build" #src path
- }
-
- $server_files = @( "Raven.Server.exe", "Raven.Studio.xap", "nlog.???", "Newtonsoft.Json.???", "Lucene.Net.???", `
- "Lucene.Net.Contrib.Spatial.???", "Lucene.Net.Contrib.SpellChecker.???", "ICSharpCode.NRefactory.???", "Rhino.Licensing.???", "BouncyCastle.Crypto.???", `
- "Esent.Interop.???", "Raven.Abstractions.???", "Raven.Database.???", "Raven.Storage.Esent.???", `
- "Raven.Storage.Managed.???", "Raven.Munin.???" );
-
- foreach($serverFile in $server_files)
- {
- Copy-Item "$raven\$serverFile" $dest -ErrorAction SilentlyContinue -Force
- }
-}
-
-function Recreate-RavenDB
-{
- param(
- [string]$dest,
- [array]$bundles
- )
- $originalDest = $dest
- $pwd = pwd
- $dest = [System.IO.Path]::Combine($pwd, $dest)
-
- rd $dest -force -recurse -erroraction silentlycontinue
- md $dest
-
- $parent = [System.IO.Path]::GetDirectoryName($dest)
- $gitignore = "$pwd/.gitignore"
- $ignoreLine = "$originalDest/"
- if((Test-Path $gitignore) -eq $false)
- {
- Set-Content -Path $gitignore $ignoreLine
- }
- else
- {
- $resultFound = Get-Content $gitignore | Select-String $ignoreLine -quiet
-
- if($resultFound -eq $null)
- {
- Add-Content -Path $gitignore $ignoreLine
- }
- }
- Copy-RavenDB $dest
-
- md $dest\Plugins -erroraction silentlycontinue
-
- $bundlesPath = "..\..\Bundles"
- if( (Test-Path "$bundlesPath\$bundle.???") -eq $false)
- {
- $bundlesPath = "..\..\build"
- }
-
- foreach($bundle in $bundles)
- {
- Copy-Item "$bundlesPath\$bundle.???" "$dest\Plugins" -ErrorAction SilentlyContinue -Force
- }
-
-}
@@ -1,111 +1,126 @@
-//-----------------------------------------------------------------------
-// <copyright file="Program.cs" company="Hibernating Rhinos LTD">
-// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-using System;
-using System.IO;
-using System.Linq;
-using System.Xml.Linq;
-
-namespace Raven.Samples.PrepareForRelease
-{
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- var slnPath = args[0];
- var libPath = args[1];
- Environment.CurrentDirectory = Path.GetDirectoryName(slnPath);
-
- RemoveProjectReferencesNotInSameDirectory(slnPath);
-
- var ns = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");
- foreach (var projectFile in Directory.GetFiles(Path.GetDirectoryName(slnPath), "*.csproj", SearchOption.AllDirectories))
- {
- Console.WriteLine("Preparing project file: " +projectFile);
- var prj = XDocument.Load(projectFile);
-
- foreach (var reference in prj.Descendants(ns + "Reference").ToArray())
- {
- var hintPath = reference.Element(ns + "HintPath");
- if (hintPath == null)
- continue;
- var guessFileName = GuessFileName(Path.GetFileName(hintPath.Value), libPath, true);
- if(guessFileName == null)
- continue;
- hintPath.Value = Path.Combine(@"..\..", guessFileName);
- }
-
- foreach (var prjRef in prj.Descendants(ns + "ProjectReference").ToArray())
- {
- var includeAttrib = prjRef.Attribute("Include");
- if (includeAttrib == null)
- continue;
- if (includeAttrib.Value.StartsWith(@"..\..\") == false)
- continue;
- var prjRefName = prjRef.Element(ns + "Name");
- if(prjRefName == null)
- continue;
- var refName = prjRefName.Value;
- var parent = prjRef.Parent;
- if(parent == null)
- continue;
- parent.Add(
- new XElement(ns + "Reference",
- new XAttribute("Include", refName),
- new XElement(ns+"HintPath", Path.Combine(@"..\..", GuessFileName(refName, libPath, false)))
- )
- );
-
- prjRef.Remove();
- }
-
- prj.Save(projectFile);
- }
- }
- catch(Exception e)
- {
- Console.Error.WriteLine(e);
- Environment.Exit(-1);
- }
- }
-
- private static string GuessFileName(string refName, string libPath, bool allowMissingFiles)
- {
- var fullPath = Path.GetFullPath(libPath);
- var searchPattern = Path.GetExtension(refName) == ".dll" ? refName : refName + ".*";
- var filePath = Directory.GetFiles(fullPath, searchPattern, SearchOption.AllDirectories)
- .Where(x=>x.ToUpperInvariant().Contains("SAMPLES") == false)
- .FirstOrDefault();
- if (filePath == null)
- {
- if (allowMissingFiles)
- return null;
- throw new InvalidOperationException("Could not file a file matching '" + searchPattern + "' in: " +
- libPath);
- }
- filePath = Path.GetFullPath(filePath);
- return filePath.Substring(fullPath.Length + 1);
- }
-
- private static void RemoveProjectReferencesNotInSameDirectory(string path)
- {
- var lastLineHadReferenceToParentDirectory = false;
- var slnLines = File.ReadAllLines(path)
- .Where(line =>
- {
- if (lastLineHadReferenceToParentDirectory)
- {
- lastLineHadReferenceToParentDirectory = false;
- return false;
- }
- return (lastLineHadReferenceToParentDirectory = line.Contains("..")) == false;
- });
-
- File.WriteAllLines(path, slnLines);
- }
- }
-}
+//-----------------------------------------------------------------------
+// <copyright file="Program.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+using System;
+using System.IO;
+using System.Linq;
+using System.Xml.Linq;
+
+namespace Raven.Samples.PrepareForRelease
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ try
+ {
+ var slnPath = args[0];
+ var libPath = args[1];
+ Environment.CurrentDirectory = Path.GetDirectoryName(slnPath);
+
+ RemoveProjectReferencesNotInSameDirectory(slnPath);
+
+ var ns = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");
+ foreach (var projectFile in Directory.GetFiles(Path.GetDirectoryName(slnPath), "*.csproj", SearchOption.AllDirectories))
+ {
+ Console.WriteLine("Preparing project file: " +projectFile);
+ var prj = XDocument.Load(projectFile);
+
+ foreach (var reference in prj.Descendants(ns + "Reference").ToArray())
+ {
+ var hintPath = reference.Element(ns + "HintPath");
+ if (hintPath == null)
+ continue;
+ var guessFileName = GuessFileName(Path.GetFileName(hintPath.Value), libPath, true);
+ if(guessFileName == null)
+ continue;
+ hintPath.Value = Path.Combine(@"..\..", guessFileName);
+ }
+
+ foreach (var prjRef in prj.Descendants(ns + "ProjectReference").ToArray())
+ {
+ var includeAttrib = prjRef.Attribute("Include");
+ if (includeAttrib == null)
+ continue;
+ if (includeAttrib.Value.StartsWith(@"..\..\") == false)
+ continue;
+ var prjRefName = prjRef.Element(ns + "Name");
+ if(prjRefName == null)
+ continue;
+ var refName = prjRefName.Value;
+ var parent = prjRef.Parent;
+ if(parent == null)
+ continue;
+ parent.Add(
+ new XElement(ns + "Reference",
+ new XAttribute("Include", refName),
+ new XElement(ns+"HintPath", Path.Combine(@"..\..", GuessFileName(refName, libPath, false)))
+ )
+ );
+
+ prjRef.Remove();
+ }
+
+ prj.Save(projectFile);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.Error.WriteLine(e);
+ Environment.Exit(-1);
+ }
+ }
+
+ private static string GuessFileName(string refName, string libPath, bool allowMissingFiles)
+ {
+ var fullPath = Path.GetFullPath(libPath);
+ var searchPattern = Path.GetExtension(refName) == ".dll" ? refName : refName + ".*";
+ var filePath = Directory.GetFiles(fullPath, searchPattern, SearchOption.AllDirectories)
+ .Where(x=>x.ToUpperInvariant().Contains("SAMPLES") == false)
+ .FirstOrDefault();
+ if (filePath == null)
+ {
+ if (allowMissingFiles)
+ return null;
+ throw new InvalidOperationException("Could not file a file matching '" + searchPattern + "' in: " +
+ libPath);
+ }
+ filePath = Path.GetFullPath(filePath);
+ return filePath.Substring(fullPath.Length + 1);
+ }
+
+ private static void RemoveProjectReferencesNotInSameDirectory(string path)
+ {
+ var projectsToRemove = new[]
+ {
+ ".nuget",
+ "Raven",
+ "Raven.Server",
+ "Raven.Database",
+ "Raven.Abstractions",
+ "Raven.Client.Embedded",
+ "Raven.Client.Lightweight",
+ "Bundles",
+ "Raven.Bundles.IndexReplication",
+ };
+
+ var lastLineHadReferenceToParentDirectory = false;
+ var slnLines = File.ReadAllLines(path)
+ .Where(line =>
+ {
+ if (lastLineHadReferenceToParentDirectory)
+ {
+ if (line == "EndProject")
+ lastLineHadReferenceToParentDirectory = false;
+ return false;
+ }
+ return (lastLineHadReferenceToParentDirectory = line.StartsWith(@"Project(""{") && projectsToRemove.Any(item => line.Contains(string.Format(@"}}"") = ""{0}"", """, item)))) == false;
+ })
+ .ToArray();
+
+ File.WriteAllLines(path, slnLines);
+ }
+ }
+}
View
@@ -19,23 +19,6 @@ function Get-Git-Commit
}
}
-function Delete-Sample-Data-For-Release
-{
- param([string]$sample_dir)
- rd "$sample_dir\bin" -force -recurse -ErrorAction SilentlyContinue
- rd "$sample_dir\obj" -force -recurse -ErrorAction SilentlyContinue
-
- rd "$sample_dir\Servers\Shard1\Data" -force -recurse -ErrorAction SilentlyContinue
- rd "$sample_dir\Servers\Shard2\Data" -force -recurse -ErrorAction SilentlyContinue
-
- rd "$sample_dir\Servers\Shard1\Plugins" -force -recurse -ErrorAction SilentlyContinue
- rd "$sample_dir\Servers\Shard2\Plugins" -force -recurse -ErrorAction SilentlyContinue
-
-
- del "$sample_dir\Servers\Shard1\RavenDB.exe" -force -recurse -ErrorAction SilentlyContinue
- del "$sample_dir\Servers\Shard2\RavenDB.exe" -force -recurse -ErrorAction SilentlyContinue
-}
-
function Get-DependencyPackageFiles
{
param([string]$packageName, [string]$frameworkVersion = "net40")
View
@@ -212,25 +212,25 @@ task RunAllTests -depends FullStorageTest,Test,TestSilverlight,StressTest
task Release -depends RunTests,DoRelease
task CopySamples {
- $samples = @("Raven.Sample.ShardClient", "Raven.Sample.Failover", "Raven.Sample.Replication", `
- "Raven.Sample.EventSourcing", "Raven.Bundles.Sample.EventSourcing.ShoppingCartAggregator", `
- "Raven.Samples.IndexReplication", "Raven.Samples.Includes", "Raven.Sample.SimpleClient", `
- "Raven.Sample.MultiTenancy", "Raven.Sample.Suggestions", `
- "Raven.Sample.LiveProjections", "Raven.Sample.FullTextSearch")
- $exclude = @("bin", "obj", "Data", "Plugins")
+ Copy-Item "$base_dir\Raven.Samples.sln" "$build_dir\Output\Samples" -force
+ Copy-Item $base_dir\Raven.VisualHost "$build_dir\Output\Samples\Raven.VisualHost" -recurse -force
+ $samples = Get-ChildItem $base_dir\Samples | Where-Object { $_.PsIsContainer }
+ $samples = $samples
foreach ($sample in $samples) {
- echo $sample
-
- Delete-Sample-Data-For-Release "$base_dir\Samples\$sample"
-
- cp "$base_dir\Samples\$sample" "$build_dir\Output\Samples" -recurse -force
-
- Delete-Sample-Data-For-Release "$build_dir\Output\Samples\$sample"
+ Write-Output $sample
+ Copy-Item "$base_dir\Samples\$sample" "$build_dir\Output\Samples\$sample" -recurse -force
+
+ Remove-Item "$sample_dir\bin" -force -recurse -ErrorAction SilentlyContinue
+ Remove-Item "$sample_dir\obj" -force -recurse -ErrorAction SilentlyContinue
+
+ Remove-Item "$sample_dir\Servers\Shard1\Data" -force -recurse -ErrorAction SilentlyContinue
+ Remove-Item "$sample_dir\Servers\Shard2\Data" -force -recurse -ErrorAction SilentlyContinue
+ Remove-Item "$sample_dir\Servers\Shard1\Plugins" -force -recurse -ErrorAction SilentlyContinue
+ Remove-Item "$sample_dir\Servers\Shard2\Plugins" -force -recurse -ErrorAction SilentlyContinue
+ Remove-Item "$sample_dir\Servers\Shard1\RavenDB.exe" -force -recurse -ErrorAction SilentlyContinue
+ Remove-Item "$sample_dir\Servers\Shard2\RavenDB.exe" -force -recurse -ErrorAction SilentlyContinue
}
-
- cp "$base_dir\Raven.Samples.sln" "$build_dir\Output\Samples" -force
- cp "$base_dir\Samples\Samples.ps1" "$build_dir\Output\Samples" -force
exec { .\Utilities\Binaries\Raven.Samples.PrepareForRelease.exe "$build_dir\Output\Samples\Raven.Samples.sln" "$build_dir\Output" }
}

0 comments on commit e56fae2

Please sign in to comment.