Adding API diffs to the build (#4354)
This commit is contained in:
Родитель
9e46f20af9
Коммит
2f944b376e
|
@ -19,6 +19,12 @@
|
|||
"commands": [
|
||||
"xharness"
|
||||
]
|
||||
},
|
||||
"api-tools": {
|
||||
"version": "1.3.2",
|
||||
"commands": [
|
||||
"api-tools"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
15
build.cake
15
build.cake
|
@ -37,12 +37,13 @@ PowerShell:
|
|||
|
||||
string agentName = EnvironmentVariable("AGENT_NAME", "");
|
||||
bool isCIBuild = !String.IsNullOrWhiteSpace(agentName);
|
||||
string artifactStagingDirectory = EnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY", "artifacts");
|
||||
string logDirectory = EnvironmentVariable("LogDirectory", $"{artifactStagingDirectory}/logs");
|
||||
string testResultsDirectory = EnvironmentVariable("TestResultsDirectory", $"{artifactStagingDirectory}/test-results");
|
||||
string workingDirectory = EnvironmentVariable("SYSTEM_DEFAULTWORKINGDIRECTORY", ".");
|
||||
string envProgramFiles = EnvironmentVariable("ProgramFiles(x86)");
|
||||
var configuration = GetBuildVariable("configuration", GetBuildVariable("BUILD_CONFIGURATION", "DEBUG"));
|
||||
string configuration = GetBuildVariable("configuration", GetBuildVariable("BUILD_CONFIGURATION", "DEBUG"));
|
||||
|
||||
DirectoryPath artifactStagingDirectory = MakeAbsolute(Directory(EnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY", "artifacts")));
|
||||
DirectoryPath logDirectory = MakeAbsolute(Directory(EnvironmentVariable("LogDirectory", $"{artifactStagingDirectory}/logs")));
|
||||
DirectoryPath testResultsDirectory = MakeAbsolute(Directory(EnvironmentVariable("TestResultsDirectory", $"{artifactStagingDirectory}/test-results")));
|
||||
DirectoryPath diffDirectory = MakeAbsolute(Directory(EnvironmentVariable("ApiDiffDirectory", $"{artifactStagingDirectory}/api-diff")));
|
||||
DirectoryPath tempDirectory = MakeAbsolute(Directory(EnvironmentVariable("AGENT_TEMPDIRECTORY", EnvironmentVariable("TEMP", EnvironmentVariable("TMPDIR", "../maui-temp")) + "/" + Guid.NewGuid())));
|
||||
|
||||
var target = Argument("target", "Default");
|
||||
if(String.IsNullOrWhiteSpace(target))
|
||||
|
@ -169,7 +170,7 @@ Information ("Team Project: {0}", teamProject);
|
|||
Information ("Agent.Name: {0}", agentName);
|
||||
Information ("isCIBuild: {0}", isCIBuild);
|
||||
Information ("artifactStagingDirectory: {0}", artifactStagingDirectory);
|
||||
Information("workingDirectory: {0}", workingDirectory);
|
||||
Information("tempDirectory: {0}", tempDirectory);
|
||||
Information("NUNIT_TEST_WHERE: {0}", NUNIT_TEST_WHERE);
|
||||
Information("TARGET: {0}", target);
|
||||
Information("MSBUILD: {0}", MSBuildExe);
|
||||
|
|
|
@ -79,15 +79,15 @@ Task("dotnet-templates")
|
|||
|
||||
var dn = localDotnet ? dotnetPath : "dotnet";
|
||||
|
||||
var templatesTest = $"../templatesTest/{Guid.NewGuid()}/";
|
||||
var templatesTest = tempDirectory.Combine("templatesTest");
|
||||
|
||||
CleanDirectories("../templatesTest");
|
||||
EnsureDirectoryExists(templatesTest);
|
||||
CleanDirectories(templatesTest.FullPath);
|
||||
|
||||
// Create empty Directory.Build.props/targets
|
||||
EnsureDirectoryExists(Directory(templatesTest));
|
||||
FileWriteText(File(templatesTest + "Directory.Build.props"), "<Project/>");
|
||||
FileWriteText(File(templatesTest + "Directory.Build.targets"), "<Project/>");
|
||||
CopyFileToDirectory(File("./NuGet.config"), Directory(templatesTest));
|
||||
FileWriteText(templatesTest.CombineWithFilePath("Directory.Build.props"), "<Project/>");
|
||||
FileWriteText(templatesTest.CombineWithFilePath("Directory.Build.targets"), "<Project/>");
|
||||
CopyFileToDirectory(File("./NuGet.config"), templatesTest);
|
||||
|
||||
// See: https://github.com/dotnet/project-system/blob/main/docs/design-time-builds.md
|
||||
var designTime = new Dictionary<string, string> {
|
||||
|
@ -102,8 +102,8 @@ Task("dotnet-templates")
|
|||
var properties = new Dictionary<string, string> {
|
||||
// Properties that ensure we don't use cached packages, and *only* the empty NuGet.config
|
||||
{ "RestoreNoCache", "true" },
|
||||
{ "RestorePackagesPath", MakeAbsolute(File(templatesTest + "packages")).FullPath },
|
||||
{ "RestoreConfigFile", MakeAbsolute(File(templatesTest + "nuget.config")).FullPath },
|
||||
{ "RestorePackagesPath", MakeAbsolute(templatesTest.CombineWithFilePath("packages")).FullPath },
|
||||
{ "RestoreConfigFile", MakeAbsolute(templatesTest.CombineWithFilePath("nuget.config")).FullPath },
|
||||
|
||||
// Avoid iOS build warning as error on Windows: There is no available connection to the Mac. Task 'VerifyXcodeVersion' will not be executed
|
||||
{ "CustomBeforeMicrosoftCSharpTargets", MakeAbsolute(File("./src/Templates/TemplateTestExtraTargets.targets")).FullPath },
|
||||
|
@ -117,7 +117,7 @@ Task("dotnet-templates")
|
|||
|
||||
foreach (var template in new [] { "maui", "maui-blazor", "mauilib" })
|
||||
{
|
||||
var name = template.Replace("-", "") + " Space-Dash";
|
||||
var name = template.Replace("-", "_").Replace(" ", "_");
|
||||
StartProcess(dn, $"new {template} -o \"{templatesTest}{name}\"");
|
||||
|
||||
// Design-time build without restore
|
||||
|
@ -129,9 +129,10 @@ Task("dotnet-templates")
|
|||
// Build
|
||||
RunMSBuildWithDotNet($"{templatesTest}{name}", properties, warningsAsError: true);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CleanDirectories(templatesTest);
|
||||
CleanDirectories(templatesTest.FullPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -189,7 +190,7 @@ Task("dotnet-pack")
|
|||
// - _NativeAssets.windows
|
||||
// - libSkiaSharp.pdb
|
||||
// - libHarfBuzzSharp.pdb
|
||||
var assetsDir = "./artifacts/additional-assets";
|
||||
var assetsDir = $"./artifacts/additional-assets";
|
||||
var nativeAssetsVersion = XmlPeek("./eng/Versions.props", "/Project/PropertyGroup/_SkiaSharpNativeAssetsVersion");
|
||||
NuGetInstall("_NativeAssets.windows", new NuGetInstallSettings
|
||||
{
|
||||
|
@ -209,6 +210,52 @@ Task("dotnet-build-test")
|
|||
.IsDependentOn("dotnet-build")
|
||||
.IsDependentOn("dotnet-test");
|
||||
|
||||
Task("dotnet-diff")
|
||||
.Does(() =>
|
||||
{
|
||||
var nupkgs = GetFiles($"./artifacts/**/*.nupkg");
|
||||
if (!nupkgs.Any())
|
||||
{
|
||||
Warning($"##vso[task.logissue type=warning]No NuGet packages were found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var diffCacheDir = tempDirectory.Combine("diffCache");
|
||||
EnsureDirectoryExists(diffCacheDir);
|
||||
CleanDirectories(diffCacheDir.FullPath);
|
||||
|
||||
EnsureDirectoryExists(diffDirectory);
|
||||
CleanDirectories(diffDirectory.FullPath);
|
||||
|
||||
foreach (var nupkg in nupkgs)
|
||||
{
|
||||
DotNetCoreTool("api-tools", new DotNetCoreToolSettings
|
||||
{
|
||||
DiagnosticOutput = true,
|
||||
ArgumentCustomization = builder => builder
|
||||
.Append("nuget-diff")
|
||||
.AppendQuoted(nupkg.FullPath)
|
||||
.Append("--latest")
|
||||
// .Append("--verbose")
|
||||
.Append("--prerelease")
|
||||
.Append("--group-ids")
|
||||
.Append("--ignore-unchanged")
|
||||
.AppendSwitchQuoted("--output", diffDirectory.FullPath)
|
||||
.AppendSwitchQuoted("--cache", diffCacheDir.FullPath)
|
||||
});
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CleanDirectories(diffCacheDir.FullPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Information("Unable to clean up diff cache directory.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Tasks for Local Development
|
||||
|
||||
Task("VS-DOGFOOD")
|
||||
|
|
|
@ -43,6 +43,7 @@ if ($IsWindows)
|
|||
# Modify global.json, so the IDE can load
|
||||
$globaljson = Join-Path $PSScriptRoot ../global.json
|
||||
[xml] $xml = Get-Content (Join-Path $PSScriptRoot Versions.props)
|
||||
$jsonBackup = Get-Content $globaljson
|
||||
$json = Get-Content $globaljson | ConvertFrom-Json
|
||||
$json | Add-Member sdk (New-Object -TypeName PSObject) -Force
|
||||
$json.sdk | Add-Member version ([string]$xml.Project.PropertyGroup.MicrosoftDotnetSdkInternalPackageVersion).Trim() -Force
|
||||
|
@ -101,6 +102,7 @@ if ($IsWindows)
|
|||
$env:DOTNET_MULTILEVEL_LOOKUP=$oldDOTNET_MULTILEVEL_LOOKUP
|
||||
$env:MSBuildEnableWorkloadResolver=$oldMSBuildEnableWorkloadResolver
|
||||
$env:PATH=$oldPATH
|
||||
$jsonBackup | Set-Content $globaljson
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -184,6 +184,9 @@ stages:
|
|||
poolName: ${{ BuildPlatform.poolName }}
|
||||
- pwsh: ./build.ps1 --target=dotnet-pack --configuration="Release" --verbosity=diagnostic
|
||||
displayName: 'Pack .NET Maui'
|
||||
- ${{ if eq(BuildPlatform.name, 'Windows') }}:
|
||||
- pwsh: ./build.ps1 --target=dotnet-diff --configuration="Release" --verbosity=diagnostic
|
||||
displayName: 'Diff .NET Maui artifacts with NuGet'
|
||||
- task: CopyFiles@2
|
||||
condition: always()
|
||||
displayName: 'Copy files to staging'
|
||||
|
@ -202,6 +205,7 @@ stages:
|
|||
SourceFolder: artifacts
|
||||
Contents: |
|
||||
metadata/**
|
||||
api-diff/**
|
||||
TargetFolder: $(build.artifactstagingdirectory)
|
||||
- task: CopyFiles@2
|
||||
displayName: 'Copy Log Files'
|
||||
|
|
Загрузка…
Ссылка в новой задаче