Skip to content

Commit 1f3843a

Browse files
authored
Merge pull request #50 from nunit/issue-49
Issue 49
2 parents 026be2a + 5026fb0 commit 1f3843a

File tree

8 files changed

+197
-188
lines changed

8 files changed

+197
-188
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "4.0.0",
6+
"version": "5.0.0",
77
"commands": [
88
"dotnet-cake"
99
],

recipe/build-settings.cake

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public static class BuildSettings
1515

1616
string solutionFile = null,
1717
bool buildWithMSBuild = false,
18-
18+
1919
DotNetVerbosity dotnetVerbosity = DotNetVerbosity.Minimal,
2020
Verbosity msbuildVerbosity = Verbosity.Minimal,
21-
NuGetVerbosity nugetVerbosity = NuGetVerbosity.Normal,
21+
NuGetVerbosity nugetVerbosity = NuGetVerbosity.Normal,
2222
bool chocolateyVerbosity = false,
2323

2424
string[] validConfigurations = null,
@@ -48,12 +48,12 @@ public static class BuildSettings
4848
SolutionFile = solutionFile ?? DeduceSolutionFile();
4949
BuildWithMSBuild = buildWithMSBuild;
5050

51-
dotnetVerbosity = dotnetVerbosity;
51+
DotNetVerbosity = dotnetVerbosity;
5252
MSBuildVerbosity = msbuildVerbosity;
5353
NuGetVerbosity = nugetVerbosity;
5454
ChocolateyVerbosity = chocolateyVerbosity;
5555

56-
ValidConfigurations = validConfigurations ?? DEFAULT_VALID_CONFIGS;
56+
ValidConfigurations = validConfigurations ?? DEFAULT_VALID_CONFIGS;
5757

5858
UnitTests = unitTests;
5959
// NUnitLiteRunner depends indirectly on ValidConfigurations
@@ -178,60 +178,60 @@ public static class BuildSettings
178178

179179
// Standard Directory Structure - not changeable by user
180180
public static string ProjectDirectory => Context.Environment.WorkingDirectory.FullPath + "/";
181-
public static string SourceDirectory => ProjectDirectory + SRC_DIR;
182-
public static string OutputDirectory => ProjectDirectory + BIN_DIR + Configuration + "/";
183-
public static string NuGetDirectory => ProjectDirectory + NUGET_DIR;
184-
public static string ChocolateyDirectory => ProjectDirectory + CHOCO_DIR;
185-
public static string ZipDirectory => ProjectDirectory + ZIP_DIR;
186-
public static string PackageDirectory => ProjectDirectory + PACKAGE_DIR;
187-
public static string PackageTestDirectory => ProjectDirectory + PKG_TEST_DIR;
188-
public static string NuGetTestDirectory => ProjectDirectory + NUGET_TEST_DIR;
189-
public static string ChocolateyTestDirectory => ProjectDirectory + CHOCO_TEST_DIR;
190-
public static string ZipTestDirectory => ProjectDirectory + ZIP_TEST_DIR;
191-
public static string PackageResultDirectory => ProjectDirectory + PKG_RSLT_DIR;
192-
public static string NuGetResultDirectory => ProjectDirectory + NUGET_RSLT_DIR;
193-
public static string ChocolateyResultDirectory => ProjectDirectory + CHOCO_RSLT_DIR;
194-
public static string ZipResultDirectory => ProjectDirectory + ZIP_RSLT_DIR;
195-
public static string ImageDirectory => ProjectDirectory + IMAGE_DIR;
196-
public static string ZipImageDirectory => ProjectDirectory + ZIP_IMG_DIR;
197-
public static string ExtensionsDirectory => ProjectDirectory + "bundled-extensions/";
198-
public static string ToolsDirectory => ProjectDirectory + TOOLS_DIR;
199-
200-
// Files
201-
public static string SolutionFile { get; set; }
181+
public static string SourceDirectory => ProjectDirectory + SRC_DIR;
182+
public static string OutputDirectory => ProjectDirectory + BIN_DIR + Configuration + "/";
183+
public static string NuGetDirectory => ProjectDirectory + NUGET_DIR;
184+
public static string ChocolateyDirectory => ProjectDirectory + CHOCO_DIR;
185+
public static string ZipDirectory => ProjectDirectory + ZIP_DIR;
186+
public static string PackageDirectory => ProjectDirectory + PACKAGE_DIR;
187+
public static string PackageTestDirectory => ProjectDirectory + PKG_TEST_DIR;
188+
public static string NuGetTestDirectory => ProjectDirectory + NUGET_TEST_DIR;
189+
public static string ChocolateyTestDirectory => ProjectDirectory + CHOCO_TEST_DIR;
190+
public static string ZipTestDirectory => ProjectDirectory + ZIP_TEST_DIR;
191+
public static string PackageResultDirectory => ProjectDirectory + PKG_RSLT_DIR;
192+
public static string NuGetResultDirectory => ProjectDirectory + NUGET_RSLT_DIR;
193+
public static string ChocolateyResultDirectory => ProjectDirectory + CHOCO_RSLT_DIR;
194+
public static string ZipResultDirectory => ProjectDirectory + ZIP_RSLT_DIR;
195+
public static string ImageDirectory => ProjectDirectory + IMAGE_DIR;
196+
public static string ZipImageDirectory => ProjectDirectory + ZIP_IMG_DIR;
197+
public static string ExtensionsDirectory => ProjectDirectory + "bundled-extensions/";
198+
public static string ToolsDirectory => ProjectDirectory + TOOLS_DIR;
199+
200+
// Files
201+
public static string SolutionFile { get; set; }
202202

