Skip to content
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

Create Nuget Packages for C# #177

Merged

Conversation

bpkroth
Copy link
Contributor

@bpkroth bpkroth commented Nov 14, 2020

This is the first step in a line of work aimed towards making MLOS more natively consumable by external projects.

The basic idea here is that we use the standard .NET.Sdk method of packaging each of the relevant .csprojs as their own .nupkg.
This let's us rely on dotnet to automatically track PackageReference and ProjectReference dependencies and generate them into the .nuspec that produces the .nupkg.

Since .nupkg files are considered immutable, we have to create unique version numbers for each of them.
To do this, I added GitVersionTask, but only for the OSS builds.

Typically, GitVersion expects one to use GitFlow or GithubFlow workflows with develop and release branches.
We are currently only using a Mainline workflow model, so the GitVersion.yml file is configure as such.
The versions produced use SemVer by default, so when building on a branch, we get a version like the following:
Mlos.SettingsSystem.CodeGen.0.1.1-codegen-nuget-for-external-project-integration.33.nupkg
Where

  • the 0.1.1 portion is taken as the number of commits on the mainline branch since the last v0.1.0 tag found in the repo
  • the -codegen-nuget-for-external-project-integration is the name of the branch
  • and the .33 is the number of commits since that branch point.
    In effect, we can use git tag to version our x.y.z releases, at least until we start adding release/0.1.x style servicing branches.

For the moment, the .nupkg files are not signed and not published (e.g. to nuget.org). Instead, we produce them into the target/pkg/$(Configuration)/ tree whenever either the new Mlos.NetCore.Components.Packages.proj is build or else when dotnet pack is run on some .csproj.

The ExternalIntegrationExample.SettingsRegistry.csproj (which otherwise uses no Mlos build rules and acts as a standard .NET.Sdk example) is used for testing and is configured to pull from that tree (for local testing) as well.

The next stage of work (separate PR) is to configure a set of cmake rules using FetchContent to grab the C++ components, build these packages and reference them when building the rest of a C++ project and its dependencies.

TODO:

  • Enable the test project and package building in CI
    • for Windows
    • for Linux
  • Test VisualStudio build
  • Verify CDPX/CoreXT builds (!473121)

WONTFIX:

  • Leaving actual publishing/signing to nuget.org for a future PR

also
- fix some minor bugs
- and provide a way to increase the verbosity
also, make sure that all MsBuild tasks use a consistent Configuration
… for normal logging mode)"

This reverts commit 112f811.
Also fix a bug where a former codegen file was still being declared, but not referenced.
GitVersion.yml Show resolved Hide resolved
This works around the fact that GitVersionTask doesn't support pre-release tags
(the only kinds we have for the "master" branch in ADO atm), when attempting to
compute the current "version" as an offset from the last tag in Mainline mode.

Instead, we detect when we're on the ADO branch by looking for the ADO
`.pipelines\pipeline.windows.yml` file and disable GitVersionTask in that case.

Also, since Mlos.NetCore.Components.Packages.proj is not a .csproj, it doesn't
include the `build/version/Mlos.NetCore.Version.props` file, so we move those
property definitions to `build/Mlos.Common.props`.

Note that this doesn't prevent that project from packaging things when built on
ADO (though it isn't included by default in `dirs.proj`), so one could still
test the `ExternalIntegrationExample.SettingsRegistry.csproj` manually, however
the versions of the `.nupkg` files it produces will currently always be `1.0.0`
so some additional effort may be required to replace previously restored
packages using that version.
GitVersion.yml Show resolved Hide resolved
@bpkroth bpkroth marked this pull request as ready for review November 17, 2020 22:20
@bpkroth bpkroth merged commit 9093352 into microsoft:main Nov 18, 2020
@bpkroth bpkroth mentioned this pull request Nov 23, 2020
3 tasks
bpkroth added a commit that referenced this pull request Dec 2, 2020
Work to make it easier/possible to integrate the C++ components of MLOS with an external C++ project (e.g. LevelDB, MySql, etc.) via `cmake`.

- Fixes some issues with our own `cmake` config assumptions.
- Adds examples patterns and documentation for using in an "external project" (currently just a minimal example).
- Hooks those into the CI pipelines.

This branch was split off of the work from #177 (since merged) to build NuGet packages for some of the C# components, so many of the original commits are shared.
@bpkroth bpkroth deleted the codegen-nuget-for-external-project-integration branch March 20, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants