Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Roslyn to create ref/ assemblies #23403

Merged
merged 10 commits into from
Jul 17, 2020

Conversation

dougbu
Copy link
Member

@dougbu dougbu commented Jun 26, 2020

Suggest reviewing the commits individually and mostly ignoring the first ("Remove all ref/ projects").

This set of changes

  • reduces the complexity of our build, mostly because it removes all ref/ projects
  • avoids any need for manual changes when APIs change
  • increases the targeting pack size slightly e.g. Microsoft.AspNetCore.App.Ref.*.nupkg was about 1.5 MB before this change and 2 MB after
    • most of this comes from including more information in the assemblies e.g. internal symbols when IVT is used
  • makes it difficult to display public API changes -- until we decide on the baselines to compare against and implement that comparison

@Tratcher
Copy link
Member

@dougbu you are my new favorite person 😁.

Can /docs/ReferenceAssemblies.md be removed?

Fixes https://github.com/dotnet/aspnetcore-internal/issues/2693

@dougbu
Copy link
Member Author

dougbu commented Jun 27, 2020

Can /docs/ReferenceAssemblies.md be removed?

Yes 😺

Directory.Build.props Outdated Show resolved Hide resolved
@wtgodbe
Copy link
Member

wtgodbe commented Jun 29, 2020

I must have missed it - where/how do we actually hook in to the roslyn ref project generation?

@dougbu
Copy link
Member Author

dougbu commented Jun 29, 2020

where/how do we actually hook in to the roslyn ref project generation?

It's a single property setting here.

@Pilchie Pilchie added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Jun 29, 2020
eng/targets/ResolveReferences.targets Outdated Show resolved Hide resolved
eng/targets/ResolveReferences.targets Outdated Show resolved Hide resolved
eng/Versions.props Show resolved Hide resolved
Copy link
Member

@wtgodbe wtgodbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good except for the question about building against old refs & running against new impl's - will approve once that's resolved

@dougbu dougbu force-pushed the dougbu/roslyn.ref.assemblies.14801 branch from 0c97680 to ecf8a2b Compare July 10, 2020 06:04
@dougbu dougbu requested review from javiercn and a team as code owners July 10, 2020 06:04
@dougbu dougbu force-pushed the dougbu/roslyn.ref.assemblies.14801 branch from ecf8a2b to 59a80f6 Compare July 10, 2020 21:39
@dougbu dougbu force-pushed the dougbu/roslyn.ref.assemblies.14801 branch from e991ff1 to de37e9c Compare July 15, 2020 19:36
@ericstj
Copy link
Member

ericstj commented Jul 15, 2020

increases the targeting pack size slightly

One idea we had in dotnet/runtime was to use the ILLinker to trim the resulting reference assemblies that are shipped in the ref pack. We already do this for our runtime assemblies, doing so for ref might be a good use of linker. The settings we use with it to root public API and trim unreachable code are here: https://github.com/dotnet/runtime/blob/69b0d160953f5c920e52f021366743623693c158/eng/illink.targets#L192

@dougbu
Copy link
Member Author

dougbu commented Jul 15, 2020

One idea we had in dotnet/runtime was to use the ILLinker to trim the resulting reference assemblies that are shipped in the ref pack.

That sounds like fun 😺 but I'm not that sure the small size bump merits the extra work. My latest build produced a 2.02 MB Microsoft.AspNetCore.App.Ref.5.0.0-ci.nupkg while the one from the most recent rolling build of master was 1.74 MB. Thoughts @Pilchie

@Pilchie
Copy link
Member

Pilchie commented Jul 15, 2020

I suspect it might be a fair bit of work, given that our reference assemblies need to have some internals so that test assemblies can be built that have InternalsVisibleTo. It seems like a significant thing to manage for a negligible benefit.

Copy link
Member Author

@dougbu dougbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆗 I declare this PR working.

The https://dev.azure.com/dnceng/public/_build/results?buildId=731663 build might still time out (unrelated to my changes) but otherwise did all the Right Thing:tm:s Have confirmed the downlevel assemblies landed in Microsoft.AspNetCore.App.Ref.5.0.0-ci.nupkg and shipped assemblies all built against what they should have e.g. Microsoft.AspNetCore.Http.Features.dll references the expected (older) ref/ assembly for System.IO.Pipelines.

