Skip to content

Commit 3042df4

Browse files
committed
nuke build
1 parent 87ad45f commit 3042df4

File tree

108 files changed

+349
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+349
-5
lines changed

.nuke

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ReportDotNet.sln

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Vyacheslav Mostovoy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

ReportDotNet.sln

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
44
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Core", "ReportDotNet.Core\ReportDotNet.Core.csproj", "{3BE01964-7B8B-40E1-9BC1-8FA13AB274AE}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Core", "src\ReportDotNet.Core\ReportDotNet.Core.csproj", "{3BE01964-7B8B-40E1-9BC1-8FA13AB274AE}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Docx", "ReportDotNet.Docx\ReportDotNet.Docx.csproj", "{4D668235-EDD3-4C25-9CA7-59878E3D4FFB}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Docx", "src\ReportDotNet.Docx\ReportDotNet.Docx.csproj", "{4D668235-EDD3-4C25-9CA7-59878E3D4FFB}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Core.Tests", "ReportDotNet.Core.Tests\ReportDotNet.Core.Tests.csproj", "{92207667-DC9F-4DE8-954D-0067839B89CD}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Core.Tests", "tests\ReportDotNet.Core.Tests\ReportDotNet.Core.Tests.csproj", "{92207667-DC9F-4DE8-954D-0067839B89CD}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Web", "ReportDotNet.Web\ReportDotNet.Web.csproj", "{B0ED4323-F629-4FDC-AC84-7E7976D110FD}"
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportDotNet.Web", "src\ReportDotNet.Web\ReportDotNet.Web.csproj", "{B0ED4323-F629-4FDC-AC84-7E7976D110FD}"
13+
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{50E9C5BF-6D6E-4315-B5ED-2874B79DAC24}"
1315
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|Any CPU = Debug|Any CPU
1719
Release|Any CPU = Release|Any CPU
1820
EndGlobalSection
1921
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{50E9C5BF-6D6E-4315-B5ED-2874B79DAC24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{50E9C5BF-6D6E-4315-B5ED-2874B79DAC24}.Release|Any CPU.ActiveCfg = Release|Any CPU
2024
{3BE01964-7B8B-40E1-9BC1-8FA13AB274AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2125
{3BE01964-7B8B-40E1-9BC1-8FA13AB274AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
2226
{3BE01964-7B8B-40E1-9BC1-8FA13AB274AE}.Release|Any CPU.ActiveCfg = Release|Any CPU

ReportDotNet.sln.DotSettings

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
66
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
77
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
8+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
89
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
910
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
1011
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>

build.cmd

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:; set -eo pipefail
2+
:; ./build.sh "$@"
3+
:; exit $?
4+
5+
@ECHO OFF
6+
powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.ps1 %*

build.ps1

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[CmdletBinding()]
2+
Param(
3+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
4+
[string[]]$BuildArguments
5+
)
6+
7+
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
8+
9+
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 }
10+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
11+
12+
###########################################################################
13+
# CONFIGURATION
14+
###########################################################################
15+
16+
$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
17+
$TempDirectory = "$PSScriptRoot\\.tmp"
18+
19+
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
20+
$DotNetInstallUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1"
21+
$DotNetChannel = "Current"
22+
23+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
24+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
25+
26+
###########################################################################
27+
# EXECUTION
28+
###########################################################################
29+
30+
function ExecSafe([scriptblock] $cmd) {
31+
& $cmd
32+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
33+
}
34+
35+
# If global.json exists, load expected version
36+
if (Test-Path $DotNetGlobalFile) {
37+
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
38+
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
39+
$DotNetVersion = $DotNetGlobal.sdk.version
40+
}
41+
}
42+
43+
# If dotnet is installed locally, and expected version is not set or installation matches the expected version
44+
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
45+
(!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
46+
$env:DOTNET_EXE = (Get-Command "dotnet").Path
47+
}
48+
else {
49+
$DotNetDirectory = "$TempDirectory\dotnet-win"
50+
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
51+
52+
# Download install script
53+
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
54+
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
55+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
56+
57+
# Install by channel or version
58+
if (!(Test-Path variable:DotNetVersion)) {
59+
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
60+
} else {
61+
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
62+
}
63+
}
64+
65+
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
66+
67+
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet }
68+
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

build.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
echo $(bash --version 2>&1 | head -n 1)
4+
5+
set -eo pipefail
6+
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
7+
8+
###########################################################################
9+
# CONFIGURATION
10+
###########################################################################
11+
12+
BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
13+
TEMP_DIRECTORY="$SCRIPT_DIR//.tmp"
14+
15+
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
16+
DOTNET_INSTALL_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh"
17+
DOTNET_CHANNEL="Current"
18+
19+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
20+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
21+
22+
###########################################################################
23+
# EXECUTION
24+
###########################################################################
25+
26+
function FirstJsonValue {
27+
perl -nle 'print $1 if m{"'$1'": "([^"]+)",?}' <<< ${@:2}
28+
}
29+
30+
# If global.json exists, load expected version
31+
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
32+
DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE"))
33+
if [[ "$DOTNET_VERSION" == "" ]]; then
34+
unset DOTNET_VERSION
35+
fi
36+
fi
37+
38+
# If dotnet is installed locally, and expected version is not set or installation matches the expected version
39+
if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then
40+
export DOTNET_EXE="$(command -v dotnet)"
41+
else
42+
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
43+
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
44+
45+
# Download install script
46+
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
47+
mkdir -p "$TEMP_DIRECTORY"
48+
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
49+
chmod +x "$DOTNET_INSTALL_FILE"
50+
51+
# Install by channel or version
52+
if [[ -z ${DOTNET_VERSION+x} ]]; then
53+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
54+
else
55+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
56+
fi
57+
fi
58+
59+
echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
60+
61+
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet
62+
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"

build/.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[*.cs]
2+
dotnet_style_qualification_for_field = false:warning
3+
dotnet_style_qualification_for_property = false:warning
4+
dotnet_style_qualification_for_method = false:warning
5+
dotnet_style_qualification_for_event = false:warning
6+
dotnet_style_require_accessibility_modifiers = never:warning
7+
8+
csharp_style_expression_bodied_methods = true:silent
9+
csharp_style_expression_bodied_properties = true:warning
10+
csharp_style_expression_bodied_indexers = true:warning
11+
csharp_style_expression_bodied_accessors = true:warning