203203
// Building
204204
public static string[] ValidConfigurations { get; set; }
205205

206206
public static DotNetVerbosity DotNetVerbosity { get; set; }
207207
public static Verbosity MSBuildVerbosity { get; set; }
208-
public static NuGetVerbosity NuGetVerbosity { get; set; }
208+
public static NuGetVerbosity NuGetVerbosity { get; set; }
209209
// The chocolatey Setting is actually bool Verbose, but we use verbosity
210-
// so it lines up with the settings for NuGet
211-
public static bool ChocolateyVerbosity { get; set; }
210+
// so it lines up with the settings for NuGet
211+
public static bool ChocolateyVerbosity { get; set; }
212212

213-
public static bool BuildWithMSBuild { get; set; }
213+
public static bool BuildWithMSBuild { get; set; }
214214
public static MSBuildSettings MSBuildSettings => new MSBuildSettings
215215
{
216216
Verbosity = MSBuildVerbosity,
217217
Configuration = Configuration,
218218
PlatformTarget = PlatformTarget.MSIL
219219
};
220-
public static DotNetBuildSettings DotNetBuildSettings => new DotNetBuildSettings
221-
{
222-
Configuration = Configuration,
223-
NoRestore = true,
224-
Verbosity = DotNetVerbosity,
225-
MSBuildSettings = new DotNetMSBuildSettings
226-
{
227-
BinaryLogger = new MSBuildBinaryLoggerSettings
228-
{
229-
Enabled = true,
230-
FileName = "build-results/NUnitConsole.binlog",
231-
Imports = MSBuildBinaryLoggerImports.Embed
232-
}
233-
}.WithProperty("Version", BuildSettings.PackageVersion)
234-
};
220+
public static DotNetBuildSettings DotNetBuildSettings => new DotNetBuildSettings
221+
{
222+
Configuration = Configuration,
223+
NoRestore = true,
224+
Verbosity = DotNetVerbosity,
225+
MSBuildSettings = new DotNetMSBuildSettings
226+
{
227+
BinaryLogger = new MSBuildBinaryLoggerSettings
228+
{
229+
Enabled = true,
230+
FileName = "build-results/NUnitConsole.binlog",
231+
Imports = MSBuildBinaryLoggerImports.Embed
232+
}
233+
}.WithProperty("Version", BuildSettings.PackageVersion)
234+
};
235235

236236
// File Header Checks
237237
public static bool SuppressHeaderCheck { get; private set; }
@@ -245,7 +245,8 @@ public static class BuildSettings
245245

246246
// Packaging
247247
public static string Title { get; private set; }
248-
public static List<PackageDefinition> Packages { get; } = new List<PackageDefinition>();
248+
public static List<PackageDefinition> Packages { get; } = new List<PackageDefinition>();
249+
public static List<PackageDefinition> SelectedPackages { get; } = new List<PackageDefinition>();
249250

250251
// Package Testing
251252
public static int PackageTestLevel =>
@@ -270,15 +271,18 @@ public static class BuildSettings
270271
public static string GitHubRepository { get; set; }
271272
public static string GitHubAccessToken => Context.EnvironmentVariable(GITHUB_ACCESS_TOKEN);
272273

