-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of the base implementation.
- Loading branch information
Showing
10 changed files
with
433 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
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,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25420.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AppPackager", "Cake.AppPackager\Cake.AppPackager.csproj", "{1884E6AA-8468-4C87-8991-FEAC97090BFC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1884E6AA-8468-4C87-8991-FEAC97090BFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1884E6AA-8468-4C87-8991-FEAC97090BFC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1884E6AA-8468-4C87-8991-FEAC97090BFC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1884E6AA-8468-4C87-8991-FEAC97090BFC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
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 Cake.Core.Annotations; | ||
|
||
namespace Cake.AppPackager { | ||
/// <summary> | ||
/// <para>Contains functionality related to create app packages using <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/hh446767(v=vs.85).aspx">MakeAppx.exe</see>.</para> | ||
/// <para> | ||
/// In order to use the commands for this alias, App packager (MakeAppx) will need to be installed on the machine where | ||
/// the Cake script is being executed. This is typically achieved by installing the correct Windows SDK. | ||
/// </para> | ||
/// </summary> | ||
[CakeAliasCategory("AppPacakager")] | ||
public static class AppPackagerAliases {} | ||
} |
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,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
|
||
namespace Cake.AppPackager | ||
{ | ||
internal sealed class AppPackagerResolver : IAppPackagerResolver | ||
{ | ||
private readonly IFileSystem _fileSystem; | ||
private readonly ICakeEnvironment _environment; | ||
private readonly IRegistry _registry; | ||
private FilePath _appPackagerToolPath; | ||
|
||
public AppPackagerResolver(IFileSystem fileSystem, ICakeEnvironment environment, IRegistry registry) | ||
{ | ||
_fileSystem = fileSystem; | ||
_environment = environment; | ||
_registry = registry; | ||
|
||
if (fileSystem == null) | ||
{ | ||
throw new ArgumentNullException(nameof(fileSystem)); | ||
} | ||
if (registry == null) | ||
{ | ||
throw new ArgumentNullException(nameof(registry)); | ||
} | ||
if (environment == null) | ||
{ | ||
throw new ArgumentNullException(nameof(environment)); | ||
} | ||
} | ||
|
||
public FilePath GetPath() | ||
{ | ||
if (_appPackagerToolPath != null) | ||
{ | ||
return _appPackagerToolPath; | ||
} | ||
|
||
_appPackagerToolPath = GetFromDisc() ?? GetFromRegistry(); | ||
if (_appPackagerToolPath == null) | ||
{ | ||
throw new CakeException("Failed to find MakeAppx.exe."); | ||
} | ||
|
||
return _appPackagerToolPath; | ||
} | ||
|
||
private FilePath GetFromDisc() | ||
{ | ||
var programFilesPath = _environment.Platform.Is64Bit | ||
? _environment.GetSpecialPath(SpecialPath.ProgramFilesX86) | ||
: _environment.GetSpecialPath(SpecialPath.ProgramFiles); | ||
|
||
var files = new List<FilePath>(); | ||
if (_environment.Platform.Is64Bit) | ||
{ | ||
files.Add(programFilesPath.Combine(@"Windows Kits\10\bin\x64").CombineWithFilePath("makeappx.exe")); | ||
files.Add(programFilesPath.Combine(@"Windows Kits\8.1\bin\x64").CombineWithFilePath("makeappx.exe")); | ||
files.Add(programFilesPath.Combine(@"Windows Kits\8.0\bin\x64").CombineWithFilePath("makeappx.exe")); | ||
} | ||
else | ||
{ | ||
files.Add(programFilesPath.Combine(@"Windows Kits\10\bin\x64").CombineWithFilePath("makeappx.exe")); | ||
files.Add(programFilesPath.Combine(@"Windows Kits\8.1\bin\x86").CombineWithFilePath("makeappx.exe")); | ||
files.Add(programFilesPath.Combine(@"Windows Kits\8.0\bin\x86").CombineWithFilePath("makeappx.exe")); | ||
} | ||
|
||
return files.FirstOrDefault(file => _fileSystem.Exist(file)); | ||
} | ||
|
||
private FilePath GetFromRegistry() | ||
{ | ||
using (var root = _registry.LocalMachine.OpenKey("Software\\Microsoft\\Microsoft SDKs\\Windows")) | ||
{ | ||
if (root == null) | ||
{ | ||
return null; | ||
} | ||
|
||
var keyName = root.GetSubKeyNames(); | ||
foreach (var key in keyName) | ||
{ | ||
var sdkKey = root.OpenKey(key); | ||
var installationFolder = sdkKey?.GetValue("InstallationFolder") as string; | ||
if (string.IsNullOrWhiteSpace(installationFolder)) continue; | ||
var installationPath = new DirectoryPath(installationFolder); | ||
var signToolPath = installationPath.CombineWithFilePath("bin\\makeappx.exe"); | ||
|
||
if (_fileSystem.Exist(signToolPath)) | ||
{ | ||
return signToolPath; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} |
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,81 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
using Cake.Core.Tooling; | ||
|
||
namespace Cake.AppPackager { | ||
/// <summary> | ||
/// The App Packager (makeappx) assembly runner. | ||
/// </summary> | ||
public sealed class AppPackagerRunner : Tool<AppPackagerSettings> { | ||
private readonly IAppPackagerResolver _resolver; | ||
private readonly IFileSystem _fileSystem; | ||
private readonly ICakeEnvironment _environment; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AppPackagerRunner"/> class. | ||
/// </summary> | ||
/// <param name="fileSystem">The file system.</param> | ||
/// <param name="environment">The environment.</param> | ||
/// <param name="processRunner">The process runner.</param> | ||
/// <param name="tools">The tool locator.</param> | ||
/// <param name="registry">The registry.</param> | ||
public AppPackagerRunner(IFileSystem fileSystem, | ||
ICakeEnvironment environment, | ||
IProcessRunner processRunner, | ||
IToolLocator tools, | ||
IRegistry registry) : this(fileSystem, environment, processRunner, tools, registry, null) {} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AppPackagerRunner"/> class. | ||
/// </summary> | ||
/// <param name="fileSystem">The file system.</param> | ||
/// <param name="environment">The environment.</param> | ||
/// <param name="processRunner">The process runner.</param> | ||
/// <param name="tools">The tool locator.</param> | ||
/// <param name="registry">The registry.</param> | ||
/// <param name="resolver">The resolver.</param> | ||
internal AppPackagerRunner(IFileSystem fileSystem, | ||
ICakeEnvironment environment, | ||
IProcessRunner processRunner, | ||
IToolLocator tools, | ||
IRegistry registry, | ||
IAppPackagerResolver resolver) : base(fileSystem, environment, processRunner, tools) { | ||
_fileSystem = fileSystem; | ||
_environment = environment; | ||
_resolver = resolver ?? new AppPackagerResolver(_fileSystem, _environment, registry); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Gets the name of the tool. | ||
/// </summary> | ||
/// <returns> | ||
/// The name of the tool (<c>App Packager</c>). | ||
/// </returns> | ||
protected override string GetToolName() { | ||
return "App Packager"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the possible names of the tool executable. | ||
/// </summary> | ||
/// <returns>The tool executable name.</returns> | ||
protected override IEnumerable<string> GetToolExecutableNames() { | ||
return new[] {"makeappx.exe"}; | ||
} | ||
|
||
/// <summary> | ||
/// Gets alternative file paths which the tool may exist in | ||
/// </summary> | ||
/// <param name="settings">The settings.</param> | ||
/// <returns>The default tool path.</returns> | ||
protected override IEnumerable<FilePath> GetAlternativeToolPaths(AppPackagerSettings settings) { | ||
var path = _resolver.GetPath(); | ||
return path != null | ||
? new[] {path} | ||
: Enumerable.Empty<FilePath>(); | ||
} | ||
} | ||
} |
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,34 @@ | ||
using Cake.Core.Tooling; | ||
|
||
namespace Cake.AppPackager | ||
{ | ||
/// <summary> | ||
/// Contains settings used by <see cref="AppPackagerRunner"/> | ||
/// </summary> | ||
public sealed class AppPackagerSettings : ToolSettings | ||
{ | ||
/// <summary> | ||
/// Gets or sets if the validation should be disabled for localized packages. | ||
/// </summary> | ||
public bool Localized { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets if the output should be overwritten. | ||
/// </summary> | ||
public bool OverwriteOutput { get; set; } | ||
/// <summary> | ||
/// Gets or sets if overwritting the output should be prevented. | ||
/// </summary> | ||
public bool PreventOverwriteOutput { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets if the validation should be skipped. | ||
/// </summary> | ||
public bool SkipSemanticValidation { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets if verbose logging is enabled. | ||
/// </summary> | ||
public bool EnableVerboseLogging { 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,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{1884E6AA-8468-4C87-8991-FEAC97090BFC}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Cake.AppPackager</RootNamespace> | ||
<AssemblyName>Cake.AppPackager</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<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|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Cake.Core, Version=0.16.2.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Cake.Core.0.16.2\lib\net45\Cake.Core.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AppPackagerAliases.cs" /> | ||
<Compile Include="AppPackagerResolver.cs" /> | ||
<Compile Include="AppPackagerRunner.cs" /> | ||
<Compile Include="AppPackagerSettings.cs" /> | ||
<Compile Include="IAppPackagerResolver.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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> |
Oops, something went wrong.