Skip to content

Commit

Permalink
Add code check CI tests, add docs about ReferenceResolution, and othe…
Browse files Browse the repository at this point in the history
…r cleanups (#1044)

Changes:
* Add a step which checks that generated code is up to date
* Copy over the documentation on how to work with `<reference>` 
* Fixup a broken reference in the .sln
* Fix the casing on Microsoft.Extensions.ValueStopwatch.Sources
* Remove some unused references and variables
  • Loading branch information
natemcmaster committed Feb 1, 2019
1 parent e2bb8ac commit 92acd8b
Show file tree
Hide file tree
Showing 39 changed files with 315 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ BenchmarkDotNet.Artifacts/
*.binlog
dist/
.dotnet/
.packages/
2 changes: 2 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<PropertyGroup>
<!-- Implementation projects are the projects which produce nuget packages or shipping assemblies. -->
<IsImplementationProject Condition=" '$(IsImplementationProject)' == '' AND '$(IsTestAssetProject)' != 'true' AND '$(IsUnitTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true' AND '$(IsSampleProject)' != 'true' ">true</IsImplementationProject>
<!-- This determines whether a project is available as a <Reference> to other projects in this repo. -->
<IsProjectReferenceProvider Condition=" '$(IsProjectReferenceProvider)' == '' AND '$(IsImplementationProject)' == 'true' AND '$(PackAsTool)' != 'true' ">true</IsProjectReferenceProvider>
</PropertyGroup>

<Import Project="eng\targets\Packaging.targets" Condition=" '$(MSBuildProjectExtension)' == '.csproj' " />
Expand Down
31 changes: 16 additions & 15 deletions Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{36617B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Sources.Tests", "src\Shared\test\Microsoft.Extensions.Sources.Tests.csproj", "{33E57F0C-3CDB-4EB8-B6BE-6A0875B42EDE}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.Extensions.CommandLineUtils.Sources", "src\Shared\src\CommandLineUtils\Microsoft.Extensions.CommandLineUtils.Sources.shproj", "{00947D4A-C20E-46E3-90C3-6CD6BC87EE72}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestingUtils", "TestingUtils", "{3DBE2341-7244-4095-A60C-A0AF7E187C9B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Internal.AspNetCore.Analyzers", "src\TestingUtils\Internal.AspNetCore.Analyzers\src\Internal.AspNetCore.Analyzers.csproj", "{62EF7870-CA1F-4815-BC80-8477D358A16C}"
Expand Down Expand Up @@ -135,7 +133,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{D635
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Configuration.FunctionalTests", "src\Configuration\test\Config.FunctionalTests\Microsoft.Extensions.Configuration.FunctionalTests.csproj", "{7177967D-BB49-46AC-80D0-BE64F07E8720}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Configuration.Test.Common", "src\Configuration\test\Config.Test.Common\Microsoft.Extensions.Configuration.Test.Common.csproj", "{3BE0F4BB-502A-4AA6-895D-19BB3D01861B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Configuration.Test.Common", "src\Configuration\testassets\Test.Common\Microsoft.Extensions.Configuration.Test.Common.csproj", "{3BE0F4BB-502A-4AA6-895D-19BB3D01861B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Options", "Options", "{D0CCC990-FBC0-49D1-8221-1CDCAE84EC8A}"
EndProject
Expand Down Expand Up @@ -283,7 +281,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateWebHostBuilderInvalid
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateWebHostBuilderPatternTestSite", "src\Shared\testassets\CreateWebHostBuilderPatternTestSite\CreateWebHostBuilderPatternTestSite.csproj", "{45512470-32BC-4AAF-BBF2-4457F03319E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MockHostTypes", "src\Shared\testassets\MockHostTypes\MockHostTypes.csproj", "{71F6D695-8165-4654-BE94-DA8DC0799F8E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MockHostTypes", "src\Shared\testassets\MockHostTypes\MockHostTypes.csproj", "{71F6D695-8165-4654-BE94-DA8DC0799F8E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "JSInterop", "JSInterop", "{6A293FDC-A13B-4137-87F9-C9225CF3542B}"
EndProject
Expand All @@ -294,12 +292,14 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.JSInterop.JS", "src\JSInterop\Microsoft.JSInterop.JS\src\Microsoft.JSInterop.JS.csproj", "{76258B76-8CDD-471A-9D43-0815B712D668}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.WebAssembly.Interop", "src\JSInterop\Mono.WebAssembly.Interop\src\Mono.WebAssembly.Interop.csproj", "{89B01C5B-42DF-4E99-847E-354B8C5FBA6F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaselineGenerator", "eng\tools\BaselineGenerator\BaselineGenerator.csproj", "{DE47CB52-3E6F-4A6A-910E-AE118A00CE1A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{B0D89499-D1FA-4113-88C7-B82AB1D98EB6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets", "{15AC3300-D335-4C5C-9E3A-22F26904AB26}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Shared\src\CommandLineUtils\Microsoft.Extensions.CommandLineUtils.Sources.projitems*{00947d4a-c20e-46e3-90c3-6cd6bc87ee72}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -1799,7 +1799,6 @@ Global
{4D8EC9A1-4854-4A88-8FE2-0B62C67110CB} = {B938B88D-2FD2-445F-B194-DEB3FF405ACF}
{9D2408A7-F77B-4D79-8FE3-5A9B67DF5AD3} = {B938B88D-2FD2-445F-B194-DEB3FF405ACF}
{33E57F0C-3CDB-4EB8-B6BE-6A0875B42EDE} = {36617B81-CF74-4FCB-A7CA-E95DF3CA92FC}
{00947D4A-C20E-46E3-90C3-6CD6BC87EE72} = {36617B81-CF74-4FCB-A7CA-E95DF3CA92FC}
{62EF7870-CA1F-4815-BC80-8477D358A16C} = {3DBE2341-7244-4095-A60C-A0AF7E187C9B}
{9D0EDBEC-22F9-4C3C-9349-B5888F709B6A} = {3DBE2341-7244-4095-A60C-A0AF7E187C9B}
{1C16FAC7-9658-4E51-BFB0-0C0370851682} = {3DBE2341-7244-4095-A60C-A0AF7E187C9B}
Expand Down Expand Up @@ -1907,17 +1906,19 @@ Global
{AC33A64E-1261-47E7-8676-69C48E4B0266} = {2FAC6FF0-1FB6-41C6-9A36-FFC2E1727783}
{66DA86CB-E1DD-4A3A-8855-AD37731F112E} = {2FAC6FF0-1FB6-41C6-9A36-FFC2E1727783}
{9FE05F36-5626-416D-956D-5C4C6D7E3E1B} = {2FAC6FF0-1FB6-41C6-9A36-FFC2E1727783}
{A73FD5A1-DA46-432A-9824-BA5FC56C2D3D} = {2C7E2059-8542-4BC8-A170-39F6B9EDE548}
{46EE8C21-DC4A-4BD6-B4D6-1919EA720396} = {2C7E2059-8542-4BC8-A170-39F6B9EDE548}
{BAF702CC-5BD2-4CD1-A16D-B899AA86B6AA} = {2C7E2059-8542-4BC8-A170-39F6B9EDE548}
{7BA970A0-FDEC-44C7-AB6E-3C1A0F22BA5C} = {2C7E2059-8542-4BC8-A170-39F6B9EDE548}
{8B5184A7-74FC-4966-B68D-ABF65474B355} = {2C7E2059-8542-4BC8-A170-39F6B9EDE548}
{45512470-32BC-4AAF-BBF2-4457F03319E2} = {2C7E2059-8542-4BC8-A170-39F6B9EDE548}
{71F6D695-8165-4654-BE94-DA8DC0799F8E} = {2C7E2059-8542-4BC8-A170-39F6B9EDE548}
{A73FD5A1-DA46-432A-9824-BA5FC56C2D3D} = {15AC3300-D335-4C5C-9E3A-22F26904AB26}
{46EE8C21-DC4A-4BD6-B4D6-1919EA720396} = {15AC3300-D335-4C5C-9E3A-22F26904AB26}
{BAF702CC-5BD2-4CD1-A16D-B899AA86B6AA} = {15AC3300-D335-4C5C-9E3A-22F26904AB26}
{7BA970A0-FDEC-44C7-AB6E-3C1A0F22BA5C} = {15AC3300-D335-4C5C-9E3A-22F26904AB26}
{8B5184A7-74FC-4966-B68D-ABF65474B355} = {15AC3300-D335-4C5C-9E3A-22F26904AB26}
{45512470-32BC-4AAF-BBF2-4457F03319E2} = {15AC3300-D335-4C5C-9E3A-22F26904AB26}
{71F6D695-8165-4654-BE94-DA8DC0799F8E} = {15AC3300-D335-4C5C-9E3A-22F26904AB26}
{6D3807BD-28A8-4B7C-92D2-8A72E1522398} = {6A293FDC-A13B-4137-87F9-C9225CF3542B}
{FD4896CE-E3FB-458E-8581-7552347C4260} = {6A293FDC-A13B-4137-87F9-C9225CF3542B}
{76258B76-8CDD-471A-9D43-0815B712D668} = {6A293FDC-A13B-4137-87F9-C9225CF3542B}
{89B01C5B-42DF-4E99-847E-354B8C5FBA6F} = {6A293FDC-A13B-4137-87F9-C9225CF3542B}
{DE47CB52-3E6F-4A6A-910E-AE118A00CE1A} = {B0D89499-D1FA-4113-88C7-B82AB1D98EB6}
{15AC3300-D335-4C5C-9E3A-22F26904AB26} = {36617B81-CF74-4FCB-A7CA-E95DF3CA92FC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {814BFC88-0867-451F-AC8F-20FE107809B4}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Microsoft.Extensions APIs can then be added to the project using the [NuGet Pack
Some of the best ways to contribute are to try things out, file issues, join in design conversations,
and make pull-requests.

* [Download our latest daily builds](./docs/daily-builds.md)
* [Build .NET Extensions from source code](./docs/build-from-source.md)
* [Download our latest daily builds](./docs/DailyBuilds.md)
* [Build .NET Extensions from source code](./docs/BuildFromSource.md)
* Check out the [contributing](CONTRIBUTING.md) page to see the best places to log issues and start discussions.

## Reporting security issues and bugs
Expand Down
19 changes: 16 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ variables:

# CI and PR triggers
trigger:
- master
- release/*
- internal/release/*
batch: true
branches:
include:
- master
- release/*
- internal/release/*

pr:
autoCancel: false
Expand All @@ -15,6 +18,16 @@ pr:
- '*'

jobs:
- job: Code_check
displayName: Code check
workspace:
clean: all
pool:
vmImage: vs2017-win2016
steps:
- powershell: ./eng/scripts/CodeCheck.ps1 -ci
displayName: Run eng/scripts/CodeCheck.ps1

- template: /eng/common/templates/jobs/jobs.yml
parameters:
enableMicrobuild: true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
71 changes: 71 additions & 0 deletions docs/ReferenceResolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
`<Reference>` resolution
========================

Most project files in this repo should use `<Reference>` instead of `<ProjectReference>` or `<PackageReference>`.
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
`<Reference>` resolutions.

The requirements that led to this system are:

* Versions of external dependencies should be consistent.
* Servicing updates 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 `<Reference>`.
* Do not use `<PackageReference>`.
* If you need to use a new package, add it to `eng/Dependencies.props` and `eng/Versions.props`.
* If you the package comes from a partner team and needs to have versions automatically updated, also add an entry `eng/Version.Details.xml`.
* Only use `<ProjectReference>` in test projects.
* Name the .csproj file to match the assembly name.
* Run `eng/scripts/GenerateProjectList.ps1` 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. This is used by MSBuild to restore and buid.
* [eng/Version.Details.xml](/eng/Version.Details.xml) - used by automation to update dependencies variables in other files.

## Example: adding a new project

Steps for adding a new project to this repo.

1. Create the .csproj
2. Run `eng/scripts/GenerateProjectList.ps1`
3. Add it to Extensions.sln

## Example: adding a new dependency

Steps for adding a new package dependency to an existing project. Let's say I'm adding a dependency on System.Banana.

1. Add the package to the .csproj file using `<Reference Include="System.Banana" />`
2. Add an entry to [eng/Dependencies.props](/eng/Dependencies.props), `<LatestPackageReference Include="System.Banana" Version="0.0.1-beta-1" />`
3. If this package comes from another dotnet team and should be updated automatically by our bot...
1. Change the LatestPackageReference entry to `Version="$(SystemBananaPackageVersion)"`.
2. Add an entry to [eng/Versions.props](/eng/Versions.props) like this `<SystemBananaPackageVersion>0.0.1-beta-1</SystemBananaPackageVersion>`.
3. Add an entry to [eng/Version.Details.xml](/eng/Version.Details.xml) like this:

```xml
<ProductDependencies>
<!-- ... -->
</Dependency>
<Dependency Name="System.Banana" Version="0.0.1-beta-1">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>000000</Sha>
</Dependency>
<!-- ... -->
</ProductDependencies>
```

If you don't know the commit hash of the source code used to produce "0.0.1-beta-1", you can use `000000` as a placeholder for `Sha`
as its value is unimportant and will be updated the next time the bot runs.
6 changes: 6 additions & 0 deletions eng/Baseline.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
This file contains a list of all the packages and their versions which were released in the last servicing
build of Extensions. Update this list when preparing for a new patch.
-->
<Baseline Version="2.2.1">
<Package Id="Microsoft.Extensions.Caching.Abstractions" Version="2.2.0" />
<Package Id="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
Expand Down
16 changes: 14 additions & 2 deletions eng/Dependencies.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
<!--
This file contains a list of all the external dependencies used in ASP.NET Core. These dependencies
are expressed as `<LatestPackageReference>`. These are used as inputs reference resolution, and
may be turned into `<PackageReference>` items in projects.
`<BaselinePackageReference>` items should not be in this file. Those items appear in Baseline.Designer.props
and are generated based on the last package release.
-->
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>

<ItemDefinitionGroup>
<LatestPackageReference>
<!-- Required. Expected to be an exact package version. Wildcards are not allowed. -->
<Version></Version>
</LatestPackageReference>
</ItemDefinitionGroup>

<ItemGroup Label=".NET Core dependencies">
<LatestPackageReference Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryPackageVersion)" />
<LatestPackageReference Include="System.ComponentModel.Annotations" Version="$(SystemComponentModelAnnotationsPackageVersion)" />
Expand All @@ -23,7 +37,6 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' != '.NETFramework' " Label="MSBuild">
<LatestPackageReference Include="Microsoft.Build" Version="15.8.166" />
<LatestPackageReference Include="Microsoft.Build.Framework" Version="15.8.166" />
<LatestPackageReference Include="Microsoft.Build.Tasks.Core" Version="15.8.166" />
<LatestPackageReference Include="Microsoft.Build.Utilities.Core" Version="15.8.166" />
Expand All @@ -46,7 +59,6 @@
<LatestPackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.8.0" />
<LatestPackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
<LatestPackageReference Include="Microsoft.TypeScript.MSBuild" Version="2.9.2" />
<LatestPackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<LatestPackageReference Include="Moq" Version="4.10.0" />
<LatestPackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<LatestPackageReference Include="Polly.Extensions.Http" Version="2.0.1" />
Expand Down
10 changes: 10 additions & 0 deletions eng/PatchConfig.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<!--
This file contains a list of the package IDs which are patching in a given release.
CAUTION: due to limitations in MSBuild, the format of the PackagesInPatch property is picky.
When adding a new package, make sure the new line ends with a semicolon and starts with a space.
Later on, this will be checked using this condition:
<IsPackageInThisPatch>$(PackagesInPatch.Contains(' $(PackageId);'))</IsPackageInThisPatch>
-->
<Project>

<PropertyGroup Condition=" '$(VersionPrefix)' == '2.2.1' ">
Expand Down
Loading

0 comments on commit 92acd8b

Please sign in to comment.