Ability to send any TF Build command
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 778
- Avg merge
- 1h 15m
- Merged PRs (30d)
- 19
Description
Since some TF Build commands are undocumented, such as `results.publish`, would you be willing to expose a public method so that Cake users can opt to type their own command strings? That way users can take responsibility to use TF Build commands which Cake does not have because they are new or undocumented.
This is Cake's current implementation, used internally:
https://github.com/cake-build/cake/blob/f11b299d7d4b9782874cb0a9b6c9dee03219ac8b/src/Cake.Common/Build/TFBuild/TFBuildCommands.cs#L321-L328
It's doing the equivalent of vsts-task-lib's [`command`](https://github.com/Microsoft/vsts-task-lib/blob/7dca1fc53e9886ac719a98e811b28339de108de0/node/internal.ts#L277-L280) (see also [`_writeline`](https://github.com/Microsoft/vsts-task-lib/blob/7dca1fc53e9886ac719a98e811b28339de108de0/node/internal.ts#L52-L54), [`TaskCommand.toString`](https://github.com/Microsoft/vsts-task-lib/blob/7dca1fc53e9886ac719a98e811b28339de108de0/node/taskcommand.ts#L26-L41)), so I'd suggest that we keep the same parameter names and types as the ones which are exported from that public library.
Maybe something like this?
```diff
namespace Cake.Common.Build.TFBuild
{
public interface ITFBuildCommands
{
void WriteWarning(string message);
void WriteWarning(string message, TFBuildMessageData data);
void WriteError(string message);
void WriteError(string message, TFBuildMessageData data);
+ void WriteCommand(string command, IReadOnlyDictionary properties, string message);
void SetProgress(int progress, string currentOperation);
void CompleteCurrentTask();
void CompleteCurrentTask(TFBuildTaskResult result);
Guid CreateNewRecord(string name, string type, int order);
Guid CreateNewRecord(string name, string type, int order, TFBuildRecordData data);
void UpdateRecord(Guid id, TFBuildRecordData data);
void SetVariable(string name, string value);
void SetSecretVariable(string name, string value);
void UploadTaskSummary(FilePath markdownPath);
void UploadTaskLogFile(FilePath logFile);
void LinkArtifact(string name, TFBuildArtifactType type, string location);
void UploadArtifact(string folderName, FilePath file);
void UploadArtifact(string folderName, FilePath file, string artifactName);
void UploadBuildLogFile(FilePath logFile);
void UpdateBuildNumber(string buildNumber);
void AddBuildTag(string tag);
}
}
```
And it would be used like this? (compare [`TestPublisher.publish`](https://github.com/Microsoft/vsts-task-lib/blob/7dca1fc53e9886ac719a98e811b28339de108de0/node/task.ts#L1684-L1714) and [Microsoft/vsts-tasks’s `publishtestresults.ts`](https://github.com/Microsoft/vsts-tasks/blob/d2f14192c3a1270b3cad81127c4812738bdfbb5c/Tasks/PublishTestResultsV2/publishtestresults.ts))
```cake
TFBuild.Commands.WriteCommand("results.publish", new Dictionary
{
["type"] = "NUnit",
["runTitle"] = "Integration tests",
["resultFiles"] = testResultFile.FullPath,
["publishRunAttachments"] = "true"
}, message: null);
```
Contributor guide
Research direction
Start with src/Cake.Common/Build/TFBuild/TFBuildCommands.cs, including the existing internal command-writing implementation, and inspect the ITFBuildCommands entry point. Compare its arguments and formatting with the linked vsts-task-lib command and TaskCommand references. Done means users can invoke a public WriteCommand method with custom command, properties, and message values such as results.publish.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, ci-cd
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100