Skip to content

Commit

Permalink
- Updated docs, license, and copyright.
Browse files Browse the repository at this point in the history
- Moved CakeModule assembly reference to assembly info.
- Changed target framework to 4.5
- Massive overhaul of how the Module works.
- Updated scripts
  • Loading branch information
larzw committed Nov 8, 2016
1 parent ff91509 commit 62a95d8
Show file tree
Hide file tree
Showing 24 changed files with 720 additions and 142 deletions.
2 changes: 1 addition & 1 deletion Documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The master branch status can be found on [README.md](https://github.com/larzw/Ca

# Contributing

All types of contributions are welcome! Please see the [Contributing](https://github.com/larzw/Cake.Paket/.github/CONTRIBUTING.md/) guidlines.
All types of contributions are welcome! Please see the [Contributing](https://github.com/larzw/Cake.Paket/blob/master/.github/CONTRIBUTING.md) guidlines.

# Questions

Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License

Copyright (c) .NET Foundation and Contributors
Copyright (c) 2016 Larz White

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="./Documentation/Images/CakePaketLogo.png" />
<a href="https://github.com/larzw/Cake.Paket"><img src="https://raw.githubusercontent.com/larzw/Cake.Paket/master/Documentation/Images/CakePaketLogo.png" /></a>
</p>

# Cake.Paket
Expand All @@ -9,7 +9,7 @@ Adds [Paket](https://fsprojects.github.io/Paket/) support to [Cake](http://cakeb
# Master Branch

|Tool|Information|Badge|
|:--:|:--:|:--:|
|:--|:--|:--|
|AppVeyor|Windows Build|[![AppVeyor branch](https://img.shields.io/appveyor/ci/larzw/Cake-Paket/master.svg)](https://ci.appveyor.com/project/larzw/cake-paket/branch/master)|
|Travis CI|Linux, OS X|[![Travis branch](https://img.shields.io/travis/larzw/Cake.Paket/master.svg)](https://travis-ci.org/larzw/Cake.Paket)|
|Read the Docs|Documentation|[![Documentation Status](https://readthedocs.org/projects/cakepaket/badge/?version=latest)](http://cakepaket.readthedocs.io/en/latest/?badge=latest)|
Expand All @@ -34,7 +34,7 @@ See the [Documentation](http://cakepaket.readthedocs.io/en/latest/) for addition

# Contributing

All types of contributions are welcome! Please see the [Contributing](.github/CONTRIBUTING.md) guidlines.
All types of contributions are welcome! Please see the [Contributing](https://github.com/larzw/Cake.Paket/blob/master/.github/CONTRIBUTING.md) guidlines.

# Questions

Expand Down
3 changes: 2 additions & 1 deletion Source/Cake.Paket.Addin/Cake.Paket.Addin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cake.Paket.Addin</RootNamespace>
<AssemblyName>Cake.Paket.Addin</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
4 changes: 2 additions & 2 deletions Source/Cake.Paket.Addin/paket.references
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group Cake.Paket
group cake.paket
Cake.Core
StyleCop.Analyzers
StyleCop.Analyzers
6 changes: 3 additions & 3 deletions Source/Cake.Paket.Addin/paket.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ description Paket addin for Cake.
summary Cake addin that extends Cake with ability to use paket.
licenseUrl https://github.com/larzw/Cake.Paket/blob/master/LICENSE
projectUrl https://github.com/larzw/Cake.Paket
iconUrl https://github.com/larzw/Cake.Paket/blob/master/Documentation/Images/CakePaketLogo.png
iconUrl https://raw.githubusercontent.com/larzw/Cake.Paket/master/Documentation/Images/CakePaketLogo.png
requireLicenseAcceptance false
copyright Copyright (c) 2016 Larz White
copyright Copyright (c) .NET Foundation and Contributors, Copyright (c) 2016 Larz White
releaseNotes Initial alpha Release.
tags Cake Script Build paket
files
bin/Release/Cake.Paket.Addin.dll
bin/Release/Cake.Paket.Addin.dll ==> lib/net45
32 changes: 30 additions & 2 deletions Source/Cake.Paket.Module/Cake.Paket.Module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cake.Paket.Module</RootNamespace>
<AssemblyName>Cake.Paket.Module</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -44,9 +45,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="INuGetContentResolver.cs" />
<Compile Include="NuGetContentResolver.cs" />
<Compile Include="PaketModule.cs" />
<Compile Include="PaketScriptProcessor.cs" />
<Compile Include="PaketPackageInstaller.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="V2\NuGetPackageReferenceSet.cs" />
<Compile Include="V2\NuGetV2ContentResolver.cs" />
<Compile Include="V3\NuGetV3ContentResolver.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down Expand Up @@ -81,4 +87,26 @@
<Paket>True</Paket>
</Analyzer>
</ItemGroup>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
<ItemGroup>
<Reference Include="Microsoft.Web.XmlTransform">
<HintPath>..\..\packages\cake.paket.module\Microsoft.Web.Xdt\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
<ItemGroup>
<Reference Include="NuGet.Core">
<HintPath>..\..\packages\cake.paket.module\NuGet.Core\lib\net40-Client\NuGet.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
23 changes: 23 additions & 0 deletions Source/Cake.Paket.Module/INuGetContentResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using Cake.Core.IO;
using Cake.Core.Packaging;

namespace Cake.Paket.Module
{
/// <summary>
/// Represents a file locator for NuGet packages that returns relevant
/// files for the current framework given the resource type.
/// </summary>
public interface INuGetContentResolver
{
/// <summary>
/// Gets the relevant files for a NuGet package
/// given a path and a resource type.
/// </summary>
/// <param name="path">The path to search.</param>
/// <param name="package">The package.</param>
/// <param name="type">The resource type.</param>
/// <returns>A collection of files.</returns>
IReadOnlyCollection<IFile> GetFiles(DirectoryPath path, PackageReference package, PackageType type);
}
}
93 changes: 93 additions & 0 deletions Source/Cake.Paket.Module/NuGetContentResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Cake.Core;
using Cake.Core.IO;
using Cake.Core.Packaging;

namespace Cake.Paket.Module
{
internal abstract class NuGetContentResolver : INuGetContentResolver
{
private readonly IFileSystem _fileSystem;
private readonly ICakeEnvironment _environment;
private readonly IGlobber _globber;

protected NuGetContentResolver(
IFileSystem fileSystem,
ICakeEnvironment environment,
IGlobber globber)
{
_fileSystem = fileSystem;
_environment = environment;
_globber = globber;
}

public IReadOnlyCollection<IFile> GetFiles(DirectoryPath path, PackageReference package, PackageType type)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}

if (type == PackageType.Addin)
{
return GetAddinAssemblies(path);
}
if (type == PackageType.Tool)
{
return GetToolFiles(path, package);
}

throw new InvalidOperationException("Unknown resource type.");
}

protected abstract IReadOnlyCollection<IFile> GetAddinAssemblies(DirectoryPath path);

private IReadOnlyCollection<IFile> GetToolFiles(DirectoryPath path, PackageReference package)
{
var result = new List<IFile>();
var toolDirectory = _fileSystem.GetDirectory(path);
if (toolDirectory.Exists)
{
result.AddRange(GetFiles(path, package));
}
return result;
}

private IEnumerable<IFile> GetFiles(DirectoryPath path, PackageReference package)
{
var collection = new FilePathCollection(new PathComparer(_environment));

// Get default files (exe and dll).
var patterns = new[] { path.FullPath + "/**/*.exe", path.FullPath + "/**/*.dll" };
foreach (var pattern in patterns)
{
collection.Add(_globber.GetFiles(pattern));
}

// Include files.
if (package.Parameters.ContainsKey("include"))
{
foreach (var include in package.Parameters["include"])
{
var includePath = string.Concat(path.FullPath, "/", include.TrimStart('/'));
collection.Add(_globber.GetFiles(includePath));
}
}

// Exclude files.
if (package.Parameters.ContainsKey("exclude"))
{
foreach (var exclude in package.Parameters["exclude"])
{
var excludePath = string.Concat(path.FullPath, "/", exclude.TrimStart('/'));
collection.Remove(_globber.GetFiles(excludePath));
}
}

// Return the files.
return collection.Select(p => _fileSystem.GetFile(p)).ToArray();
}
}
}
32 changes: 26 additions & 6 deletions Source/Cake.Paket.Module/PaketModule.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
using Cake.Core.Annotations;
using System;
using Cake.Core.Composition;
using Cake.Core.Scripting;

[assembly: CakeModule(typeof(Cake.Paket.Module.PaketModule))]
using Cake.Core.Packaging;

namespace Cake.Paket.Module
{
public class PaketModule : ICakeModule
/// <summary>
/// The module responsible for registering
/// default types in the Cake.Paket.Module assembly.
/// </summary>
public sealed class PaketModule : ICakeModule
{
/// <summary>
/// Performs custom registrations in the provided registrar.
/// </summary>
/// <param name="registrar">The container registrar.</param>
public void Register(ICakeContainerRegistrar registrar)
{
registrar.RegisterType<PaketScriptProcessor>().As<IScriptProcessor>().Singleton();
if (registrar == null)
{
throw new ArgumentNullException(nameof(registrar));
}

#if NETCORE
// NuGet V3
registrar.RegisterType<V3.NuGetV3ContentResolver>().As<INuGetContentResolver>().Singleton();
#else
// NuGet V2
registrar.RegisterType<V2.NuGetV2ContentResolver>().As<INuGetContentResolver>().Singleton();
#endif

// URI resource support.
registrar.RegisterType<PaketPackageInstaller>().As<IPackageInstaller>().Singleton();
}
}
}

0 comments on commit 62a95d8

Please sign in to comment.