Skip to content

Commit

Permalink
Updated to support using extension methods elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll committed Jul 4, 2019
1 parent 7837648 commit b2efeba
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 113 deletions.
7 changes: 4 additions & 3 deletions Packages.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup>
<GlobalPackageReference Include="Rocket.Surgery.Build.Metadata" Version="3.3.3" Condition="'$(MSBuildProjectName)'!='.build'"/>
<GlobalPackageReference Include="Rocket.Surgery.Build.Metadata" Version="3.3.3" Condition="'$(MSBuildProjectName)'!='.build'" />
<!-- <GlobalPackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" /> -->
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19270-01" />
<GlobalPackageReference Include="Roslynator.Analyzers" Version="2.1.0-rc" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Nuke.Common" Version="0.20.1" />
<PackageReference Update="GitVersion.CommandLine.DotNetCore" Version="4.0.1-beta1-49" />
<PackageReference Update="Rocket.Surgery.Nuke" Version="0.1.0-beta.7" />
<PackageReference Update="GitVersion.CommandLine.DotNetCore" Version="5.0.0-beta4-9" />
<PackageReference Update="ReportGenerator" Version="4.2.5" />
</ItemGroup>
<ItemGroup>
Expand All @@ -17,7 +18,7 @@
<PackageReference Update="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Rocket.Surgery.Extensions.Testing" Version="1.1.8" />
<PackageReference Update="Rocket.Surgery.Extensions.Testing" Version="1.1.9" />
<PackageReference Update="Autofac.Extras.FakeItEasy" Version="5.0.1" />
<PackageReference Update="Bogus" Version="28.0.1" />
<PackageReference Update="coverlet.collector" Version="1.0.1" />
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resources:
- repository: rsg
type: github
name: RocketSurgeonsGuild/AzureDevopsTemplates
# ref: refs/tags/v0.5.11
ref: refs/tags/v0.6.0
endpoint: github

variables:
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version
else
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"

# Download install script
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
mkdir -p "$TEMP_DIRECTORY"
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
chmod +x "$DOTNET_INSTALL_FILE"

# Install by channel or version
if [ -z ${DOTNET_VERSION+x} ]; then
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
Expand Down
3 changes: 2 additions & 1 deletion src/Nuke/CustomDotNetBuildExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

