Skip to content

Commit 5266918

Browse files
authored
Use Roslyn to create ref/ assemblies (#23403)
* Remove all ref/ projects * Remove GenAPI infrastructure * Remove notion of a reference assembly project - remove `$(IsReferenceAssemblyProject)`, `$(ReferenceReferenceAssemblies)` and `$(ReferenceImplementationAssemblies)` - remove unnecessary `$(NoWarn)` settings nits: - remove a few misleading comments - wrap some long lines * Move .0 package version workaround into Versions.props - touch up SharedFramework.External.props * Expose `%(LatestPackageReference.RTMVersion)` metadata - automate use of properties in the `@(LatestPackageReference)` item group to make this maintainable - add a couple of special cases at the bottom of eng/Dependencies.props - add one more `$(...PackageVersion)` property to avoid yet-another special case * Enable Roslyn reference assemblies - exclude ref/ assembly from packages other than targeting pack - update Microsoft.AspNetCore.App.Ref.csproj - `%(IsReferenceAssembly)` and `%(ReferenceGrouping)` metadata no longer relevant - only ref/ assemblies are in `@(ReferencePathWithRefAssemblies)` item group nits: - remove now-unnecessary workaround - issues with TFM transition are behind us - clean up Microsoft.AspNetCore.App.Runtime.csproj slightly - use `GeneratePathProperty="true"` - reorder item / property settings for meta-expansion - correct spelling errors and phrasing in comments * Update documentation to reflect recent changes - remove CrossRepoBreakingChanges.md; was tied to old TeamCity infrastructure - also much less relevant given repo merges - adjust details and examples in ReferenceResolution.md - reflect repo merges, Dependencies.props changes, and current Maestro++ channels - add a few more details e.g. specific files where Version.Details.xml versions are used * !fixup! Remove another irrelevant doc file * !fixup! Address PR review suggestions - convert a couple of warnings to errors - use consistent casing for Microsoft.NETCore.App.Runtime.* packages - reduce `%(LatestPackageReference.Version)` metadata special cases - add and improve comments e.g. - improve comments about `$(*V0PackageVersion)` properties - improve placement of comments about item removal in ResolveReferences.targets - confirmed `$(*V0PackageVersion)` property list is complete nits: - fix solution example in ReferenceResolution.md - remove item group definition for `@(LatestPackageReference)` - remove `%(LatestPackageReference.VersionName)` metadata after use; large item group - similarly, remove `%(LatestPackageReference.RTMVersion)` when not needed; just complicates `Condition`s When I squash, I must remember this fixes - #14801 - dotnet/aspnetcore-internal#2693 * Actually use `%(LatestPackageReference.RTMVersion)` metadata - gather RTM package references in a new project - a (very) separate project to work around package conflict resolution - empty `Test` target works around Arcade's testing approach - new target in ResolveReferences.targets updates relevant assembly paths to use the RTM packages - done as soon as possible after `ResolvePackageAssets` determines the paths - done for all compilation inputs, not just ref/ assemblies
1 parent 59b94e4 commit 5266918

File tree

277 files changed

+533
-33376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+533
-33376
lines changed

Directory.Build.props

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
<PropertyGroup>
1212
<RepoRelativeProjectDir>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</RepoRelativeProjectDir>
1313

14-
<IsReferenceAssemblyProject>false</IsReferenceAssemblyProject>
15-
<IsReferenceAssemblyProject Condition="$(MSBuildProjectDirectory.EndsWith('ref'))">true</IsReferenceAssemblyProject>
16-
<OutDirName Condition="'$(IsReferenceAssemblyProject)' == 'true'">$(MSBuildProjectName)-ref</OutDirName>
17-
1814
<IsBenchmarkProject Condition="$(MSBuildProjectName.EndsWith('.Performance')) OR $(RepoRelativeProjectDir.Contains('perf')) OR $(RepoRelativeProjectDir.Contains('benchmarkapps'))">true</IsBenchmarkProject>
1915
<IsSpecificationTestProject Condition="$(MSBuildProjectName.EndsWith('.Specification.Tests'))">true</IsSpecificationTestProject>
2016
<IsUnitTestProject>false</IsUnitTestProject>
@@ -130,7 +126,7 @@
130126
<RuntimeInstallerBaseName>aspnetcore-runtime</RuntimeInstallerBaseName>
131127
<TargetingPackInstallerBaseName>aspnetcore-targeting-pack</TargetingPackInstallerBaseName>
132128

133-
<!-- Produce targeting pack installers/packages once per major.minor. -->
129+
<!-- This is used to produce targeting pack installers/packages once per major.minor. -->
134130
<IsTargetingPackBuilding Condition=" '$(DotNetBuildFromSource)' == 'true' ">false</IsTargetingPackBuilding>
135131
<IsTargetingPackBuilding
136132
Condition=" '$(IsTargetingPackBuilding)' == '' AND '$(AspNetCorePatchVersion)' != '0' ">false</IsTargetingPackBuilding>

Directory.Build.targets

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<Project>
1+
<Project>
22

33
<PropertyGroup>
44
<!-- Only build Microsoft.AspNetCore.App and ref/ assemblies in source build. -->
55
<!-- Analyzer package are needed in source build for WebSDK -->
66
<ExcludeFromSourceBuild
7-
Condition="'$(ExcludeFromSourceBuild)' == '' and '$(DotNetBuildFromSource)' == 'true' and '$(IsAspNetCoreApp)' != 'true' and '$(IsReferenceAssemblyProject)' != 'true' and '$(IsAnalyzersProject)' != 'true'">true</ExcludeFromSourceBuild>
7+
Condition="'$(ExcludeFromSourceBuild)' == '' and '$(DotNetBuildFromSource)' == 'true' and '$(IsAspNetCoreApp)' != 'true' and '$(IsAnalyzersProject)' != 'true'">true</ExcludeFromSourceBuild>
88

99
<!-- If the user has specified that they want to skip building any test related projects with SkipTestBuild,
1010
suppress all targets for TestProjects using ExcludeFromBuild. -->
@@ -57,7 +57,8 @@
5757

5858
<PropertyGroup Condition=" '$(MSBuildProjectExtension)' == '.csproj' ">
5959
<PackageId Condition=" '$(PackageId)' == '' ">$(AssemblyName)</PackageId>
60-
<IsPackable Condition="'$(IsPackable)' == '' AND ( '$(IsTestProject)' == 'true' OR '$(IsTestAssetProject)' == 'true' OR '$(IsBenchmarkProject)' == 'true' OR '$(IsSampleProject)' == 'true' OR '$(IsReferenceAssemblyProject)' == 'true' ) ">false</IsPackable>
60+
<IsPackable
61+
Condition="'$(IsPackable)' == '' AND ( '$(IsTestProject)' == 'true' OR '$(IsTestAssetProject)' == 'true' OR '$(IsBenchmarkProject)' == 'true' OR '$(IsSampleProject)' == 'true' ) ">false</IsPackable>
6162
</PropertyGroup>
6263

6364
<Import Project="eng\Baseline.Designer.props" />
@@ -100,14 +101,19 @@
100101

101102
<PropertyGroup>
102103
<!-- Implementation projects are the projects which produce nuget packages or shipping assemblies. -->
103-
<IsImplementationProject Condition=" '$(IsImplementationProject)' == '' AND '$(IsAnalyzersProject)' != 'true' AND '$(IsTestAssetProject)' != 'true' AND '$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true' AND '$(IsSampleProject)' != 'true' AND '$(IsReferenceAssemblyProject)' != 'true' ">true</IsImplementationProject>
104+
<IsImplementationProject Condition=" '$(IsImplementationProject)' == '' AND '$(IsAnalyzersProject)' != 'true' AND '$(IsTestAssetProject)' != 'true' AND '$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true' AND '$(IsSampleProject)' != 'true' ">true</IsImplementationProject>
104105

105106
<!-- This determines whether a project is available as a <Reference> to other projects in this repo. -->
106107
<IsProjectReferenceProvider Condition=" '$(IsProjectReferenceProvider)' == '' AND '$(IsImplementationProject)' == 'true' AND '$(PackAsTool)' != 'true' ">true</IsProjectReferenceProvider>
107108

108109
<HasReferenceAssembly
109-
Condition=" '$(HasReferenceAssembly)' == '' AND '$(IsProjectReferenceProvider)' == 'true' AND '$(IsAspNetCoreApp)' == 'true' ">true</HasReferenceAssembly>
110+
Condition=" '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' AND '$(IsAspNetCoreApp)' == 'true' ">true</HasReferenceAssembly>
110111
<HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == ''">false</HasReferenceAssembly>
112+
<ProduceReferenceAssembly>$(HasReferenceAssembly)</ProduceReferenceAssembly>
113+
114+
<!-- Duplicate setting from Microsoft.Common.CurrentVersion.targets because this is imported after that file. -->
115+
<TargetRefPath
116+
Condition=" '$(TargetRefPath)' == '' and $(ProduceReferenceAssembly) ">$([MSBuild]::NormalizePath($(TargetDir), 'ref', $(TargetFileName)))</TargetRefPath>
111117

112118
<IsPackable Condition="'$(IsPackable)' == '' AND ('$(IsImplementationProject)' == 'true' OR '$(IsAnalyzersProject)' == 'true') ">true</IsPackable>
113119
<IsPackable Condition="'$(IsPackable)' == '' ">false</IsPackable>
@@ -124,13 +130,7 @@
124130
<None Include="$(PackageThirdPartyNoticesFile)" Pack="true" PackagePath="." />
125131
</ItemGroup>
126132

127-
<ItemGroup Condition="'$(Language)' == 'C#' AND '$(IsReferenceAssemblyProject)' == 'true'">
128-
<Compile Include="$(SharedSourceRoot)ReferenceAssemblyInfo.cs" LinkBase="Properties" />
129-
</ItemGroup>
130-
131133
<PropertyGroup Condition="'$(Language)' == 'C#'">
132-
<!-- Reference assemblies should always use Major.Minor.0.0 for assembly versions even during servicing. Only the package version should be updated. -->
133-
<!-- Pinning the implementation assemblies at Major.Minor.0.0 as we figure out compiling against ref assemblies. -->
134134
<AssemblyVersion>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).0.0</AssemblyVersion>
135135
</PropertyGroup>
136136

