Skip to content

Add publishing of NuGet package with CLI version #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

frobijn
Copy link
Contributor

@frobijn frobijn commented Aug 12, 2024

Description

  • Added nuspec for the MDP CLI
  • Updated the README.md with a description of the two packages
  • Updated the azure pipeline
  • Corrected the help text for the MDP console application

The package is named nanoFramework.Tools.MetadataProcessor.CLI to emphasize that it is intended to be an interface and not a general purpose tool. In the tags only nanoFramework is kept, as this is not a tool for the general audience.

In the README.md I've tried to describe the specific use case. I've tried to phrase the text in a way to discourage a regular user to play with this package. I've tried to describe (better?) my use case, where I have unit tests that generate code, compile the code with Roslyn, make a .pe assembly, use nanoclr --loadassemblies and use the output to assert whether a test is successful. This is probably a very niche application, for users who meddle with source generators.

For this application the content of the package needs to end up in the output (bin) directory of the project that uses the package. The code in the project will use something as Cli.Wrap (nanoFramework.Tools.MetadataProcessor.exe) to convert a *.dll to *.pe file. Hence the package will put the MDP-files in the content directory and not the lib or tools directory.

Unfortunately the way package managers handle content files differs.

  • If the project is added to a modern SDK-style project, it is possible to add the files with build action=None and Copy to Output Directory = true. The package manager expects content files in the contentFiles directory in the package.
  • If the project is added to an old-style .NET Framework project, the files are copied from the content directory in the package, the build action is always Content and Copy to Output Directory is not set (hence = false). In the README.md this is described, the Copy to Output Directory must be assigned by hand.

The nuspec supports both package managers, which means that each file is in two locations in the package. This is in line with the recommendations in the description of the NuSpec format.

The azure pipeline is updated. Two steps are taken from the nuspec of the TestFramework. I understand the NuGet command but do not know if the version-related one is applicable. I've also moved a nbgv-command up the list, as I suspect the task must be run before the version is copied to the variable.

Motivation and Context

See the description for my specific use case. Earlier today I tried that and found that a feature I was using has a different implementation in nF than in .NET. Being able to test the code on a virtual device as part of a unit test very early on in the development cycle saves a lot of time. Any converter from *.dll to *.pe is fine. The MDP.exe is best suited as it already exists, is a console application so there are no problems with package dependencies and framework versions. It does more than needed, but I guess the typical user of this package is smart enough to leave those options alone.

How Has This Been Tested?

  • I've used the latest nuget to create the package from the nuspec with the command in the pipeline yaml
  • Configured a solution directory to use a directory as nuget source, with the package
  • Created two projects, SDK-style and .NET framework, and installed the package.
  • Verified that the package is installed as BuildAction=None,Copy=true in the SDK style project. Files are copied to the bin directory.
  • Verified that the package is installed as BuildAction=Content,Copy=false in the .NET framework project. Files are copied to the bin directory only after manually setting the Copy To Output Directory.
  • Verified that updates of the package are installed in the same way.

I don't know how to test the azure pipeline.