namespace Rocket.Surgery.Nuke
{
static class CustomDotNetBuildExtensions
public static class CustomDotNetBuildExtensions
{
public static T SetBinaryLogger<T>(this T settings, AbsolutePath path, MSBuildBinaryLogImports imports) where T : ToolSettings
{
var existingArgs = settings.ArgumentConfigurator;
return settings.SetArgumentConfigurator(args =>
existingArgs(args).Add($"/bl:{path};ProjectImports={imports}"));
}

public static T SetFileLogger<T>(this T settings, AbsolutePath path, Verbosity verbosity) where T : ToolSettings
{
var existingArgs = settings.ArgumentConfigurator;
Expand Down
108 changes: 108 additions & 0 deletions src/Nuke/DotNetCoreBuild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using Nuke.Common;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Tools.VSTest;
using Nuke.Common.Tools.VSWhere;

namespace Rocket.Surgery.Nuke
{
public abstract class DotNetCoreBuild : RocketBoosterBuild
{
public Target Core => _ => _;

public Target InstallTools => _ => _
.DependsOn(Clean)
.DependentFor(Core)
.Unlisted()
.Executes(() => DotNet("tool restore"));

public Target Restore => _ => _
.DependentFor(Core)
.DependsOn(InstallTools)
.Executes(() =>
{
DotNetRestore(s => s
.SetProjectFile(Solution)
.SetDisableParallel(true)
.SetBinaryLogger(LogsDirectory / "restore.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "restore.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
);
});

public Target Build => _ => _
.DependsOn(Restore)
.DependentFor(Core)
.Executes(() =>
{
DotNetBuild(s => s
.SetProjectFile(Solution)
.SetBinaryLogger(LogsDirectory / "build.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "build.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
.SetConfiguration(Configuration)
.EnableNoRestore());
});

public Target Test => _ => _
.DependsOn(Build)
.DependentFor(Core)
.DependentFor(Pack)
.Triggers(Generate_Code_Coverage_Reports)
.OnlyWhenStatic(() => TestDirectory.GlobFiles("**/*.csproj").Count > 0)
.WhenSkipped(DependencyBehavior.Execute)
.Executes(() =>
{
// TestDirectory.GlobFiles("**/*.csproj")
// .ForEach((Project) =>
// {
// var name = Path.GetFileNameWithoutExtension(Project).ToLowerInvariant();
// // var name = Project.
// DotNetTest(s => s
// .SetProjectFile(Project)
// .SetBinaryLogger(LogsDirectory / $"{name}.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
// .SetFileLogger(LogsDirectory / $"{name}.log", Verbosity)
// .SetGitVersionEnvironment(GitVersion)
// .SetConfiguration(Configuration)
// .EnableNoRestore()
// .SetLogger($"trx;LogFileName={TestResultsDirectory / $"{name}.trx"}")
// .SetProperty("CollectCoverage", true)
// .SetProperty("CoverageDirectory", CoverageDirectory)
// .SetProperty("VSTestResultsDirectory", TestResultsDirectory));
// });
DotNetTest(s => s
.SetProjectFile(Solution)
.SetBinaryLogger(LogsDirectory / "test.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "test.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
.SetConfiguration(Configuration)
.EnableNoRestore()
.SetLogger($"trx")
.SetProperty("CollectCoverage", true)
.SetProperty("CoverageDirectory", CoverageDirectory)
.SetProperty("VSTestResultsDirectory", TestResultsDirectory));
});

public Target Pack => _ => _
.DependsOn(Build)
.DependentFor(Core)
.Executes(() =>
{
DotNetPack(s => s
.SetProject(Solution)
.SetVersion(GitVersion.FullSemVer)
.SetIncludeSource(IncludeSource)
.SetIncludeSymbols(IncludeSymbols)
.SetBinaryLogger(LogsDirectory / "pack.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "pack.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
.SetConfiguration(Configuration)
.EnableNoRestore()
.SetOutputDirectory(NuGetPackageDirectory));
});
}
}
102 changes: 0 additions & 102 deletions src/Nuke/RocketBoosterBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Tools.VSTest;
using Nuke.Common.Tools.ReportGenerator;
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;
using Nuke.Common.Tools.VSWhere;
using static Nuke.Common.Tools.VSWhere.VSWhereTasks;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -96,101 +91,4 @@ public abstract class RocketBoosterBuild : NukeBuild
RenameFile(CoverageDirectory / "Cobertura.xml", "solution.xml");
});
}

public abstract class DotNetCoreBuild : RocketBoosterBuild
{
public Target Core => _ => _;

public Target InstallTools => _ => _
.DependsOn(Clean)
.DependentFor(Core)
.Unlisted()
.Executes(() => DotNet("tool restore"));

public Target Restore => _ => _
.DependentFor(Core)
.DependsOn(InstallTools)
.Executes(() =>
{
DotNetRestore(s => s
.SetProjectFile(Solution)
.SetDisableParallel(true)
.SetBinaryLogger(LogsDirectory / "restore.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "restore.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
);
});

public Target Build => _ => _
.DependsOn(Restore)
.DependentFor(Core)
.Executes(() =>
{
DotNetBuild(s => s
.SetProjectFile(Solution)
.SetBinaryLogger(LogsDirectory / "build.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "build.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
.SetConfiguration(Configuration)
.EnableNoRestore());
});

public Target Test => _ => _
.DependsOn(Build)
.DependentFor(Core)
.DependentFor(Pack)
.Triggers(Generate_Code_Coverage_Reports)
.OnlyWhenStatic(() => TestDirectory.GlobFiles("**/*.csproj").Count > 0)
.WhenSkipped(DependencyBehavior.Execute)
.Executes(() =>
{
// TestDirectory.GlobFiles("**/*.csproj")
// .ForEach((Project) =>
// {
// var name = Path.GetFileNameWithoutExtension(Project).ToLowerInvariant();
// // var name = Project.
// DotNetTest(s => s
// .SetProjectFile(Project)
// .SetBinaryLogger(LogsDirectory / $"{name}.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
// .SetFileLogger(LogsDirectory / $"{name}.log", Verbosity)
// .SetGitVersionEnvironment(GitVersion)
// .SetConfiguration(Configuration)
// .EnableNoRestore()
// .SetLogger($"trx;LogFileName={TestResultsDirectory / $"{name}.trx"}")
// .SetProperty("CollectCoverage", true)
// .SetProperty("CoverageDirectory", CoverageDirectory)
// .SetProperty("VSTestResultsDirectory", TestResultsDirectory));
// });
DotNetTest(s => s
.SetProjectFile(Solution)
.SetBinaryLogger(LogsDirectory / "test.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "test.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
.SetConfiguration(Configuration)
.EnableNoRestore()
.SetLogger($"trx")
.SetProperty("CollectCoverage", true)
.SetProperty("CoverageDirectory", CoverageDirectory)
.SetProperty("VSTestResultsDirectory", TestResultsDirectory));
});

public Target Pack => _ => _
.DependsOn(Build)
.DependentFor(Core)
.Executes(() =>
{
DotNetPack(s => s
.SetProject(Solution)
.SetVersion(GitVersion.FullSemVer)
.SetIncludeSource(IncludeSource)
.SetIncludeSymbols(IncludeSymbols)
.SetBinaryLogger(LogsDirectory / "pack.binlog", IsLocalBuild ? MSBuildBinaryLogImports.None : MSBuildBinaryLogImports.Embed)
.SetFileLogger(LogsDirectory / "pack.log", Verbosity)
.SetGitVersionEnvironment(GitVersion)
.SetConfiguration(Configuration)
.EnableNoRestore()
.SetOutputDirectory(NuGetPackageDirectory));
});
}
}
4 changes: 0 additions & 4 deletions tools/packages.config

This file was deleted.

0 comments on commit b2efeba

Please sign in to comment.