forked from ravendb/ravendb
/
IISDeploymentUtil.cs
44 lines (36 loc) · 1.2 KB
/
IISDeploymentUtil.cs
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.IO;
using Raven.Client;
using Raven.Database.Extensions;
namespace Raven.Tests
{
public class IISDeploymentUtil
{
protected const string WebDirectory = @".\RavenIISTestWeb\";
public static string DeployWebProjectToTestDirectory()
{
var fullPath = Path.GetFullPath(WebDirectory);
if (Directory.Exists(fullPath))
{
IOExtensions.DeleteDirectory(fullPath);
}
IOExtensions.CopyDirectory(GetRavenWebSource(), WebDirectory);
return fullPath;
}
private static string GetRavenWebSource()
{
foreach (var path in new[] { @".\..\..\..\Raven.Web", @".\_PublishedWebsites\Raven.Web" })
{
var fullPath = Path.GetFullPath(path);
if (Directory.Exists(fullPath) && File.Exists(Path.Combine(fullPath, "web.config")))
{
var combine = Path.Combine(fullPath, "bin");
if (!Directory.Exists(combine) || Directory.GetFiles(combine, "Raven.Web.dll").Length == 0)
throw new Exception("Raven.Web\\bin at " + fullPath + " was nonexistant or empty, you need to build Raven.Web.");
return fullPath;
}
}
throw new FileNotFoundException("Could not find source directory for Raven.Web");
}
}
}