(I did not test the use of the package from the code of the project. I've done that before.)

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

Summary by CodeRabbit

  • New Features
    • Enhanced build process with new tasks for managing build numbers and packing NuGet packages.
    • Introduced a script to set cloud build variables, ensuring accurate versioning post-tests.
    • Added a PowerShell task to save cloud build number for correct versioning in NuGet packages.
    • Implemented a task for packing the NuGet package with appropriate metadata.

These improvements streamline the deployment process and enhance version control in the build pipeline.

- Updated the README.md with a description of the two packages
- Updated the azure pipeline
- Corrected the help text for the MDP console application

Signed-off-by: Frank Robijn <robijn@good-heavens.nl>
Copy link

coderabbitai bot commented Aug 12, 2024

Walkthrough

The recent changes to the Azure Pipelines configuration enhance the build process by introducing tasks for managing build numbers and packing a NuGet package. A script for setting cloud build variables ensures accurate versioning after tests are executed. Additionally, a PowerShell task saves the build number derived from the NuGet package version, and a new task for packing the package is included. These updates streamline automation and improve the overall deployment process.

Changes

Files Change Summary
azure-pipelines.yml Added tasks for setting cloud build variables, saving build numbers, and packing a NuGet package.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant AzurePipelines
    participant Testing
    participant NuGet

    Developer->>AzurePipelines: Start Build
    AzurePipelines->>Testing: Run Tests
    Testing-->>AzurePipelines: Return Test Results
    AzurePipelines->>AzurePipelines: Update Build Number
    AzurePipelines->>NuGet: Pack NuGet Package
    NuGet-->>AzurePipelines: Package Created
    AzurePipelines-->>Developer: Build Complete
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2646438 and 24ff7db.

Files ignored due to path filters (3)
  • MetadataProcessor.Console/Program.cs is excluded by none and included by none
  • MetadataProcessor.Console/package.nuspec is excluded by none and included by none
  • README.md is excluded by !**/*.md and included by none
Files selected for processing (1)
  • azure-pipelines.yml (2 hunks)
Additional context used
yamllint
azure-pipelines.yml

[error] 216-216: trailing spaces

(trailing-spaces)


[warning] 221-221: wrong indentation: expected 6 but found 8

(indentation)


[error] 228-228: trailing spaces

(trailing-spaces)

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please address the suggestions from coderabbitai and it should be good to go.

Signed-off-by: Frank Robijn <robijn@good-heavens.nl>
@frobijn frobijn requested a review from josesimoes August 13, 2024 05:35
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 24ff7db and bd40afd.

Files selected for processing (1)
  • azure-pipelines.yml (2 hunks)
Additional context used
yamllint
azure-pipelines.yml

[error] 216-216: trailing spaces

(trailing-spaces)


[warning] 221-221: wrong indentation: expected 6 but found 8

(indentation)

Additional comments not posted (3)
azure-pipelines.yml (3)

216-216: Remove trailing spaces.

Line 216 contains trailing spaces, which should be removed for cleaner code.

Tools
yamllint

[error] 216-216: trailing spaces

(trailing-spaces)


221-221: Correct indentation.

The indentation on line 221 is incorrect. It should be adjusted to align with the expected YAML structure.

Tools
yamllint

[warning] 221-221: wrong indentation: expected 6 but found 8

(indentation)


228-228: Remove trailing spaces.

Line 228 contains trailing spaces, which should be removed for cleaner code.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bd40afd and 47b1ebb.

Files selected for processing (1)
  • azure-pipelines.yml (2 hunks)
Additional context used
yamllint
azure-pipelines.yml

[error] 216-216: trailing spaces

(trailing-spaces)

Additional comments not posted (14)
azure-pipelines.yml (14)

213-213: LGTM!

The script command to set cloud build variables is correctly implemented.


214-214: LGTM!

The condition succeeded() is correctly used to ensure the script runs only if previous tasks succeeded.


215-215: LGTM!

The display name "Set build number" is clear and descriptive.


217-217: LGTM!

The PowerShell task is correctly defined.


218-218: LGTM!

The condition succeeded() is correctly used to ensure the PowerShell task runs only if previous tasks succeeded.


219-219: LGTM!

The display name "Save cloud build number" is clear and descriptive.


220-220: LGTM!

The inputs section is correctly structured.


222-222: LGTM!

The script to update the build number is correctly implemented.


223-223: LGTM!

The blank line is appropriately placed for readability.


224-224: LGTM!

The NuGetCommand task is correctly defined.


225-225: LGTM!

The condition succeeded() is correctly used to ensure the NuGetCommand task runs only if previous tasks succeeded.


226-226: LGTM!

The display name "Pack NuGet with MetadataProcessor Console" is clear and descriptive.


227-227: LGTM!

The inputs section is correctly structured.


229-229: LGTM!

The arguments for the NuGetCommand task are correctly specified.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

@josesimoes josesimoes changed the title Revive the MDP CLI NuGet package for special purposes Add publishing of MDP CLI NuGet package Aug 13, 2024
@josesimoes josesimoes changed the title Add publishing of MDP CLI NuGet package Add publishing of NuGet package with CLI version Aug 13, 2024
@josesimoes josesimoes merged commit fc23448 into nanoframework:main Aug 13, 2024
4 checks passed
@nfbot
Copy link
Member

nfbot commented Aug 13, 2024

@frobijn thank you again for your contribution! 🙏😄

.NET nanoFramework is all about community involvement, and no contribution is too small.
We would like to invite you to join the project's Contributors list.

Please edit it and add an entry with your GitHub username in the appropriate location (names are sorted alphabetically):

  <tr>
    <td><img src="https://github.com/frobijn.png?size=50" height="50" width="50" ></td>
    <td><a href="https://github.com/frobijn">Frank Robijn</a></td>
  </tr>

(Feel free to adjust your name if it's not correct)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants