Skip to content

Commit

Permalink
More build updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenba committed Apr 5, 2019
1 parent 2100e33 commit 2afb5e4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
54 changes: 34 additions & 20 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.DotNet;
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;

[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
Expand All @@ -17,62 +20,73 @@ class Build : NukeBuild
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode

public string PackageVersionSuffix => "develop-" + DateTime.UtcNow.ToString("yyyyMMddhhmm");
public static int Main () => Execute<Build>(x => x.Pack);

[Solution] readonly Solution Solution;
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

public static int Main() => Execute<Build>(x => x.Pack);
[Parameter("Package version suffix")]
readonly string PackageVersionSuffix = "develop-" + DateTime.UtcNow.ToString("yyyyMMddhhmm");

[Solution] readonly Solution Solution;
[GitRepository] readonly GitRepository GitRepository;

AbsolutePath SourceDirectory => RootDirectory / "src";
AbsolutePath TestsDirectory => RootDirectory / "tests";
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";

Target Initialize => _ => _
.Before(Clean)
.Executes(() =>
{
SetVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
});

Target Clean => _ => _
.DependsOn(Initialize)
.Before(Restore)
.Executes(() =>
{
foreach (var directory in Solution.Directory.GlobDirectories("**/bin", "**/obj"))
{
DeleteDirectory(directory);
}
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
EnsureCleanDirectory(ArtifactsDirectory);
});

Target Restore => _ => _
.DependsOn(Clean)
.Executes(() =>
{
DotNetTasks.DotNetRestore();
DotNetRestore(s => s
.SetProjectFile(Solution));
});

Target Compile => _ => _
.DependsOn(Restore)
.Executes(() =>
{
DotNetTasks.DotNetBuild(settings => settings
.SetVersionSuffix(PackageVersionSuffix));
DotNetBuild(s => s
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.EnableNoRestore());
});

Target Test => _ => _
.DependsOn(Compile)
.Executes(() =>
{
DotNetTasks.DotNetTest(settings => settings
.SetProjectFile(Solution.Directory / "tests" / "YouTrackSharp.Tests" / "YouTrackSharp.Tests.csproj")
DotNetTest(settings => settings
.SetProjectFile(TestsDirectory / "YouTrackSharp.Tests" / "YouTrackSharp.Tests.csproj")
.EnableNoBuild());
});

Target Pack => _ => _
.DependsOn(Test)
.Executes(() =>
{
EnsureExistingDirectory(Solution.Directory / "artifacts");
EnsureExistingDirectory(ArtifactsDirectory);

DotNetTasks.DotNetPack(settings => settings
.SetOutputDirectory(Solution.Directory / "artifacts")
DotNetPack(settings => settings
.SetOutputDirectory(ArtifactsDirectory)
.EnableIncludeSource()
.EnableIncludeSymbols()
.SetVersionSuffix(PackageVersionSuffix));
});
}
}
3 changes: 1 addition & 2 deletions build/_build.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/ImplicitNullability/EnableFields/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
Expand All @@ -17,7 +17,6 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
Expand Down

0 comments on commit 2afb5e4

Please sign in to comment.