@@ -180,7 +180,6 @@
180180
<Import Project="eng\targets\FSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
181181
<Import Project="eng\targets\Wix.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
182182
<Import Project="eng\targets\Npm.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
183-
<Import Project="eng\targets\ReferenceAssembly.targets" Condition=" $(HasReferenceAssembly) " />
184183
<Import Project="eng\targets\Helix.targets" Condition="'$(IsTestProject)' == 'true'" />
185184
<Import Project="eng\targets\FunctionalTestAsset.targets" Condition="'$(IsTestAssetProject)' == 'true'" />
186185
<Import Project="eng\targets\FunctionalTestWithAssets.targets" Condition="'$(ContainsFunctionalTestAssets)' == 'true'" />

docs/CrossRepoBreakingChanges.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/ReferenceAssemblies.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/ReferenceResolution.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ See [ResolveReferences.targets](/eng/targets/ResolveReferences.targets) for the
1010

1111
The requirements that led to this system are:
1212

13-
* Versions of external dependencies should be consistent.
14-
* Servicing updates of ASP.NET Core should minimize the number of assemblies which need to re-build and re-ship.
13+
* Versions of external dependencies should be consistent and easily discovered.
1514
* Newer versions of packages should not have lower dependency versions than previous releases.
1615
* Minimize the cascading effect of servicing updates where possible by keeping a consistent baseline of dependencies.
16+
* Servicing releases should not add or remove dependencies in existing packages.
17+
18+
As a minor point, the current system also makes our project files somewhat less verbose.
1719