System.Collections, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.ComponentModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.IO.Pipelines, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Net.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

I'll clean up the commits and remove the "test only" parts in preparation for a final review. In the meantime, I would appreciate comments on below !!! bit since I'd rather not check that question in 😈

eng/targets/ResolveReferences.targets Outdated Show resolved Hide resolved
@dougbu
Copy link
Member Author

dougbu commented Jul 16, 2020

@Pilchie

I suspect it might be a fair bit of work

Maybe not quite as much as you suspect. My objection was based on the size of the target @ericstj pointed us to and the potential build perf degradation due to a lot of <Exec> invocations. If we did anything, it would be in the Microsoft.AspNetCore.App.Ref project and should not affect anything else building in this repo.

@ericstj
Copy link
Member

ericstj commented Jul 16, 2020

Fair enough. FWIW we saw a lot larger size differences when we were looking at roslyn's references. For example, I spot checked System.Text.Json right now and our ref is 25KB vs Roslyn's which is 75KB. The nice thing about the linker is that it can solve the internals problem for you. IIRC we were trying idefs and this was hard because the compiler needs legit syntax, whereas with the linker you can root just the internals you need and it will walk the type graph.

@jaredpar
Copy link
Member

FWIW we saw a lot larger size differences when we were looking at roslyn's references. For example, I spot checked System.Text.Json right now and our ref is 25KB vs Roslyn's which is 75KB

This is to some degree expected. The reference assemblies generated by the runtime team are omitting members. This can be done in runtime because they have a good grasp of their specific domain and can safely omit some types / members. Though this has bit them before and ended up causing real world customer issues (the stripping of struct fields that were private as an example).

The general compiler feature though must produce reference assemblies that are correct in any customer domain. That means we'll generally include more data because it's a superset of what runtime would produce.

dougbu added 10 commits July 16, 2020 21:53
- remove `$(IsReferenceAssemblyProject)`, `$(ReferenceReferenceAssemblies)` and `$(ReferenceImplementationAssemblies)`
    - remove unnecessary `$(NoWarn)` settings

nits:
- remove a few misleading comments
- wrap some long lines
- touch up SharedFramework.External.props
- 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
- 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
- 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
- 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
- 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
@dougbu dougbu force-pushed the dougbu/roslyn.ref.assemblies.14801 branch from d3c005a to 7ebf486 Compare July 17, 2020 05:00
@dougbu dougbu changed the base branch from master to release/5.0-preview8 July 17, 2020 05:02
@dougbu
Copy link
Member Author

dougbu commented Jul 17, 2020

🆙📅 to consolidate changes since @wtgodbe and @JunTaoLuo reviewed (equivalent of c65704f) into two commits, remove the test-only bits, and rebase on preview8 branch. Please review or re-review in case there's anything I missed.

@Pilchie we didn't chat about this but I chose to label this a tell-mode change. LMK if that's not right.

@dougbu dougbu added the tell-mode Indicates a PR which is being merged during tell-mode label Jul 17, 2020
@dougbu dougbu added this to the 5.0.0-preview8 milestone Jul 17, 2020
@dougbu
Copy link
Member Author

dougbu commented Jul 17, 2020

The shift-click menu doesn't always work. The URI for the last 9 commits (all but removing the ref/ projects) is https://github.com/dotnet/aspnetcore/pull/23403/files/32dd707601f5b832060e8bbe49be5197c844545f..7ebf486c9a29c462ad8956d117b224c231111d53 at the moment.

in all servicing builds. Cannot reference two versions of a package, mandating this separate package.
-->
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't be parameterized?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not unless I remove the Directory.Build.* files. I'll test out whether that causes any problems after getting this in and doing the merge to 'master'. It's no worse at the moment than the hard-coded TFMs in (say) our project templates. But, I'll clean it up next if possible.

@Pilchie
Copy link
Member

Pilchie commented Jul 17, 2020

I think tell mode is fine - I'll explicitly mention it in tactics, since it is a pretty significant change.

@dougbu dougbu merged commit 5266918 into release/5.0-preview8 Jul 17, 2020
@dougbu dougbu deleted the dougbu/roslyn.ref.assemblies.14801 branch July 17, 2020 20:35
@Pilchie
Copy link
Member

Pilchie commented Jul 17, 2020

Yipee!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework tell-mode Indicates a PR which is being merged during tell-mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants