Skip to content

Commit

Permalink
Improve error message if TC project name changed
Browse files Browse the repository at this point in the history
This fixes #19.
  • Loading branch information
ermshiperete committed Oct 5, 2017
1 parent 29f7868 commit f0d6656
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
16 changes: 12 additions & 4 deletions BuildDependencyLib/DependencyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,19 @@ private async Task<List<ArtifactTemplate>> InternalLoadFile(string fileName, ILo
artifacts.Add(artifact);
continue;
}
log.LogError($"Can't find project '{config.ProjectId}'. Skipping {line} (line {lineNumber}).");
}
else
log.LogError($"Can't find build configuration '{configId}'. Skipping {line} (line {lineNumber}).");
}
else
log.LogError($"Can't find server '{tc}' mentioned on line {lineNumber}. Skipping {line}.");

// just a dummy artifact so that we can skip the following lines
artifact = new ArtifactTemplate(Server.CreateServer(ServerType.TeamCity), new Project(), null);
}
log.LogError("Can't interpret line {0}. Skipping {1}.", lineNumber, line);
else
log.LogError($"Can't interpret line {lineNumber}. Skipping {line}.");
}
else if (string.IsNullOrEmpty(line.Trim()) ||
line.Trim().StartsWith("#", StringComparison.InvariantCulture))
Expand All @@ -168,7 +177,7 @@ private async Task<List<ArtifactTemplate>> InternalLoadFile(string fileName, ILo
var parts = line.Split(new []{ '=' }, 2);
if (parts.Length < 2)
{
log.LogError("Can't interpret line {0}. Skipping {1}", lineNumber, line);
log.LogError($"Can't interpret line {lineNumber}. Skipping {line}.");
continue;
}
switch (parts[0])
Expand All @@ -184,8 +193,7 @@ private async Task<List<ArtifactTemplate>> InternalLoadFile(string fileName, ILo
if (Enum.TryParse(parts[1], out condition))
artifact.Condition = condition;
else
log.LogError("Can't interpret condition on line {0}. Skipping {1}",
lineNumber, line);
log.LogError($"Can't interpret condition '{parts[1]}' on line {lineNumber}. Skipping {line}.");
break;
case "Path":
{
Expand Down
40 changes: 40 additions & 0 deletions Samples/BuildDependencyTestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Copyright (c) 2015 Eberhard Beilharz
// This software is licensed under the MIT license (http://opensource.org/licenses/MIT)

using System;
using System.Collections;
using System.IO;
using System.Runtime.ConstrainedExecution;
using BuildDependency.Tasks;
using Microsoft.Build.Framework;

namespace BuildDependencyTestApp
{
Expand All @@ -17,7 +22,42 @@ public static void Main(string[] args)
task.WorkingDir = "/tmp/bla";
Directory.CreateDirectory("/tmp/bla");
task.RunAsync = true;
task.BuildEngine = new TmpBuildEngine();
task.Execute();
}

class TmpBuildEngine : IBuildEngine
{
public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties,
IDictionary targetOutputs)
{
return true;
}

public void LogCustomEvent(CustomBuildEventArgs e)
{
Console.WriteLine($"Log custom event: {e.Message}");
}

public void LogErrorEvent(BuildErrorEventArgs e)
{
Console.WriteLine($"Log error: {e.Message}");
}

public void LogMessageEvent(BuildMessageEventArgs e)
{
Console.WriteLine($"Log message: {e.Message}");
}

public void LogWarningEvent(BuildWarningEventArgs e)
{
Console.WriteLine($"Log warning: {e.Message}");
}

public int ColumnNumberOfTaskNode { get; }
public bool ContinueOnError { get; }
public int LineNumberOfTaskNode { get; }
public string ProjectFileOfTaskNode { get; }
}
}
}
2 changes: 1 addition & 1 deletion Samples/MsBuildSample/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BuildDependencyTasks" version="0.2.10.0" />
<package id="BuildDependencyTasks" version="0.2.11.0" />
</packages>

0 comments on commit f0d6656

Please sign in to comment.