Skip to content

Commit

Permalink
updated az pipeline (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
mizrael authored Jan 25, 2024
1 parent 8a36ad8 commit 8b84742
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
16 changes: 14 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
inputs:
command: 'run'
projects: '$(Build.SourcesDirectory)/targets/targets.csproj'
arguments: '-- pack -c $(BuildConfiguration)'
arguments: '-- pack -c $(BuildConfiguration) -p .\src\PAModel\Microsoft.PowerPlatform.Formulas.Tools.csproj .\src\Microsoft.PowerPlatform.PowerApps.Persistence\Microsoft.PowerPlatform.PowerApps.Persistence.csproj'

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@3
displayName: 'ESRP sign nuget packages'
Expand Down Expand Up @@ -144,17 +144,29 @@ jobs:
ServiceEndpointUrl: 'https://api.esrp.microsoft.com/api/v1'

- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Generation Task'
displayName: 'PAModel Generation Task'
inputs:
BuildDropPath: '$(Build.SourcesDirectory)/bin/$(BuildConfiguration)/PAModel/'

- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Persistence Generation Task'
inputs:
BuildDropPath: '$(Build.SourcesDirectory)/bin/$(BuildConfiguration)/Microsoft.PowerPlatform.PowerApps.Persistence/'

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/bin/$(BuildConfiguration)/PAModel/'
ArtifactName: 'Generation Task'
publishLocation: 'Container'
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/bin/$(BuildConfiguration)/Microsoft.PowerPlatform.PowerApps.Persistence/'
ArtifactName: 'Persistence Generation Task'
publishLocation: 'Container'
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/pkg/PackResult'
Expand Down
34 changes: 24 additions & 10 deletions targets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using CommandLine;
using SimpleExec;
Expand All @@ -18,6 +20,9 @@ class Options

[Option('c', "configuration", Required = false, Default = "Debug")]
public string Configuration { get; set; }

[Option('p', "projects", Required = false)]
public IEnumerable<string> Projects { get; set; }
}

class Program
Expand All @@ -26,10 +31,10 @@ class Program

static void Main(string[] args)
{

string RootDir = "", gitHash = "";
bool gitExists = true;
try
try
{
RootDir = Read("git", "rev-parse --show-toplevel", noEcho: true).Trim();
gitHash = Read("git", "rev-parse HEAD", noEcho: true).Trim();
Expand All @@ -51,8 +56,8 @@ static void Main(string[] args)

string PAModelDir = Path.Combine(SrcDir, "PAModel");
var solution = Path.Combine(SrcDir, "PASopa.sln");
var project = Path.Combine(PAModelDir, "Microsoft.PowerPlatform.Formulas.Tools.csproj");

var defaultPackProject = Path.Combine(PAModelDir, "Microsoft.PowerPlatform.Formulas.Tools.csproj");

Target("squeaky-clean",
() =>
Expand All @@ -70,7 +75,8 @@ static void Main(string[] args)
() => RunDotnet("restore", $"{EscapePath(solution)}", gitExists, LogDir));

Target("build",
() => {
() =>
{
if (gitExists)
CreateBuildHashFile(ObjDir, gitHash);
RunDotnet("build", $"{EscapePath(solution)} --configuration {options.Configuration} --no-restore", gitExists, LogDir);
Expand All @@ -83,7 +89,13 @@ static void Main(string[] args)
DependsOn("restore", "build"));

Target("pack",
() => RunDotnet("pack", $"{EscapePath(project)} --configuration {options.Configuration} --output {EscapePath(Path.Combine(PkgDir, "PackResult"))} --no-build -p:Packing=true", gitExists, LogDir));
() =>
{
var projects = (options.Projects.Any()) ? options.Projects : new[]{ defaultPackProject };

foreach (var project in projects)
RunDotnet("pack", $"{EscapePath(project)} --configuration {options.Configuration} --output {EscapePath(Path.Combine(PkgDir, "PackResult"))} --no-build -p:Packing=true", gitExists, LogDir);
});

Target("ci",
DependsOn("squeaky-clean", "rebuild", "test"));
Expand All @@ -92,7 +104,7 @@ static void Main(string[] args)
.WithParsed<Options>(o =>
{
options = o;
RunTargetsAndExit(new[] {options.Target},
RunTargetsAndExit(new[] { options.Target },
logPrefix: options.Target,
messageOnly: ex => ex is NonZeroExitCodeException);
})
Expand All @@ -105,7 +117,7 @@ static void Main(string[] args)
static void RunDotnet(string verb, string verbArgs, bool gitExists, string LogDir)
{
var gitDef = "";
if (gitExists)
if (gitExists)
gitDef = "-p:GitExists=true";
var optionsLogPath = Path.Combine(LogDir, $"{verb}-{options.Configuration}");
var logSettings = $"/clp:verbosity=minimal /flp:Verbosity=normal;LogFile={EscapePath(optionsLogPath + ".log")} /flp3:PerformanceSummary;Verbosity=diag;LogFile={EscapePath(optionsLogPath + ".diagnostics.log")}";
Expand All @@ -118,7 +130,8 @@ static void CreateBuildHashFile(string objDir, string gitHash)
var file = new System.IO.FileInfo(filePath);
file.Directory.Create();

var jsonContents = new {
var jsonContents = new
{
CommitHash = gitHash,
#if !ADOBuild
IsLocalBuild = true
Expand All @@ -132,7 +145,8 @@ static void CleanDirectory(string directoryPath)
{
directoryPath = Path.GetFullPath(directoryPath);
Console.WriteLine($"Cleaning directory: {directoryPath}");
try {
try
{
if (Directory.Exists(directoryPath))
{
Directory.Delete(directoryPath, recursive: true);
Expand Down

0 comments on commit 8b84742

Please sign in to comment.