@ -1,6 +1,7 @@
using System ;
using System ;
using System.Diagnostics ;
using System.Diagnostics ;
using System.IO ;
using System.IO ;
using System.IO.Compression ;
using System.Linq ;
using System.Linq ;
using System.Runtime.InteropServices ;
using System.Runtime.InteropServices ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
@ -38,9 +39,12 @@ partial class Build : NukeBuild
[PackageExecutable("Microsoft.DotNet.GenAPI.Tool", "Microsoft.DotNet.GenAPI.Tool.dll", Framework = "net8.0")]
[PackageExecutable("Microsoft.DotNet.GenAPI.Tool", "Microsoft.DotNet.GenAPI.Tool.dll", Framework = "net8.0")]
Tool ApiGenTool ;
Tool ApiGenTool ;
protected override void OnBuildInitialized ( )
protected override void OnBuildInitialized ( )
{
{
Parameters = new BuildParameters ( this ) ;
Parameters = new BuildParameters ( this , ScheduledTargets . Contains ( BuildToNuGetCache ) ) ;
Information ( "Building version {0} of Avalonia ({1}) using version {2} of Nuke." ,
Information ( "Building version {0} of Avalonia ({1}) using version {2} of Nuke." ,
Parameters . Version ,
Parameters . Version ,
Parameters . Configuration ,
Parameters . Configuration ,
@ -82,6 +86,12 @@ partial class Build : NukeBuild
c . AddProperty ( "PackageVersion" , Parameters . Version )
c . AddProperty ( "PackageVersion" , Parameters . Version )
. SetConfiguration ( Parameters . Configuration )
. SetConfiguration ( Parameters . Configuration )
. SetVerbosity ( DotNetVerbosity . Minimal ) ;
. SetVerbosity ( DotNetVerbosity . Minimal ) ;
if ( Parameters . IsPackingToLocalCache )
c
. AddProperty ( "ForcePackAvaloniaNative" , "True" )
. AddProperty ( "SkipObscurePlatforms" , "True" )
. AddProperty ( "SkipBuildingSamples" , "True" )
. AddProperty ( "SkipBuildingTests" , "True" ) ;
return c ;
return c ;
}
}
DotNetBuildSettings ApplySetting ( DotNetBuildSettings c , Configure < DotNetBuildSettings > configurator = null ) = >
DotNetBuildSettings ApplySetting ( DotNetBuildSettings c , Configure < DotNetBuildSettings > configurator = null ) = >
@ -325,6 +335,39 @@ partial class Build : NukeBuild
. DependsOn ( Package )
. DependsOn ( Package )
. DependsOn ( ZipFiles ) ;
. DependsOn ( ZipFiles ) ;
Target BuildToNuGetCache = > _ = > _
. DependsOn ( CreateNugetPackages )
. Executes ( ( ) = >
{
if ( ! Parameters . IsPackingToLocalCache )
throw new InvalidOperationException ( ) ;
foreach ( var path in Parameters . NugetRoot . GlobFiles ( "*.nupkg" ) )
{
using var f = File . Open ( path . ToString ( ) , FileMode . Open , FileAccess . Read ) ;
using var zip = new ZipArchive ( f , ZipArchiveMode . Read ) ;
var nuspecEntry = zip . Entries . First ( e = > e . FullName . EndsWith ( ".nuspec" ) & & e . FullName = = e . Name ) ;
var packageId = XDocument . Load ( nuspecEntry . Open ( ) ) . Document . Root
. Elements ( ) . First ( x = > x . Name . LocalName = = "metadata" )
. Elements ( ) . First ( x = > x . Name . LocalName = = "id" ) . Value ;
var packagePath = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ,
".nuget" ,
"packages" ,
packageId . ToLowerInvariant ( ) ,
BuildParameters . LocalBuildVersion ) ;
if ( Directory . Exists ( packagePath ) )
Directory . Delete ( packagePath , true ) ;
Directory . CreateDirectory ( packagePath ) ;
zip . ExtractToDirectory ( packagePath ) ;
File . WriteAllText ( Path . Combine ( packagePath , ".nupkg.metadata" ) , @ "{
"" version "" : 2 ,
"" contentHash "" : "" e900dFK7jHJ2WcprLcgJYQoOMc6ejRTwAAMi0VGOFbSczcF98ZDaqwoQIiyqpAwnja59FSbV + GUUXfc3vaQ2Jg = = "" ,
"" source "" : "" https : //api.nuget.org/v3/index.json""
} ");
}
} ) ;
Target GenerateCppHeaders = > _ = > _. Executes ( ( ) = >
Target GenerateCppHeaders = > _ = > _. Executes ( ( ) = >
{
{
var file = MicroComCodeGenerator . Parse (
var file = MicroComCodeGenerator . Parse (