From fc23448084d8a6800c4f782cae73c4d6601c1f9e Mon Sep 17 00:00:00 2001 From: Frank Robijn <13610628+frobijn@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:20:56 +0200 Subject: [PATCH] Add publishing of NuGet package with CLI version (#167) --- MetadataProcessor.Console/Program.cs | 2 +- MetadataProcessor.Console/package.nuspec | 37 ++++++++++++++++++++++++ README.md | 8 +++++ azure-pipelines.yml | 24 +++++++++++---- 4 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 MetadataProcessor.Console/package.nuspec diff --git a/MetadataProcessor.Console/Program.cs b/MetadataProcessor.Console/Program.cs index 070b1f98..3fdd6cc0 100644 --- a/MetadataProcessor.Console/Program.cs +++ b/MetadataProcessor.Console/Program.cs @@ -213,7 +213,7 @@ public static void Main(string[] args) { System.Console.WriteLine(""); System.Console.WriteLine("-parse Analyses .NET assembly."); - System.Console.WriteLine("-compile Compiles an assembly into nanoCLR format. Optionally flags if this it's a core library."); + System.Console.WriteLine("-compile Compiles an assembly into nanoCLR format and (true/false) if this it's a core library."); System.Console.WriteLine("-loadHints Loads one (or more) assembly file(s) as a dependency(ies)."); System.Console.WriteLine("-excludeClassByName Removes the class from an assembly."); System.Console.WriteLine("-generateskeleton Generate skeleton files with stubs to add native code for an assembly."); diff --git a/MetadataProcessor.Console/package.nuspec b/MetadataProcessor.Console/package.nuspec new file mode 100644 index 00000000..65b94f24 --- /dev/null +++ b/MetadataProcessor.Console/package.nuspec @@ -0,0 +1,37 @@ + + + + nanoFramework.Tools.MetadataProcessor.CLI + nanoFramework.Tools.MetadataProcessor.CLI + $version$ + nanoframework + Command line interface to the Metadata Processor that is used internally by nanoFramework tooling and VS extensions. It is not needed for regular nanoFramework projects, but there are a few use cases where this tool is required. + + + docs\README.md + https://github.com/nanoframework/metadata-processor + images\nf-logo.png + LICENSE.md + false + + Copyright (c) .NET Foundation and Contributors + + nanoFramework + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index 16f917d1..51392cdc 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ Is part of .NET **nanoFramework** toolbox, along with other various tools that a Version 2.0 is a C# application adapted from the original work of [Oleg Rakhmatulin](@OlegRa). Version 1.0 was a Visual C++ application adapted from .NETMF toolbox. +## Using the metadata processor + +The metadata processor is available in two packages. + +The main use of the metadata processor is packaged as a MSBuild task: [nanoFramework.Tools.MetadataProcessor.MsBuildTask](https://www.nuget.org/packages/nanoFramework.Tools.MetadataProcessor.MsBuildTask). The task is well integrated into the .NET **nanoFramework** build system and is distributed as part of the VS extensions. Almost all use cases can be addressed by the build system as it is, or by setting build variables for, e.g., additional logging. + +There are few use cases where the build task cannot be used. E.g., in software that generates source code at runtime, compiles the code via Roslyn, executes it on the virtual device, and uses the output for further processing. The metadata processor is required as a companion to Roslyn to convert the generated .NET assemblies to .NET **nanoFramework** .pe assemblies. The second package, [nanoFramework.Tools.MetadataProcessor.CLI](https://www.nuget.org/packages/nanoFramework.Tools.MetadataProcessor.CLI), contains a CLI version of the tool for this purpose. It is packaged as content: if added to a project, the tool will be distributed with the results of that project. If the package is added to a non-SDK-style project (e.g., .NET Framework project), make sure to set the *Copy to Output Directory* property for the files, as the package manager does not automatically do that. The code in the project should run the CLI with arguments *-loadhints*, *-parse* and *-compile* (in that order!) to create the .pe assembly. + ## Developers guide ### Cloning the repository diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 27477a4c..2df54475 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -209,6 +209,25 @@ jobs: TargetFolder: '$(Build.ArtifactStagingDirectory)' flattenFolders: true + # set cloud build vars again as they've been overriten by the tests run + - script: nbgv cloud -a -c + condition: succeeded() + displayName: Set build number + + - task: PowerShell@2 + condition: succeeded() + displayName: Save cloud build number + inputs: + targetType: 'inline' + script: Write-Host "$("##vso[build.updatebuildnumber]")$env:NBGV_NuGetPackageVersion" + + - task: NuGetCommand@2 + condition: succeeded() + displayName: Pack NuGet with MetadataProcessor Console + inputs: + command: 'custom' + arguments: 'pack MetadataProcessor.Console\package.nuspec -Version $(NBGV_NuGetPackageVersion) -properties commit="$(Build.SourceVersion)" -properties NoWarn=NU5100' + - task: CopyFiles@1 condition: succeeded() displayName: Collecting NuGet package artifact @@ -255,11 +274,6 @@ jobs: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: deployables - # set cloud build vars again as they've been overriten by the tests run - - script: nbgv cloud -a -c - condition: succeeded() - displayName: Set build number - # push NuGet packages to NuGet (always happens except on PR builds) - task: NuGetCommand@2 displayName: Push NuGet packages to NuGet