1820
## Recommendations for writing a .csproj
1921

@@ -29,30 +31,31 @@ The requirements that led to this system are:
2931

3032
## Important files
3133

32-
* [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.
34+
* [eng/Baseline.xml](/eng/Baseline.xml) - this contains the 'baseline' of the latest servicing release for this branch.
35+
It should be modified and used to update the generated file, [eng/Baseline.Designer.props](eng/Baseline.Designer.props).
3336
* [eng/Dependencies.props](/eng/Dependencies.props) - contains a list of all package references that might be used in the repo.
3437
* [eng/ProjectReferences.props](/eng/ProjectReferences.props) - lists which assemblies or packages might be available to be referenced as a local project.
3538
* [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 build.
36-
* [eng/Version.Details.xml](/eng/Version.Details.xml) - used by automation to update dependencies variables in other files.
39+
* [eng/Version.Details.xml](/eng/Version.Details.xml) - used by automation to update dependency variables in
40+
[eng/Versions.props](/eng/Versions.props) and, for SDKs and `msbuild` toolsets, [global.json](global.json).
3741

3842
## Example: adding a new project
3943

4044
Steps for adding a new project to this repo.
4145

4246
1. Create the .csproj
4347
2. Run `eng/scripts/GenerateProjectList.ps1`
44-
3. Add it to Extensions.sln
48+
3. Add new project to AspNetCore.sln and any relevant `*.slnf` files
4549

4650
## Example: adding a new dependency
4751

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

5054
1. Add the package to the .csproj file using `<Reference Include="System.Banana" />`
51-
2. Add an entry to [eng/Dependencies.props](/eng/Dependencies.props), `<LatestPackageReference Include="System.Banana" Version="0.0.1-beta-1" />`
52-
3. If this package comes from another dotnet team and should be updated automatically by our bot...
53-
1. Change the LatestPackageReference entry to `Version="$(SystemBananaPackageVersion)"`.
54-
2. Add an entry to [eng/Versions.props](/eng/Versions.props) like this `<SystemBananaPackageVersion>0.0.1-beta-1</SystemBananaPackageVersion>`.
55-
3. Add an entry to [eng/Version.Details.xml](/eng/Version.Details.xml) like this:
55+
2. Add an entry to [eng/Dependencies.props](/eng/Dependencies.props) e.g. `<LatestPackageReference Include="System.Banana" />`
56+
3. If this package comes from another dotnet team and should be updated automatically by our bot&hellip;
57+
1. Add an entry to [eng/Versions.props](/eng/Versions.props) like this `<SystemBananaPackageVersion>0.0.1-beta-1</SystemBananaPackageVersion>`.
58+
2. Add an entry to [eng/Version.Details.xml](/eng/Version.Details.xml) like this:
5659

5760
```xml
5861
<ProductDependencies>
@@ -65,27 +68,28 @@ Steps for adding a new package dependency to an existing project. Let's say I'm
6568
</ProductDependencies>
6669
```
6770

68-
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`
69-
as its value is unimportant and will be updated the next time the bot runs.
71+
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
72+
placeholder for `Sha` as its value will be updated the next time the bot runs.
7073

71-
If the new dependency comes from dotnet/CoreFx, dotnet/code-setup or dotnet/extensions, add a
74+
If the new dependency comes from dotnet/runtime and you are updating dotnet/aspnetcore-tooling, add a
7275
`CoherentParentDependency` attribute to the `<Dependency>` element as shown below. This example indicates the
73-
dotnet/CoreFx dependency version should be determined based on the build that produced the chosen
74-
Microsoft.NETCore.App. That is, the dotnet/CoreFx dependency and Microsoft.NETCore.App should be
75-
coherent.
76+
dotnet/runtime dependency version for System.Banana should be determined based on the dotnet/aspnetcore build
77+
that produced the chosen Microsoft.CodeAnalysis.Razor. That is, the dotnet/runtime and dotnet/aspnetcore
78+
dependencies should be coherent.
7679

7780
```xml
78-
<Dependency Name="System.Banana" Version="0.0.1-beta-1" CoherentParentDependency="Microsoft.NETCore.App">
81+
<Dependency Name="System.Banana" Version="0.0.1-beta-1" CoherentParentDependency="Microsoft.CodeAnalysis.Razor">
7982
<!-- ... -->
8083
</Dependency>
8184
```
8285

83-
The attribute value should be `"Microsoft.Extensions.Logging"` for dotnet/core-setup dependencies and
84-
`"Microsoft.CodeAnalysis.Razor"` for dotnet/extensions dependencies.
86+
The attribute value should be `"Microsoft.CodeAnalysis.Razor"` for dotnet/runtime dependencies in
87+
dotnet/aspnetcore-tooling.
8588

8689
## Example: make a breaking change to references
8790

88-
If Microsoft.AspNetCore.Banana in 2.1 had a reference to `Microsoft.AspNetCore.Orange`, but in 3.0 this reference is changing to `Microsoft.AspNetCore.BetterThanOrange`, you would need to make these changes to the .csproj file
91+
If Microsoft.AspNetCore.Banana in 2.1 had a reference to `Microsoft.AspNetCore.Orange`, but in 3.1 or 5.0 this reference
92+
is changing to `Microsoft.AspNetCore.BetterThanOrange`, you would need to make these changes to the .csproj file
8993

9094
```diff
9195
<!-- in Microsoft.AspNetCore.Banana.csproj -->
@@ -100,8 +104,12 @@ If Microsoft.AspNetCore.Banana in 2.1 had a reference to `Microsoft.AspNetCore.O
100104

101105
If the `dotnet-maestro` bot has not correctly updated the dependencies, it may be worthwhile running `darc` manually:
102106

103-
1. Install `darc` as described in https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md#setting-up-your-darc-client
104-
2. Run `darc update-dependencies --channel '.NET Core 3 Dev'`
105-
* Use `'.NET Core 3 Release'` in a `release/3.0-*` branch
107+
1. Install `darc` as described in <https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md#setting-up-your-darc-client>
108+
2. Run `darc update-dependencies --channel '.NET Core 3.1 Release'`
109+
* Use `'trigger-subscriptions'` to prod the bot to create a PR if you do not want to make local changes
110+
* Use `'.NET 3 Eng''` to update dependencies from dotnet/arcade
111+
* Use `'.NET Eng - Latest'` to update dependencies from dotnet/arcade in the `master` branch
112+
* Use `'VS Master'` to update dependencies from dotnet/roslyn in the `master` branch
113+
* Use `'.NET 5 Dev'` to update dependencies from dotnet/efcore or dotnet/runtime in the `master` branch
106114
3. `git diff` to confirm the tool's changes
107115
4. Proceed with usual commit and PR

0 commit comments

Comments
 (0)