274+
// Publishing - Policies
273275
public static bool IsPreRelease => BuildVersion.IsPreRelease;
276+
public static bool ShouldPublishRelease =>
277+
!IsPreRelease || LABELS_WE_PUBLISH.Contains(BuildVersion.PreReleaseLabel);
274278
public static bool ShouldPublishToMyGet =>
275279
!IsPreRelease || LABELS_WE_PUBLISH_ON_MYGET.Contains(BuildVersion.PreReleaseLabel);
276280
public static bool ShouldPublishToNuGet =>
277281
!IsPreRelease || LABELS_WE_PUBLISH_ON_NUGET.Contains(BuildVersion.PreReleaseLabel);
278282
public static bool ShouldPublishToChocolatey =>
279283
!IsPreRelease || LABELS_WE_PUBLISH_ON_CHOCOLATEY.Contains(BuildVersion.PreReleaseLabel);
280-
public static bool IsProductionRelease =>
281-
!IsPreRelease || LABELS_WE_RELEASE_ON_GITHUB.Contains(BuildVersion.PreReleaseLabel);
284+
public static bool ShouldPublishToGitHub =>
285+
!IsPreRelease || LABELS_WE_PUBLISH_ON_GITHUB.Contains(BuildVersion.PreReleaseLabel);
282286

283287
private static void ValidateSettings()
284288
{
@@ -361,20 +365,25 @@ public static class BuildSettings
361365
foreach (var package in Packages)
362366
{
363367
Console.WriteLine(package.PackageId);
364-
Console.WriteLine(" PackageType: " + package.PackageType);
365-
Console.WriteLine(" PackageFileName: " + package.PackageFileName);
366-
Console.WriteLine(" PackageInstallDirectory: " + package.PackageInstallDirectory);
367-
Console.WriteLine(" PackageTestDirectory: " + package.PackageTestDirectory);
368+
Console.WriteLine(" PackageType: " + package.PackageType);
369+
Console.WriteLine(" PackageFileName: " + package.PackageFileName);
370+
Console.WriteLine(" PackageInstallDirectory: " + package.PackageInstallDirectory);
371+
Console.WriteLine(" PackageTestDirectory: " + package.PackageTestDirectory);
368372
}
373+
var selected = SelectedPackages.Select(p => p.PackageId);
374+
if (CommandLineOptions.PackageSelector.Exists)
375+
Console.WriteLine(" SelectedPackages: " + string.Join(", ", selected.ToArray()));
376+
else
377+
Console.WriteLine(" SelectedPackages: NO SELECTOR SPECIFIED");
369378

370-
Console.WriteLine("\nPUBLISHING");
379+
Console.WriteLine("\nPUBLISHING");
371380
Console.WriteLine("ShouldPublishToMyGet: " + ShouldPublishToMyGet);
372381
Console.WriteLine("ShouldPublishToNuGet: " + ShouldPublishToNuGet);
373382
Console.WriteLine("ShouldPublishToChocolatey: " + ShouldPublishToChocolatey);
374383

375384
Console.WriteLine("\nRELEASING");
376-
Console.WriteLine("BranchName: " + BranchName);
377-
Console.WriteLine("IsReleaseBranch: " + IsReleaseBranch);
378-
Console.WriteLine("IsProductionRelease: " + IsProductionRelease);
385+
Console.WriteLine("BranchName: " + BranchName);
386+
Console.WriteLine("IsReleaseBranch: " + IsReleaseBranch);
387+
Console.WriteLine("ShouldPublishToGitHub: " + ShouldPublishToGitHub);
379388
}
380389
}

recipe/constants.cake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ private const string CHOCO_API_KEY = "CHOCO_API_KEY";
4747
private const string GITHUB_ACCESS_TOKEN = "GITHUB_ACCESS_TOKEN";
4848

4949
// Pre-release labels that we publish
50-
private static readonly string[] LABELS_WE_PUBLISH_ON_MYGET = { "dev", "alpha" };
50+
private static readonly string[] LABELS_WE_PUBLISH = { "dev", "alpha", "beta", "rc" };
51+
private static readonly string[] LABELS_WE_PUBLISH_ON_MYGET = { "dev", "alpha", "beta", "rc" };
5152
private static readonly string[] LABELS_WE_PUBLISH_ON_NUGET = { "beta", "rc" };
5253
private static readonly string[] LABELS_WE_PUBLISH_ON_CHOCOLATEY = { "beta", "rc" };
53-
private static readonly string[] LABELS_WE_RELEASE_ON_GITHUB = { "beta", "rc" };
54+
private static readonly string[] LABELS_WE_PUBLISH_ON_GITHUB = { "beta", "rc" };
55+
private static readonly string[] LABELS_USED_AS_TAGS = { "alpha", "beta", "rc" };

recipe/package-definition.cake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public abstract class PackageDefinition
9999
if (index <= 0)
100100
throw new ArgumentException("Selection expression does not contain =", "where");
101101
string prop = factor.Substring(0, index).Trim();
102-
string val = factor.Substring(index+1).Trim();
102+
if (factor[++index] == '=') ++index; // == operator
103+
string val = factor.Substring(index).Trim();
103104

104105
switch(prop.ToUpper())
105106
{

0 commit comments

Comments
 (0)