From 96ea32666448a054f70305b8b6cf1a7cd4821c5e Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 13 Dec 2018 14:35:02 -0800 Subject: [PATCH] Document custom reference resolution (#4806) --- build/repo.targets | 6 +++- docs/README.md | 5 ++++ docs/ReferenceResolution.md | 34 +++++++++++++++++++++++ eng/Baseline.xml | 6 ++++ eng/Dependencies.props | 28 +++++++++++-------- eng/PatchConfig.props | 10 +++++++ eng/ProjectReferences.props | 6 +++- eng/Versions.props | 8 ++++++ eng/targets/CSharp.Common.props | 9 ++++++ eng/targets/ResolveReferences.targets | 40 ++++++++++++++++++++++++--- 10 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 docs/README.md create mode 100644 docs/ReferenceResolution.md create mode 100644 eng/Versions.props diff --git a/build/repo.targets b/build/repo.targets index 1bb8d78971f..59785014b5b 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -60,7 +60,11 @@ $(MSBuildThisFileDirectory)..\eng\ProjectReferences.props + @(_ProjectReferenceProvider->'', '%0A ') diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000000..98fe46e4032 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,5 @@ +Contributor documentation +========================= + +The primary audience for documentation in this folder is contributors to ASP.NET Core. +If you are looking for documentation on to *use* ASP.NET Core, go to . diff --git a/docs/ReferenceResolution.md b/docs/ReferenceResolution.md new file mode 100644 index 00000000000..e0c3dbf6f4d --- /dev/null +++ b/docs/ReferenceResolution.md @@ -0,0 +1,34 @@ +`` resolution +======================== + +Most project files in this repo should use `` instead of `` or ``. +This was done to enable ASP.NET Core's unique requirements without requiring most ASP.NET Core contributors +to understand the complex rules for how versions and references should work. The build system will resolve +Reference items to the correct type and version of references based on our servicing and update rules. + +See [ResolveReferences.targets](/eng/targets/ResolveReferences.targets) for the exact implementation of custom +`` resolutions. + +The requirements that led to this system are: + +* Versions of external dependencies should be consistent. +* Servicing updates of ASP.NET Core should minimize the number of assemblies which need to re-build and re-ship. +* Newer versions of packages should not have lower dependency versions than previous releases. +* Minimize the cascading effect of servicing updates where possible by keeping a consistent baseline of dependencies. + +## Recommendations for writing a .csproj + +* Use `` +* Do not use `` +* Only use `` in test projects +* Name the .csproj file to match the assembly name. +* Run `build.cmd /t:GenerateProjectList` when adding new projects +* Use [eng/tools/BaseLineGenerator/](/eng/tools/BaselineGenerator/README.md) if you need to update baselines. + +## Important files + +* [eng/Baseline.xml](/eng/Baseline.xml) - this contains the 'baseline' of the latest servicing release for this branch. It should be modified and used to update the generated file, Baseline.Designer.props. +* [eng/Dependencies.props](/eng/Dependencies.props) - contains a list of all package references that might be used in the repo. +* [eng/PatchConfig.props](/eng/PatchConfig.props) - lists which assemblies or packages are patching in the current build. +* [eng/ProjectReferences.props](/eng/ProjectReferences.props) - lists which assemblies or packages might be available to be referenced as a local project +* [eng/Versions.props](/eng/Versions.props) - contains a list of versions which may be updated by automation. diff --git a/eng/Baseline.xml b/eng/Baseline.xml index 070816457bb..e27da11e3a6 100644 --- a/eng/Baseline.xml +++ b/eng/Baseline.xml @@ -1,3 +1,9 @@ + diff --git a/eng/Dependencies.props b/eng/Dependencies.props index b7b342f0e71..7b1eba3c54a 100644 --- a/eng/Dependencies.props +++ b/eng/Dependencies.props @@ -1,14 +1,29 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + + + + + + + + - @@ -82,13 +97,4 @@ - - - - - - - - - diff --git a/eng/PatchConfig.props b/eng/PatchConfig.props index 91e93a17fe7..2fd81f182e3 100644 --- a/eng/PatchConfig.props +++ b/eng/PatchConfig.props @@ -1,3 +1,13 @@ + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) diff --git a/eng/ProjectReferences.props b/eng/ProjectReferences.props index ea6ac86aac4..2b71425adf5 100644 --- a/eng/ProjectReferences.props +++ b/eng/ProjectReferences.props @@ -1,4 +1,8 @@ - + diff --git a/eng/Versions.props b/eng/Versions.props new file mode 100644 index 00000000000..8adc6dcbbd9 --- /dev/null +++ b/eng/Versions.props @@ -0,0 +1,8 @@ + + diff --git a/eng/targets/CSharp.Common.props b/eng/targets/CSharp.Common.props index b3fc97e2d9b..6769d7508f6 100644 --- a/eng/targets/CSharp.Common.props +++ b/eng/targets/CSharp.Common.props @@ -11,4 +11,13 @@ + + + + + + + + + diff --git a/eng/targets/ResolveReferences.targets b/eng/targets/ResolveReferences.targets index 7ff54b7d33b..3c55bf6f8f6 100644 --- a/eng/targets/ResolveReferences.targets +++ b/eng/targets/ResolveReferences.targets @@ -1,3 +1,21 @@ + @@ -31,16 +49,22 @@ + <_ImplicitPackageReference Include="@(PackageReference->WithMetadataValue('IsImplicitlyDefined', 'true'))" /> + <_ExplicitPackageReference Include="@(PackageReference)" Exclude="@(_ImplicitPackageReference)" /> + <_ExplicitPackageReference Remove="Internal.AspNetCore.Sdk" /> - + <_UnusedProjectReferenceProvider Include="@(ProjectReferenceProvider)" Exclude="@(Reference)" /> - + <_ProjectReferenceByAssemblyName Condition="'$(UseProjectReferences)' == 'true'" Include="@(ProjectReferenceProvider)" - Exclude="@(UnusedProjectReferenceProvider)" /> + Exclude="@(_UnusedProjectReferenceProvider)" /> @@ -51,12 +75,18 @@ + <_ReferenceTemp Remove="@(_ReferenceTemp)" /> + + @@ -117,6 +148,7 @@ Text="Could not resolve this reference. Could not locate the package or project for "%(Reference.Identity)"" /> + <_TargetFramework Remove="@(_TargetFramework)" />