forked from projectkudu/kudu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Kudu.Console and exe that performs deployment.
Changed logic to perform deployment as part of git push.
- Loading branch information
Showing
25 changed files
with
516 additions
and
226 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,84 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{E2B0EE28-8C96-497A-AB08-605B9FD841E9}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Kudu.Console</RootNamespace> | ||
<AssemblyName>kudu</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<TargetFrameworkProfile> | ||
</TargetFrameworkProfile> | ||
<FileAlignment>512</FileAlignment> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> | ||
<RestorePackages>true</RestorePackages> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.IO.Abstractions"> | ||
<HintPath>..\packages\System.IO.Abstractions.1.4.0.12\lib\net35\System.IO.Abstractions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Common\Constants.cs"> | ||
<Link>Constants.cs</Link> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Kudu.Contracts\Kudu.Contracts.csproj"> | ||
<Project>{EC0ED988-2C60-4F31-A434-645E048BFD95}</Project> | ||
<Name>Kudu.Contracts</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Kudu.Core\Kudu.Core.csproj"> | ||
<Project>{5320177C-725A-44BD-8FA6-F88D9725B46C}</Project> | ||
<Name>Kudu.Core</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Infrastructure\" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
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,132 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Abstractions; | ||
using Kudu.Core; | ||
using Kudu.Core.Deployment; | ||
using Kudu.Core.Infrastructure; | ||
using Kudu.Core.SourceControl.Git; | ||
using Kudu.Core.Tracing; | ||
|
||
namespace Kudu.Console | ||
{ | ||
class Program | ||
{ | ||
static int Main(string[] args) | ||
{ | ||
if (args.Length < 2) | ||
{ | ||
System.Console.WriteLine("Usage: kudu.exe {appRoot} {wapTargets}"); | ||
return 1; | ||
} | ||
|
||
while (!System.Diagnostics.Debugger.IsAttached) | ||
{ | ||
|
||
} | ||
|
||
System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); | ||
|
||
var appRoot = args[0]; | ||
var wapTargets = args[1]; | ||
string nugetCachePath = null; | ||
|
||
IEnvironment env = GetEnvironment(appRoot, nugetCachePath); | ||
|
||
// Setup the trace | ||
string tracePath = Path.Combine(env.ApplicationRootPath, Constants.TracePath, Constants.TraceFile); | ||
var traceFactory = new TracerFactory(() => new Tracer(tracePath)); | ||
|
||
// Calculate the lock path | ||
string lockPath = Path.Combine(env.ApplicationRootPath, Constants.LockPath); | ||
string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); | ||
var deploymentLock = new LockFile(traceFactory, deploymentLockPath); | ||
|
||
var fs = new FileSystem(); | ||
var buildPropertyProvider = new BuildPropertyProvider(wapTargets); | ||
var builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); | ||
var serverRepository = new GitDeploymentRepository(env.DeploymentRepositoryPath, traceFactory); | ||
|
||
var logger = new ConsoleLogger(); | ||
var deploymentManager = new DeploymentManager(serverRepository, | ||
builderFactory, | ||
env, | ||
fs, | ||
traceFactory, | ||
deploymentLock, | ||
logger); | ||
|
||
try | ||
{ | ||
deploymentManager.Deploy(); | ||
} | ||
catch(System.Exception ex) | ||
{ | ||
System.Console.Error.WriteLine(ex.Message); | ||
|
||
throw; | ||
} | ||
|
||
if (logger.HasErrors) | ||
{ | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
private static IEnvironment GetEnvironment(string root, string nugetCachePath) | ||
{ | ||
string deployPath = Path.Combine(root, Constants.WebRoot); | ||
string deployCachePath = Path.Combine(root, Constants.DeploymentCachePath); | ||
string deploymentRepositoryPath = Path.Combine(root, Constants.RepositoryPath); | ||
string tempPath = Path.GetTempPath(); | ||
string deploymentTempPath = Path.Combine(tempPath, Constants.RepositoryPath); | ||
|
||
return new Environment(root, | ||
tempPath, | ||
() => deploymentRepositoryPath, | ||
() => null, | ||
deployPath, | ||
deployCachePath, | ||
nugetCachePath); | ||
} | ||
|
||
private class BuildPropertyProvider : IBuildPropertyProvider | ||
{ | ||
private readonly string _extensionsPath; | ||
|
||
public BuildPropertyProvider(string extensionsPath) | ||
{ | ||
_extensionsPath = extensionsPath; | ||
} | ||
|
||
public IDictionary<string, string> GetProperties() | ||
{ | ||
return new Dictionary<string, string> { | ||
{ "MSBuildExtensionsPath32", _extensionsPath } | ||
}; | ||
} | ||
} | ||
|
||
private class ConsoleLogger : ILogger | ||
{ | ||
public ILogger Log(string value, LogEntryType type) | ||
{ | ||
if (type == LogEntryType.Error) | ||
{ | ||
HasErrors = true; | ||
|
||
System.Console.Error.WriteLine(value); | ||
} | ||
else | ||
{ | ||
System.Console.WriteLine(value); | ||
} | ||
|
||
return NullLogger.Instance; | ||
} | ||
|
||
public bool HasErrors { get; set; } | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Kudu.Console")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("Kudu.Console")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft 2012")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("1d669d37-1397-4533-8bb7-561c46217f5d")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,3 @@ | ||
<?xml version="1.0"?> | ||
<configuration> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="System.IO.Abstractions" version="1.4.0.12" /> | ||
</packages> |
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,7 @@ | ||
namespace Kudu.Core.Deployment | ||
{ | ||
public interface IDeploymentCommandGenerator | ||
{ | ||
string GetDeploymentCommand(); | ||
} | ||
} |
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
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,13 @@ | ||
using Kudu.Core.SourceControl; | ||
|
||
namespace Kudu.Core.SourceControl | ||
{ | ||
public interface IDeploymentRepository | ||
{ | ||
void Clean(); | ||
ChangeSet GetChangeSet(string id); | ||
PushInfo GetPushInfo(); | ||
void Update(); | ||
void Update(string id); | ||
} | ||
} |
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,20 @@ | ||
namespace Kudu.Core.Deployment | ||
{ | ||
internal class CascadeLogger : ILogger | ||
{ | ||
private readonly ILogger _primary; | ||
private readonly ILogger _secondary; | ||
|
||
public CascadeLogger(ILogger primary, ILogger secondary) | ||
{ | ||
_primary = primary; | ||
_secondary = secondary; | ||
} | ||
|
||
public ILogger Log(string value, LogEntryType type) | ||
{ | ||
_secondary.Log(value, type); | ||
return _primary.Log(value, type); | ||
} | ||
} | ||
} |
Oops, something went wrong.