forked from RagingKore/Cake.Web
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Symbianx/feature-create-virtual-directories
Added functionality to manage Virtual Directories
- Loading branch information
Showing
5 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using Cake.Core; | ||
using Cake.Core.Annotations; | ||
using Microsoft.Web.Administration; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Cake.IIS | ||
{ | ||
/// <summary> | ||
/// Contains aliases for working with IIS virtual applications. | ||
/// </summary> | ||
[CakeAliasCategory("IIS")] | ||
[CakeNamespaceImport("Microsoft.Web.Administration")] | ||
public static class VirtualDirectoryAliases | ||
{ | ||
/// <summary> | ||
/// Adds site virtual directory to local IIS. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="settings">The virtual directory settings.</param> | ||
[CakeMethodAlias] | ||
public static void AddSiteVirtualDirectory(this ICakeContext context, VirtualDirectorySettings settings) | ||
{ | ||
context.AddSiteVirtualDirectory("", settings); | ||
} | ||
|
||
/// <summary> | ||
/// Adds site virtual directory to remote IIS. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="server">The remote server name.</param> | ||
/// <param name="settings">The virtual directory settings.</param> | ||
[CakeMethodAlias] | ||
public static void AddSiteVirtualDirectory(this ICakeContext context, string server, VirtualDirectorySettings settings) | ||
{ | ||
using (ServerManager manager = BaseManager.Connect(server)) | ||
{ | ||
settings.ComputerName = server; | ||
|
||
WebsiteManager | ||
.Using(context.Environment, context.Log, manager) | ||
.AddVirtualDirectory(settings); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Removes site virtual directory from local IIS. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="settings">The virtual directory settings.</param> | ||
[CakeMethodAlias] | ||
public static void RemoveSiteVirtualDirectory(this ICakeContext context, VirtualDirectorySettings settings) | ||
{ | ||
context.RemoveSiteVirtualDirectory("", settings); | ||
} | ||
|
||
/// <summary> | ||
/// Removes site virtual directory from remote IIS. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="server">The remote server name.</param> | ||
/// <param name="settings">The virtual directory settings.</param> | ||
[CakeMethodAlias] | ||
public static void RemoveSiteVirtualDirectory(this ICakeContext context, string server, VirtualDirectorySettings settings) | ||
{ | ||
using (ServerManager manager = BaseManager.Connect(server)) | ||
{ | ||
WebsiteManager | ||
.Using(context.Environment, context.Log, manager) | ||
.RemoveVirtualDirectory(settings); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Checks if site virtual directory exists in remote IIS. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="server">The remote server name.</param> | ||
/// <param name="settings">The virtual directory settings.</param> | ||
[CakeMethodAlias] | ||
public static bool SiteVirtualDirectoryExists(this ICakeContext context, string server, VirtualDirectorySettings settings) | ||
{ | ||
using (ServerManager manager = BaseManager.Connect(server)) | ||
{ | ||
return WebsiteManager | ||
.Using(context.Environment, context.Log, manager) | ||
.VirtualDirectoryExists(settings); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Cake.Core.IO; | ||
|
||
namespace Cake.IIS | ||
{ | ||
public class VirtualDirectorySettings : IDirectorySettings | ||
{ | ||
#region Constructor (1) | ||
public VirtualDirectorySettings() | ||
{ | ||
|
||
} | ||
#endregion | ||
|
||
#region Properties (8) | ||
|
||
public string ComputerName { get; set; } | ||
|
||
public DirectoryPath PhysicalDirectory { get; set; } | ||
|
||
public DirectoryPath WorkingDirectory { get; set; } | ||
public string SiteName { get; set; } | ||
|
||
public string ApplicationPath { get; set; } | ||
|
||
public string Path { get; set; } | ||
|
||
public AuthenticationSettings Authentication { get; set; } | ||
|
||
public AuthorizationSettings Authorization { get; set; } | ||
|
||
#endregion | ||
|
||
|
||
} | ||
} |