Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
4 changes: 0 additions & 4 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@
"SkipTests": {
"type": "boolean",
"description": "skip-tests"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded. Default is Avalonia.Controls.TreeDataGrid.sln"
}
}
},
Expand Down
12 changes: 3 additions & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ steps:
- task: UseDotNet@2
displayName: 'Use .NET SDK'
inputs:
version: 8.0.x
version: 9.0.x

- task: CmdLine@2
displayName: 'Install Nuke'
inputs:
script: |
dotnet tool install --global Nuke.GlobalTool --version 6.0.3

- script: nuke --target RunTests --configuration Release
- script: dotnet run --project $(Build.SourcesDirectory)/nukebuild/_build.csproj -- RunTests --configuration Release
displayName: 'Run Unit Tests'

- script: nuke --target Package --configuration Release
- script: dotnet run --project $(Build.SourcesDirectory)/nukebuild/_build.csproj -- Package --configuration Release
displayName: 'Generate Nuget Package'

- task: PublishBuildArtifacts@1
Expand Down
80 changes: 11 additions & 69 deletions nukebuild/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,14 @@

partial class Build : NukeBuild
{
[Solution("Avalonia.Controls.TreeDataGrid.sln")] readonly Solution Solution;

static Lazy<string> MsBuildExe = new Lazy<string>(() =>
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return null;

var msBuildDirectory = VSWhere("-latest -nologo -property installationPath -format value -prerelease").FirstOrDefault().Text;

if (!string.IsNullOrWhiteSpace(msBuildDirectory))
{
string msBuildExe = Path.Combine(msBuildDirectory, @"MSBuild\Current\Bin\MSBuild.exe");
if (!System.IO.File.Exists(msBuildExe))
msBuildExe = Path.Combine(msBuildDirectory, @"MSBuild\15.0\Bin\MSBuild.exe");

return msBuildExe;
}

return null;
}, false);

BuildParameters Parameters { get; set; }
protected override void OnBuildInitialized()
{
Parameters = new BuildParameters(this);
Information("Building version {0} of Avalonia.Controls.TreeDataGrid ({1}) using version {2} of Nuke.",
Parameters.Version,
Parameters.Configuration,
typeof(NukeBuild).Assembly.GetName().Version.ToString());
typeof(NukeBuild).Assembly.GetName()?.Version?.ToString());

if (Parameters.IsLocalBuild)
{
Expand All @@ -69,29 +48,12 @@ protected override void OnBuildInitialized()
void ExecWait(string preamble, string command, string args)
{
Console.WriteLine(preamble);
Process.Start(new ProcessStartInfo(command, args) {UseShellExecute = false}).WaitForExit();
Process.Start(new ProcessStartInfo(command, args) {UseShellExecute = false})?.WaitForExit();
}
ExecWait("dotnet version:", "dotnet", "--info");
ExecWait("dotnet workloads:", "dotnet", "workload list");
}

IReadOnlyCollection<Output> MsBuildCommon(
string projectFile,
Configure<MSBuildSettings> configurator = null)
{
return MSBuild(c => c
.SetProjectFile(projectFile)
// This is required for VS2019 image on Azure Pipelines
.When(_ => Parameters.IsRunningOnWindows && Parameters.IsRunningOnAzure, _ => _
.AddProperty("JavaSdkDirectory", GetVariable<string>("JAVA_HOME_11_X64")))
.AddProperty("PackageVersion", Parameters.Version)
.AddProperty("iOSRoslynPathHackRequired", true)
.SetProcessToolPath(MsBuildExe.Value)
.SetConfiguration(Parameters.Configuration)
.SetVerbosity(MSBuildVerbosity.Minimal)
.Apply(configurator));
}

Target Clean => _ => _.Executes(() =>
{
Parameters.BuildDirs.ForEach(p => p.DeleteDirectory());
Expand All @@ -107,18 +69,11 @@ IReadOnlyCollection<Output> MsBuildCommon(
.DependsOn(Clean)
.Executes(() =>
{
if (Parameters.IsRunningOnWindows)
MsBuildCommon(Parameters.MSBuildSolution, c => c
.SetProcessAdditionalArguments("/r")
.AddTargets("Build")
);

else
DotNetBuild(c => c
.SetProjectFile(Parameters.MSBuildSolution)
.AddProperty("PackageVersion", Parameters.Version)
.SetConfiguration(Parameters.Configuration)
);
DotNetBuild(c => c
.SetProjectFile(Parameters.MSBuildSolution)
.AddProperty("PackageVersion", Parameters.Version)
.SetConfiguration(Parameters.Configuration)
);
});

Target RunCoreLibsTests => _ => _
Expand Down Expand Up @@ -165,15 +120,10 @@ IReadOnlyCollection<Output> MsBuildCommon(
.After(RunTests)
.Executes(() =>
{
if (Parameters.IsRunningOnWindows)

MsBuildCommon(Parameters.MSBuildSolution, c => c
.AddTargets("Pack"));
else
DotNetPack(c => c
.SetProject(Parameters.MSBuildSolution)
.SetConfiguration(Parameters.Configuration)
.AddProperty("PackageVersion", Parameters.Version));
DotNetPack(c => c
.SetProject(Parameters.MSBuildSolution)
.SetConfiguration(Parameters.Configuration)
.AddProperty("PackageVersion", Parameters.Version));
});

Target RunTests => _ => _
Expand All @@ -199,11 +149,3 @@ public static int Main() =>
? Execute<Build>(x => x.Package)
: Execute<Build>(x => x.RunTests);
}

public static class ToolSettingsExtensions
{
public static T Apply<T>(this T settings, Configure<T> configurator)
{
return configurator != null ? configurator(settings) : settings;
}
}
2 changes: 1 addition & 1 deletion nukebuild/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace></RootNamespace>
<IsPackable>False</IsPackable>
Expand Down
Loading