Skip to content

Commit cc3c61a

Browse files
committed
Merge branch 'hotfix/0.10.3'
2 parents 65704f6 + fe8abbc commit cc3c61a

40 files changed

Lines changed: 203 additions & 171 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,4 @@ build/configurations/
195195
build/bootstrap/
196196
build/doc/
197197
packages.xml
198+
src/nbuildkit/tasks/.vs/
Binary file not shown.

src/nbuildkit/tasks/nBuildKit.MsBuild.Tasks.Core/BaseTask.cs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,6 @@ namespace NBuildKit.MsBuild.Tasks.Core
2020
/// </summary>
2121
public abstract class BaseTask : Task
2222
{
23-
/// <summary>
24-
/// Defines the error ID for an error that occurs when a directory cannot be found.
25-
/// </summary>
26-
protected const string ErrorIdDirectoryNotFound = "NBuildKit.DirectoryNotFound";
27-
28-
/// <summary>
29-
/// Defines the error ID for an error that occurs when a file cannot be loaded.
30-
/// </summary>
31-
protected const string ErrorIdFileLoad = "NBuildKit.FileLoad";
32-
33-
/// <summary>
34-
/// Defines the error ID for an error that occurs when a file cannot be found.
35-
/// </summary>
36-
protected const string ErrorIdFileNotFound = "NBuildKit.FileNotFound";
37-
38-
/// <summary>
39-
/// Defines the error ID for an error that occurs when a file cannot be read.
40-
/// </summary>
41-
protected const string ErrorIdFileRead = "NBuildKit.FileRead";
42-
43-
private const string MetadataCodeTag = "Code";
44-
4523
/// <summary>
4624
/// Gets the verbosity that the current MsBuild instance is running at.
4725
/// </summary>
@@ -95,16 +73,7 @@ protected static string VerbosityForCurrentMsBuildInstance()
9573
/// <returns>The error code that matches the given ID.</returns>
9674
protected string ErrorCodeById(string errorId)
9775
{
98-
var result = string.Empty;
99-
if (ErrorInformation != null)
100-
{
101-
var code = ErrorInformation.Where(t => string.Equals(errorId, t.ItemSpec, StringComparison.OrdinalIgnoreCase))
102-
.Select(t => t.GetMetadata(MetadataCodeTag))
103-
.FirstOrDefault();
104-
result = code ?? string.Empty;
105-
}
106-
107-
return result;
76+
return Core.ErrorInformation.ErrorCodeById(errorId, ErrorInformation);
10877
}
10978

11079
/// <summary>

src/nbuildkit/tasks/nBuildKit.MsBuild.Tasks.Core/CommandLineToolTask.cs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,6 @@ namespace NBuildKit.MsBuild.Tasks.Core
2323
/// </summary>
2424
public abstract class CommandLineToolTask : BaseTask
2525
{
26-
/// <summary>
27-
/// Defines the error ID for an error describing an application writing to the error stream.
28-
/// </summary>
29-
protected const string ErrorIdApplicationErrorStream = "NBuildKit.Application.WroteToErrorStream";
30-
31-
/// <summary>
32-
/// Defines the error ID for an error indicating that a required application argument has not been provided.
33-
/// </summary>
34-
protected const string ErrorIdApplicationMissingArgument = "NBuildKit.Application.MissingArgument";
35-
36-
/// <summary>
37-
/// Defines the error ID for an error describing an application exiting with a non-zero exit code.
38-
/// </summary>
39-
protected const string ErrorIdApplicationNonzeroExitCode = "NBuildKit.Application.NonzeroExitCode";
40-
41-
/// <summary>
42-
/// Defines the error ID for an error indicating that the path to the selected tool was not found.
43-
/// </summary>
44-
protected const string ErrorIdApplicationPathNotFound = "NBuildKit.FileNotFound.ExecutableTool";
45-
4626
private readonly IApplicationInvoker _invoker;
4727

4828
/// <summary>
@@ -106,8 +86,8 @@ protected virtual DataReceivedEventHandler DefaultErrorHandler
10686

10787
Log.LogError(
10888
string.Empty,
109-
ErrorCodeById(ErrorIdApplicationErrorStream),
110-
ErrorIdApplicationErrorStream,
89+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationErrorStream),
90+
Core.ErrorInformation.ErrorIdApplicationErrorStream,
11191
string.Empty,
11292
0,
11393
0,
@@ -255,8 +235,8 @@ protected int InvokeCommandLineTool(
255235
{
256236
Log.LogError(
257237
string.Empty,
258-
ErrorCodeById(ErrorIdApplicationPathNotFound),
259-
ErrorIdApplicationPathNotFound,
238+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationPathNotFound),
239+
Core.ErrorInformation.ErrorIdApplicationPathNotFound,
260240
string.Empty,
261241
0,
262242
0,
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright company="nBuildKit">
3+
// Copyright (c) nBuildKit. All rights reserved.
4+
// Licensed under the Apache License, Version 2.0 license. See LICENCE.md file in the project root for full license information.
5+
// </copyright>
6+
//-----------------------------------------------------------------------
7+
8+
using System;
9+
using System.Linq;
10+
using Microsoft.Build.Framework;
11+
12+
namespace NBuildKit.MsBuild.Tasks.Core
13+
{
14+
/// <summary>
15+
/// Provides the error IDs known in nBuildKit and methods to map error IDs to error codes.
16+
/// </summary>
17+
public static class ErrorInformation
18+
{
19+
/// <summary>
20+
/// Defines the error ID for an error describing an application writing to the error stream.
21+
/// </summary>
22+
public const string ErrorIdApplicationErrorStream = "NBuildKit.Application.WroteToErrorStream";
23+
24+
/// <summary>
25+
/// Defines the error ID for an error indicating that a required application argument has not been provided.
26+
/// </summary>
27+
public const string ErrorIdApplicationMissingArgument = "NBuildKit.Application.MissingArgument";
28+
29+
/// <summary>
30+
/// Defines the error ID for an error describing an application exiting with a non-zero exit code.
31+
/// </summary>
32+
public const string ErrorIdApplicationNonzeroExitCode = "NBuildKit.Application.NonzeroExitCode";
33+
34+
/// <summary>
35+
/// Defines the error ID for an error indicating that the path to the selected tool was not found.
36+
/// </summary>
37+
public const string ErrorIdApplicationPathNotFound = "NBuildKit.FileNotFound.ExecutableTool";
38+
39+
/// <summary>
40+
/// Defines the error ID for an error that occurs when a directory cannot be found.
41+
/// </summary>
42+
public const string ErrorIdDirectoryNotFound = "NBuildKit.DirectoryNotFound";
43+
44+
/// <summary>
45+
/// Defines the error ID for an error that occurs when a file cannot be loaded.
46+
/// </summary>
47+
public const string ErrorIdFileLoad = "NBuildKit.FileLoad";
48+
49+
/// <summary>
50+
/// Defines the error ID for an error that occurs when a file cannot be found.
51+
/// </summary>
52+
public const string ErrorIdFileNotFound = "NBuildKit.FileNotFound";
53+
54+
/// <summary>
55+
/// Defines the error ID for an error that occurs when a file cannot be read.
56+
/// </summary>
57+
public const string ErrorIdFileRead = "NBuildKit.FileRead";
58+
59+
/// <summary>
60+
/// Defines the error ID for an error that occurs when a file hash cannot be calculated.
61+
/// </summary>
62+
public const string ErrorIdHashCalculationFailure = "nBuildKit.CalculateHash.Failure";
63+
64+
private const string MetadataCodeTag = "Code";
65+
66+
/// <summary>
67+
/// Returns the error code for the given ID.
68+
/// </summary>
69+
/// <param name="errorId">The error ID.</param>
70+
/// <param name="errorInformation">The collection containing the error information.</param>
71+
/// <returns>The error code that matches the given ID.</returns>
72+
public static string ErrorCodeById(string errorId, ITaskItem[] errorInformation)
73+
{
74+
var result = string.Empty;
75+
if (errorInformation != null)
76+
{
77+
var code = errorInformation.Where(t => string.Equals(errorId, t.ItemSpec, StringComparison.OrdinalIgnoreCase))
78+
.Select(t => t.GetMetadata(MetadataCodeTag))
79+
.FirstOrDefault();
80+
result = code ?? string.Empty;
81+
}
82+
83+
return result;
84+
}
85+
}
86+
}

src/nbuildkit/tasks/nBuildKit.MsBuild.Tasks.Core/FxCopCommandLineToolTask.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ protected void InvokeFxCop(IEnumerable<string> arguments)
7474
{
7575
Log.LogError(
7676
string.Empty,
77-
ErrorCodeById(ErrorIdApplicationNonzeroExitCode),
78-
ErrorIdApplicationNonzeroExitCode,
77+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode),
78+
Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode,
7979
string.Empty,
8080
0,
8181
0,

src/nbuildkit/tasks/nBuildKit.MsBuild.Tasks.Core/GitCommandLineToolTask.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ protected string GetGitOutput(IEnumerable<string> arguments)
4848
{
4949
Log.LogError(
5050
string.Empty,
51-
ErrorCodeById(ErrorIdApplicationNonzeroExitCode),
52-
ErrorIdApplicationNonzeroExitCode,
51+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode),
52+
Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode,
5353
string.Empty,
5454
0,
5555
0,
@@ -116,8 +116,8 @@ protected int InvokeGit(IEnumerable<string> arguments, DataReceivedEventHandler
116116
{
117117
Log.LogError(
118118
string.Empty,
119-
ErrorCodeById(ErrorIdApplicationNonzeroExitCode),
120-
ErrorIdApplicationNonzeroExitCode,
119+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode),
120+
Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode,
121121
string.Empty,
122122
0,
123123
0,

src/nbuildkit/tasks/nBuildKit.MsBuild.Tasks.Core/MsBuildCommandLineToolTask.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ protected int InvokeMsBuild(IEnumerable<string> instanceArguments)
197197
{
198198
Log.LogError(
199199
string.Empty,
200-
ErrorCodeById(ErrorIdApplicationPathNotFound),
201-
ErrorIdApplicationPathNotFound,
200+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationPathNotFound),
201+
Core.ErrorInformation.ErrorIdApplicationPathNotFound,
202202
string.Empty,
203203
0,
204204
0,
@@ -218,8 +218,8 @@ protected int InvokeMsBuild(IEnumerable<string> instanceArguments)
218218
{
219219
Log.LogError(
220220
string.Empty,
221-
ErrorCodeById(ErrorIdApplicationNonzeroExitCode),
222-
ErrorIdApplicationNonzeroExitCode,
221+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode),
222+
Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode,
223223
string.Empty,
224224
0,
225225
0,

src/nbuildkit/tasks/nBuildKit.MsBuild.Tasks.Core/PowershellCommandLineToolTask.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ protected override DataReceivedEventHandler DefaultErrorHandler
5050
{
5151
Log.LogError(
5252
string.Empty,
53-
ErrorCodeById(ErrorIdApplicationErrorStream),
54-
ErrorIdApplicationErrorStream,
53+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationErrorStream),
54+
Core.ErrorInformation.ErrorIdApplicationErrorStream,
5555
string.Empty,
5656
0,
5757
0,
@@ -112,8 +112,8 @@ private void InvokePowershell(
112112
{
113113
Log.LogError(
114114
string.Empty,
115-
ErrorCodeById(ErrorIdApplicationNonzeroExitCode),
116-
ErrorIdApplicationNonzeroExitCode,
115+
ErrorCodeById(Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode),
116+
Core.ErrorInformation.ErrorIdApplicationNonzeroExitCode,
117117
string.Empty,
118118
0,
119119
0,

src/nbuildkit/tasks/nBuildKit.MsBuild.Tasks.Core/nBuildKit.MsBuild.Tasks.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<ItemGroup>
7272
<Compile Include="ApplicationInvoker.cs" />
7373
<Compile Include="CommandLineToolTask.cs" />
74+
<Compile Include="ErrorInformation.cs" />
7475
<Compile Include="EscapingUtilities.cs" />
7576
<Compile Include="FileSystem\PathUtilities.cs" />
7677
<Compile Include="FxCopCommandLineToolTask.cs" />

0 commit comments

Comments
 (0)