|
| 1 | +# Automatic dependency flow Repo API |
| 2 | + |
| 3 | +Repos must implement these arguments to participate in the orchestrated dependency flow. |
| 4 | + |
| 5 | + |
| 6 | +# Dependency version input arguments |
| 7 | + |
| 8 | +## `-p:DotNetPackageVersionPropsPath=<path>` |
| 9 | +Directs the repo build to use a "package version props" file at `path`. The versions in the file must be used instead of any defaults the repo would ordinarily depend on. |
| 10 | + |
| 11 | +`path` is outside of the repository directory. |
| 12 | + |
| 13 | +### File format: package version props |
| 14 | +The file specifies one property for each package. The name is the package identity after being suffixed with `PackageVersion`, chars uppercased to get to PascalCase, and non-alphanumeric characters (assumed to be delimiters) removed. The property value is the full version of the package. Example with a few CoreCLR packages: |
| 15 | + |
| 16 | +```xml |
| 17 | +<?xml version="1.0" encoding="utf-8"?> |
| 18 | +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 19 | + <PropertyGroup> |
| 20 | + <MicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.1.0-preview2-25701-02</MicrosoftNETCoreRuntimeCoreCLRPackageVersion> |
| 21 | + <RuntimeOsxX64MicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.1.0-preview2-25701-02</RuntimeOsxX64MicrosoftNETCoreRuntimeCoreCLRPackageVersion> |
| 22 | + <TransportMicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.1.0-preview2-25701-02</TransportMicrosoftNETCoreRuntimeCoreCLRPackageVersion> |
| 23 | + </PropertyGroup> |
| 24 | +</Project> |
| 25 | +``` |
| 26 | + |
| 27 | +To collect package identities and versions for the package version props, the orchestrator reads the `nuspec` of every package on the blob feed in `packages/*.nupkg`. The file is placed in a directory on the build machine outside of the repo's git repository. |
| 28 | + |
| 29 | +### Recommended implementation |
| 30 | +Use the build dependency props format for all `PackageReference`s that may be satisfied by another repo that is being orchestrated: |
| 31 | + |
| 32 | +```xml |
| 33 | +<PackageReference Include="System.Collections.Immutable" |
| 34 | + Version="$(SystemCollectionsImmutablePackageVersion)" /> |
| 35 | +``` |
| 36 | + |
| 37 | +Store all defaults in a centralized `.props` file, and import `DotNetPackageVersionPropsPath` if specified to override the defaults: |
| 38 | + |
| 39 | +```xml |
| 40 | +<?xml version="1.0" encoding="utf-8"?> |
| 41 | +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 42 | + <PropertyGroup> |
| 43 | + <SystemCollectionsImmutablePackageVersion>1.5.0-preview1-25712-02</SystemCollectionsImmutablePackageVersion> |
| 44 | + <!-- ...All NuGet package dependency versions. ---> |
| 45 | + </PropertyGroup> |
| 46 | + |
| 47 | + <!-- Override isolated build dependency versions with product build's. --> |
| 48 | + <Import Project="$(DotNetPackageVersionPropsPath)" |
| 49 | + Condition="'$(DotNetPackageVersionPropsPath)' != ''" /> |
| 50 | +</Project> |
| 51 | +``` |
| 52 | + |
| 53 | +## `-p:DotNetSourceBuildTargetFrameworkPropsPath=<path>` |
| 54 | +**NOTE: This API may be simplified to use an argument instead of a file if only one TFM (target framework moniker) is required.** See [source-build#184](https://github.com/dotnet/source-build/issues/184). |
| 55 | + |
| 56 | +Directs the repo to use the "source build target framework props" file at `path`. The repo must use the version of each TFM listed in the file instead of any default. |
| 57 | + |
| 58 | +The TFMs must be used when source build wouldn't work with the repo's default values. If a product build is being orchestrated, for example, other TFMs are permitted and this property is not passed. |
| 59 | + |
| 60 | +### File format: restore target framework props |
| 61 | +Each TFM being built has a property specifying the name of that TFM as built in the current source build. Example: |
| 62 | + |
| 63 | +```xml |
| 64 | +<?xml version="1.0" encoding="utf-8"?> |
| 65 | +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 66 | + <PropertyGroup> |
| 67 | + <DotNetNETCoreAppTargetFramework>netcoreapp2.1</DotNetNETCoreAppTargetFramework> |
| 68 | + <DotNetNETStandardTargetFramework>netstandard2.1</DotNetNETStandardTargetFramework> |
| 69 | + </PropertyGroup> |
| 70 | +</Project> |
| 71 | +``` |
| 72 | + |
| 73 | +### Recommended implementation |
| 74 | +Import the "restore target framework props" file in a high-level MSBuild file in the repository, and set up an overridable property for each TFM the project uses. Use those properties in project files instead of hard-coded values. |
| 75 | + |
| 76 | + |
| 77 | +# Source override arguments |
| 78 | + |
| 79 | +## `-p:DotNetBuildOffline=<bool>` |
| 80 | +Directs the repo to skip online sources if `bool` is `true`. |
| 81 | + |
| 82 | +## `-p:DotNetRestoreSourcePropsPath=<path>` |
| 83 | +Directs the repo to use the semicolon-delimited sources in the `DotNetRestoreSources` property specified by the "restore source props" file at `path`. The sources should be the repo's highest priority NuGet package sources. |
| 84 | + |
| 85 | +Unless otherwise specified by `DotNetBuildOffline`, the repo may also use its default sources. |
| 86 | + |
| 87 | +### File format: restore source props |
| 88 | +An MSBuild file defining a single property `DotNetRestoreSources`. This file is necessary to avoid issues with escaping: there are various issues trying to pass `;` on the command line to delimit sources. Example: |
| 89 | + |
| 90 | +```xml |
| 91 | +<?xml version="1.0" encoding="utf-8"?> |
| 92 | +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 93 | + <PropertyGroup> |
| 94 | + <DotNetRestoreSources> |
| 95 | + /git/source-build/bin/obj/x64/Release/blob-feed/packages/; |
| 96 | + /git/source-build/bin/prebuilt/nuget-packages/; |
| 97 | + </DotNetRestoreSources> |
| 98 | + </PropertyGroup> |
| 99 | +</Project> |
| 100 | +``` |
| 101 | + |
| 102 | +### Recommended implementation |
| 103 | +Import `DotNetRestoreSourcePropsPath` as an MSBuild props file, and use properties similar to the following to define restore sources: |
| 104 | + |
| 105 | +```xml |
| 106 | +<Project> |
| 107 | + <Import Project="$(DotNetRestoreSourcePropsPath)" |
| 108 | + Condition="'$(DotNetRestoreSourcePropsPath)' != ''"/> |
| 109 | + |
| 110 | + <PropertyGroup> |
| 111 | + <RestoreSources>$(DotNetRestoreSources)</RestoreSources> |
| 112 | + <RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'"> |
| 113 | + $(RestoreSources); |
| 114 | + https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json; |
| 115 | + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; |
| 116 | + https://api.nuget.org/v3/index.json |
| 117 | + </RestoreSources> |
| 118 | + </PropertyGroup> |
| 119 | +</Project> |
| 120 | +``` |
| 121 | + |
| 122 | +If the repo doesn't use [NuGet MSBuild targets](https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets#restore-target) to restore, there's more work to use the `RestoreSources` property. For example, to pass `--source` args, `RestoreSources` can be `Include`d in an Item element to split it, then formatted. |
| 123 | + |
| 124 | +There is no known reasonable way to use NuGet.Config files, satisfy this API, *and* avoid duplicating the default source information. The recommendation is to not use NuGet.Config. |
| 125 | + |
| 126 | +## `-p:DotNetAssetRootUrl=<url>` |
| 127 | +Directs the repo to get binary assets from a given base `url`. For example, installers and lzma files. The scheme can be `http[s]` or `file`. The url ends with a `/`. |
| 128 | + |
| 129 | +### Conventions |
| 130 | +Repos must cooperate to establish conventions. Core-Setup needs to implement `DotNetOutputBlobFeedDir` in a way that allows CLI to find its binaries in `DotNetAssetRootUrl`. |
| 131 | + |
| 132 | +### Recommended implementation |
| 133 | +Use the AssetRoot properties if they are defined. Example (adapted from [CLI's build/BundledRuntimes.props](https://github.com/dotnet/cli/blob/4fe4c4d28a5171946311ca3ebf65af95180eb11f/build/BundledRuntimes.props)): |
| 134 | + |
| 135 | +```xml |
| 136 | +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 137 | + <PropertyGroup> |
| 138 | + <!-- SharedFrameworkVersion is defined elsewhere by a Core-Setup package version. --> |
| 139 | + <CombinedFrameworkHostCompressedFileName>dotnet-runtime-$(SharedFrameworkVersion)-$(SharedFrameworkRid)$(ArchiveExtension)</CombinedFrameworkHostCompressedFileName> |
| 140 | + </PropertyGroup> |
| 141 | + |
| 142 | + <PropertyGroup> |
| 143 | + <CoreSetupBlobRootUrl Condition="'$(DotNetAssetRootUrl)' != ''">$(DotNetAssetRootUrl)</CoreSetupBlobRootUrl> |
| 144 | + <CoreSetupBlobRootUrl Condition="'$(CoreSetupBlobRootUrl)' == ''">https://dotnetcli.azureedge.net/dotnet/</CoreSetupBlobRootUrl> |
| 145 | + |
| 146 | + <CoreSetupRootUrl>$(CoreSetupBlobRootUrl)Runtime/</CoreSetupRootUrl> |
| 147 | + |
| 148 | + <CoreSetupBlobAccessTokenParam Condition="'$(DotNetAssetRootAccessTokenSuffix)' != ''">$(DotNetAssetRootAccessTokenSuffix)</CoreSetupBlobAccessTokenParam> |
| 149 | + </PropertyGroup> |
| 150 | + |
| 151 | + <ItemGroup> |
| 152 | + <_DownloadAndExtractItem Include="CombinedSharedHostAndFrameworkArchive"> |
| 153 | + <Url>$(CoreSetupRootUrl)$(SharedFrameworkVersion)/$(CombinedFrameworkHostCompressedFileName)$(CoreSetupBlobAccessTokenParam)</Url> |
| 154 | + </_DownloadAndExtractItem> |
| 155 | + </ItemGroup> |
| 156 | +</Project> |
| 157 | +``` |
| 158 | + |
| 159 | +The above assumes that Core-Setup publishes outputs to `$(DotNetOutputBlobFeedDir)assets/Runtime/<SharedFrameworkVersion>/`. |
| 160 | + |
| 161 | +## `-p:DotNetAssetRootAccessTokenSuffix=<query string>` |
| 162 | +Directs the repo to append `query string` to any URL constructed using the `DotNetAssetRootUrl`. |
| 163 | + |
| 164 | +Recommended implementation is included in the `DotNetAssetRootUrl` section. |
| 165 | + |
| 166 | + |
| 167 | +# Output placement arguments |
| 168 | + |
| 169 | +## `-p:DotNetOutputBlobFeedDir=<target directory>` |
| 170 | +Directs the repo to place all outputs in the blob feed located at `target directory`, following blob feed structure. |
| 171 | + |
| 172 | +### Recommended implementation |
| 173 | +Place NuGet library packages (`*.nupkg`) directly in `$(DotNetOutputBlobFeedDir)packages/`. |
| 174 | + |
| 175 | +Place all other assets, such as installers, lzma files, and NuGet symbol packages (`*.symbols.nupkg`), in `$(DotNetOutputBlobFeedDir)assets/`. |
| 176 | + |
| 177 | +BuildTools can be configured to do this by setting the `PackageOutputPath` and `SymbolPackageOutputPath` MSBuild properties. |
0 commit comments