build/Build.cs

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
using System.Linq;
2+
using Nuke.Common;
3+
using Nuke.Common.Execution;
4+
using Nuke.Common.Git;
5+
using Nuke.Common.IO;
6+
using Nuke.Common.ProjectModel;
7+
using Nuke.Common.Tooling;
8+
using Nuke.Common.Tools.DotNet;
9+
using Nuke.Common.Tools.GitHub;
10+
using Nuke.Common.Tools.GitVersion;
11+
using Nuke.Common.Utilities.Collections;
12+
using static Nuke.Common.IO.FileSystemTasks;
13+
using static Nuke.Common.IO.PathConstruction;
14+
using static Nuke.Common.Tools.DotNet.DotNetTasks;
15+
16+
[CheckBuildProjectConfigurations]
17+
class Build: NukeBuild
18+
{
19+
public static int Main() => Execute<Build>(x => x.Compile);
20+
21+
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
22+
readonly Configuration Configuration =
23+
IsLocalBuild
24+
? Configuration.Debug
25+
: Configuration.Release;
26+
27+
[Parameter("NuGet api key")] readonly string ApiKey;
28+
readonly string LicenseFile = RootDirectory / "LICENSE";
29+
30+
[Parameter("Local nuget source")] readonly string LocalNugetSource;
31+
32+
[Solution] readonly Solution Solution;
33+
[GitRepository] readonly GitRepository GitRepository;
34+
[GitVersion] readonly GitVersion GitVersion;
35+
36+
AbsolutePath SourceDirectory => RootDirectory / "src";
37+
AbsolutePath TestsDirectory => RootDirectory / "tests";
38+
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
39+
40+
Target Clean
41+
=> _ => _
42+
.Before(Restore)
43+
.Executes(() =>
44+
{
45+
SourceDirectory.GlobDirectories("**/bin", "**/obj")
46+
.ToArray()
47+
.ForEach(DeleteDirectory);
48+
TestsDirectory.GlobDirectories("**/bin", "**/obj")
49+
.ToArray()
50+
.ForEach(DeleteDirectory);
51+
EnsureCleanDirectory(ArtifactsDirectory);
52+
});
53+
54+
Target Restore
55+
=> _ => _
56+
.Executes(() =>
57+
{
58+
DotNetRestore(s => s
59+
.SetProjectFile(Solution));
60+
});
61+
62+
Target Compile
63+
=> _ => _
64+
.DependsOn(Restore)
65+
.Executes(() =>
66+
{
67+
DotNetBuild(s => s
68+
.SetProjectFile(Solution)
69+
.SetConfiguration(Configuration)
70+
.SetAssemblyVersion(GitVersion.AssemblySemVer)
71+
.SetFileVersion(GitVersion.AssemblySemFileVer)
72+
.SetInformationalVersion(GitVersion.InformationalVersion)
73+
.EnableNoRestore());
74+
});
75+
76+
Target Pack
77+
=> _ => _
78+
.DependsOn(Clean, Compile)
79+
.Executes(() =>
80+
{
81+
var licenseUrl =
82+
GitRepository.GetGitHubBrowseUrl(LicenseFile, "master");
83+
DotNetPack(s => s
84+
//.SetPackageReleaseNotes(changelogUrl)
85+
.SetWorkingDirectory(RootDirectory)
86+
.SetPackageLicenseUrl(licenseUrl)
87+
.SetProject(Solution.Path)
88+
.SetRepositoryUrl("https://github.com/mifopen/ReportDotNet")
89+
.EnableNoBuild()
90+
.SetConfiguration(Configuration)
91+
.EnableIncludeSymbols()
92+
.SetOutputDirectory(ArtifactsDirectory)
93+
.SetDescription("Docx reports generator")
94+
.SetAuthors("mif")
95+
.SetPackageTags("reports", "docx")
96+
.SetVersion(GitVersion.NuGetVersionV2));
97+
});
98+
99+
Target Publish
100+
=> _ => _
101+
.DependsOn(Pack)
102+
.Requires(() => ApiKey)
103+
.Requires(() => Equals(Configuration, Configuration.Release))
104+
.Executes(() =>
105+
{
106+
GlobFiles(ArtifactsDirectory, "*.nupkg")
107+
.NotEmpty()
108+
.Where(x => !x.EndsWith(".symbols.nupkg"))
109+
.ForEach(x => DotNetNuGetPush(s => s
110+
.SetTargetPath(x)
111+
.SetSource("https://api.nuget.org/v3/index.json")
112+
.SetApiKey(ApiKey)));
113+
});
114+
115+
Target PublishLocal
116+
=> _ => _
117+
.DependsOn(Pack)
118+
.Requires(() => LocalNugetSource)
119+
.Executes(() =>
120+
{
121+
EnsureExistingDirectory(LocalNugetSource);
122+
GlobFiles(ArtifactsDirectory, "*.nupkg")
123+
.NotEmpty()
124+
.Where(x => !x.EndsWith(".symbols.nupkg"))
125+
.ForEach(x => DotNetNuGetPush(s => s
126+
.SetTargetPath(x)
127+
.SetSource(LocalNugetSource)));
128+
});
129+
}

build/_build.csproj

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
<NoWarn>CS0649;CS0169</NoWarn>
7+
<NukeRootDirectory>..</NukeRootDirectory>
8+
<NukeScriptDirectory>..</NukeScriptDirectory>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="GitVersion.CommandLine" Version="5.1.4-beta1.142" ExcludeAssets="All" />
13+
<PackageReference Include="Nuke.Common" Version="0.24.2" />
14+
</ItemGroup>
15+
16+
</Project>

0 commit comments

Comments
 (0)