Skip to content

Commit

Permalink
Add publishing of NuGet package with CLI version (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
frobijn authored Aug 13, 2024
1 parent 2646438 commit fc23448
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MetadataProcessor.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static void Main(string[] args)
{
System.Console.WriteLine("");
System.Console.WriteLine("-parse <path-to-assembly-file> Analyses .NET assembly.");
System.Console.WriteLine("-compile <path-to-PE-file> Compiles an assembly into nanoCLR format. Optionally flags if this it's a core library.");
System.Console.WriteLine("-compile <path-to-PE-file> <isCoreLibrary> Compiles an assembly into nanoCLR format and (true/false) if this it's a core library.");
System.Console.WriteLine("-loadHints <assembly-name> <path-to-assembly-file> Loads one (or more) assembly file(s) as a dependency(ies).");
System.Console.WriteLine("-excludeClassByName <class-name> Removes the class from an assembly.");
System.Console.WriteLine("-generateskeleton Generate skeleton files with stubs to add native code for an assembly.");
Expand Down
37 changes: 37 additions & 0 deletions MetadataProcessor.Console/package.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>nanoFramework.Tools.MetadataProcessor.CLI</id>
<title>nanoFramework.Tools.MetadataProcessor.CLI</title>
<version>$version$</version>
<authors>nanoframework</authors>
<description>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.</description>
<releaseNotes>
</releaseNotes>
<readme>docs\README.md</readme>
<projectUrl>https://github.com/nanoframework/metadata-processor</projectUrl>
<icon>images\nf-logo.png</icon>
<license type="file">LICENSE.md</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<repository type="git" url="https://github.com/nanoframework/metadata-processor" commit="$commit$" />
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
<references></references>
<tags>nanoFramework</tags>
<contentFiles>
<files include="any\any\MetadataProcessor\**" buildAction="None" copyToOutput="true"/>
</contentFiles>
</metadata>
<files>
<file src="..\assets\nf-logo.png" target="images\" />
<file src="..\LICENSE.md" target="" />
<file src="..\README.md" target="docs\" />
<!-- Installation via packages.json -->
<file src="bin\Release\*.dll" target="content/MetadataProcessor" />
<file src="bin\Release\*.exe" target="content/MetadataProcessor" />
<file src="bin\Release\*.exe.config" target="content/MetadataProcessor" />
<!-- Installation via PackageReference -->
<file src="bin\Release\*.dll" target="/contentFiles/any/any/MetadataProcessor" />
<file src="bin\Release\*.exe" target="/contentFiles/any/any/MetadataProcessor" />
<file src="bin\Release\*.exe.config" target="/contentFiles/any/any/MetadataProcessor" />
</files>
</package>
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 19 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fc23448

Please sign in to comment.