dotnet-subset
0.3.2
dotnet tool install --global dotnet-subset --version 0.3.2
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local dotnet-subset --version 0.3.2
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dotnet-subset&version=0.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package dotnet-subset --version 0.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
dotnet-subset
dotnet-subset
is a .NET tool that copies a subset of files from a repository to a directory.
The tool is mainly used in Dockerfiles to optimize the docker build caching for "dotnet restore" instructions.
Motivation
To learn more about the motivation behind dotnet-subset
, please read the related blog post.
Features
- Supports a single project or a solution file as input.
- Copies all the required files for the root projects, including their project dependencies transitiverly.
- Copies imported MSBuild files, including Directory.Build.props and Directory.Build.targets.
- For each required project, copies all NuGet configuration files involved in computing its effective NuGet settings. See How NuGet settings are applied.
dotnet-subset
also supports custom NuGet configuration filepath defined in the project's csproj. - For each required project, copies the NuGet lock file and support the
NuGetLockFilePath
property. Seehttps://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#lock-file-extensibility
. - Only copies files under the specified root, while maintaining their relative path to it.
Installation
From NuGet
dotnet tool install --global dotnet-subset
From source
Prerequisite: .NET SDK 2.1 or newer
- Clone this repository
- Open a terminal in the repository's root
dotnet pack --configuration Release --version-suffix local
dotnet tool update dotnet-subset --global --prerelease --add-source ./artifacts/Release/nupkg/dotnet-subset/
Usage
Description:
Create a subset for the restore operation.
Usage:
dotnet-subset restore <projectOrSolution> [options]
Arguments:
<projectOrSolution> Project or solution to restore.
Options:
--root-directory <root-directory> (REQUIRED) Directory from where the files will be copied, usually the
repository's root.
--output <output> (REQUIRED) Directory where the subset files will be copied,
preserving the original hierarchy.
-?, -h, --help Show help and usage information
Example with a project:
dotnet subset restore /source/complexapp/complexapp.csproj --root-directory /source/ --output /tmp/restore_subset/
Example with a solution:
dotnet subset restore /source/complexapp.sln --root-directory /source/ --output /tmp/restore_subset/
dotnet-subset + docker
Please check these pull requests to see how to use dotnet-subset
in your Dockerfile
:
- https://github.com/othmane-kinane-nw/eShopOnContainers/pull/1/files?diff=unified&w=0
- https://github.com/othmane-kinane-nw/modular-monolith-with-ddd/pull/1/files?diff=unified&w=0
- https://github.com/othmane-kinane-nw/dotnet-docker/pull/1/files?diff=unified&w=0
Roadmap
- Add tests
- Automate the versionning
- Automate the deployment to NuGet
- Refactor the codebase
- Add "build" algorithm
License
Copyright © Nimbleways, Othmane Kinane and contributors.
dotnet-subset
is provided as-is under the MIT license. For more information see LICENSE.
- For Microsoft.Build, see https://github.com/dotnet/msbuild/blob/main/LICENSE
- For Microsoft.Build.Locator, see https://github.com/microsoft/MSBuildLocator/blob/master/LICENSE
- For System.CommandLine, see https://github.com/dotnet/command-line-api/blob/main/LICENSE.md
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.