# .NET 7 on Ubuntu

Table of Content:
- [Support](#support)
- [End of Life process](#end-of-life-process)
- [Package Design Considerations](#package-design-considerations)
- [Building the Binary Packages](#building-the-binary-packages)
- [Get the orig tarball (for Canonical Package Maintainers)](#get-the-orig-tarball-for-canonical-package-maintainers)

## Support

.NET 7 is a Standard Term Support (STS) Release. This means that .NET 7 gets
free support and patches for 18 months from Microsoft (until May 14, 2024).
The quality of an STS release is exactly the same as a Long Term Support (LTS)
release; the only difference is the support length.

Patch updates are released monthly on the second Tuesday of each month, also
known as Patch Tuesday. Within the .NET 7 release support lifecycle, systems
must remain current on released patch updates. Patches to releases are
compatible, which eliminates the risk of adversely affecting applications.

Microsoft provides Canonical early access to .NET 7 patches to ensure a smooth
and simultaneous release on all platforms on the same day, secure the software
supply chain between .NET and Ubuntu, and provide enterprise-grade support.
Canonical's Security Team handles security releases, and Canonical's Toolchains
Squad of the Foundations Team handles non-security releases.

Canonical does not support .NET 7 after Microsoft's STS period ends.

Please report bugs related to the .NET 7 Ubuntu Package to
[Launchpad](https://bugs.launchpad.net/ubuntu/+source/dotnet7) instead of the
upstream bug trackers. We are working closely with Microsoft to fix bugs and
improve the user experience and will forward issues if necessary.

**See also:**
- [Microsoft .NET Support Policy](https://dotnet.microsoft.com/en-us/platform/support/policy)
- [Launchpad – `dotnet7` Bug Tracker](https://bugs.launchpad.net/ubuntu/+source/dotnet7)
- [Ubuntu CVE Tracker for .NET 7](https://ubuntu.com/security/cves?package=dotnet7)
- [Canonical Blog Article about the collaboration with Microsoft](https://canonical.com/blog/install-dotnet-on-ubuntu)

## End of Life Process

As mentioned in the section [Support](#support), .NET 7 reaches its end of life
(support) on May 14, 2024. Canonical does not extend Microsoft's Support period.

The latest released .NET 7 packages will remain available in the Ubuntu Archive,
but Canonical will not extend Microsoft's Support period. Security related bugs
will not get fixed; therefore, switch to one of the supported .NET versions is
strongly recommended, which you can find [here](https://dotnet.microsoft.com/en-us/platform/support/policy).

## Package Design Considerations

### `debian/watch` file

The .NET 7 source code is distributed over several public repositories and has
no single public place to download the source from. The watch file can only
check if a new version has been released. Canonical gets the source from a private
repository for Microsoft's security partners.

This will change with the Virtual Monolithic Repository that .NET 8 introduced
(See: https://github.com/dotnet/dotnet). If you want to build the upstream
.NET 7 source, yourself you have to follow these instructions:
https://github.com/dotnet/installer#build-net-from-source-source-build

### Lintian Overrides

 * `license-problem-non-free-RFC`: Every folder under `src` includes a
 `THIRD_PARTY_NOTICES.TXT` file (that triggers the error). Also, the file
 `src/runtime.*/src/coreclr/utilcode/guidfromname.cpp` is multilicensed.

 * `source-is-missing`: We have three cases here for
   overriding this:
   1. JS files: It looks like these are all false positives. The `*.js` files
      all contain the full source code and license headers. Also, there are
      `*.min.js` files available; these would be a problem if the corresponding
      `*.js` did not accompany them.
   2. HTML files: Also a false positive due to using the substring ".Link" in
      their names.
   3. prebuilds from [Microsoft Arcade](https://github.com/dotnet/arcade): These
      files are needed for bootstrapping the first release of the package (they
      will disappear in upcoming releases).

## Building the Binary Packages

Because .NET gets built with .NET itself, building the binary packages of this
source package is not trivial. Notice that in the `debian/control` file, the
`dotnet7` source package `Build-Depends` on the binary packages it produces
(`dotnet-sdk-7.0` and `dotnet-sdk-7.0-source-built-artifacts`).

You have to use a previous build from the Ubuntu Archive. Canonical will
bootstrap the initial version.

### Requirements

- ~100GB Disk Space
- `sbuild` is set up ([How to set up your environment for Ubuntu Development?](https://github.com/canonical/ubuntu-maintainers-handbook/blob/main/Setup.md))
- a [`schroot`](https://manpages.ubuntu.com/manpages/mantic/en/man1/schroot.1.html)
  for `mantic` and the architecture you want to build for
  (e.g., with `mk-sbuild mantic`)

### Build from Ubuntu Previous Build

1. Get the latest source from [Launchpad](https://launchpad.net/ubuntu/+source/dotnet7) with
    ```
    pull-lp-source dotnet7
    ```

    After the command finishes, you should have a
    - `dotnet7_*.orig.tar.xz` tarball file
    - `dotnet7_*.debian.tar.xz` tarball file
    - `dotnet7-*` folder where both are unpacked

2. Build the source with
    ```
    sbuild \
      --dist=mantic \
      --arch-any --arch=amd64 --no-arch-all --no-source \
      --apt-update --apt-upgrade \
      --no-run-lintian \
      --purge-build=successful \
      dotnet7_*.dsc
    ```

    NOTE: replace `--arch=amd64` with `--arch=arm64` if you want to build the
    binary packages for `arm64`, but be aware that you need to build on an
    `arm64` system.

    NOTE: The argument `--no-run-lintian` is optional, but depending on your
    system, running `lintian` can take up to 1 hour.

## Get the orig tarball (for Canonical Package Maintainers)

As explained in the section [*`debian/watch` file*](#debianwatch-file) we
(Canonical) only get the original source from a private repository. We do not
really need a `debian/watch` file for this repository as we weekly speak to
Microsoft about releases and we get notified by email if a new release is
available for us.

We use the `build-dotnet-tarball.sh` script to download the source and build
the `orig.tar` from it. You can run `build-dotnet-tarball.sh --help` to get
help how to use that script. The script also aims to give usefull error messages
if something is wrong.

NOTE: This script is practically useless for you if you have no access to the
dotnet security partners repository.

 -- Dominik Viererbe <dominik.viererbe@canonical.com>  Fri, 21 Jul 2023 09:57:31 +0300
