Skip to content

Commit

Permalink
Adapted PostActions for latest interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebattista committed Feb 11, 2023
1 parent 68b5079 commit 1847f7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,14 +703,14 @@ private static void VerifyLicensesAndProjPostactions(ValidationTemplateInfo temp
{
if (template.TagsCollection.ContainsKey("ts.licenses") && !string.IsNullOrEmpty(template.TagsCollection["ts.licenses"]))
{
if (template.PostActions?.Count == 0)
if (template.PostActionInfos?.Count == 0)
{
results.Add($"No postaction found for license defined on template {template.Identity}");
}
}
else
{
if (template.PostActions != null && template.PostActions.Any(p => p.ToString("D") == "0B814718-16A3-4F7F-89F1-69C0F9170EAD"))
if (template.PostActionInfos != null && template.PostActionInfos.Any(p => p.ActionId == "0B814718-16A3-4F7F-89F1-69C0F9170EAD"))
{
results.Add($"Missing license on template {template.Identity}");
}
Expand All @@ -719,11 +719,10 @@ private static void VerifyLicensesAndProjPostactions(ValidationTemplateInfo temp

private static void VerifyPostactionsPath(ValidationTemplateInfo template, List<string> results)
{
// TODO: TemplateEngine 7.x packages changed PostActions to just a list of GUIDs. Unclear how to implement this.
//if (template.PostActions != null && template.PostActions.Any(p => p.Args.Any(a => a.Key == "projectPath" && a.Value.Contains("/"))))
//{
// results.Add("Post-action projectPath should use '\\' instead of '/' to indicate the project file path");
//}
if (template.PostActionInfos != null && template.PostActionInfos.Any(p => p.Args.Any(a => a.Key == "projectPath" && a.Value.Contains("/"))))
{
results.Add("Post-action projectPath should use '\\' instead of '/' to indicate the project file path");
}
}

private static void EnsureValidPrimaryOutputPaths(ValidationTemplateInfo template, List<string> results)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Abstractions.Constraints;
using Microsoft.TemplateEngine.Abstractions.Parameters;
using Microsoft.Templates.Core.PostActions;
using Newtonsoft.Json;

namespace TemplateValidator
Expand Down Expand Up @@ -103,7 +104,12 @@ public class ValidationTemplateInfo : ITemplateInfo
public IParameterDefinitionSet ParameterDefinitions { get; }

[ApiAnalysisOptional]
public IReadOnlyList<Guid> PostActions { get; set; }
[JsonProperty("postActions")]
public List<PostActionInfo> PostActionInfos { get; set; }

[ApiAnalysisOptional]
[JsonIgnore]
IReadOnlyList<Guid> ITemplateInfo.PostActions { get; }

public string SourceName { get; set; }

Expand Down

0 comments on commit 1847f7a

Please sign in to comment.