Skip to content

Use ProjectReference to build against System.Private.CoreLib#38196

Merged
ViktorHofer merged 3 commits intodotnet:masterfrom
ViktorHofer:UseCoreLibP2P
Jun 22, 2020
Merged

Use ProjectReference to build against System.Private.CoreLib#38196
ViktorHofer merged 3 commits intodotnet:masterfrom
ViktorHofer:UseCoreLibP2P

Conversation

@ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Jun 20, 2020

Fixes #36464
Fixes #37963

Validated System.Private.CoreLib's ability to build incrementally (fast).

@ghost
Copy link

ghost commented Jun 20, 2020

Tagging subscribers to this area: @safern, @ViktorHofer
Notify danmosemsft if you want to be subscribed.

@ViktorHofer
Copy link
Member Author

/azp run runtime

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ViktorHofer ViktorHofer merged commit dd41a4a into dotnet:master Jun 22, 2020
@ViktorHofer ViktorHofer deleted the UseCoreLibP2P branch June 22, 2020 17:53
Exclude="$(RuntimePath)$(MSBuildProjectName).dll" />
<ReferencePath Include="$(RuntimePath)System.*.dll;$(RuntimePath)Microsoft.Win32.*.dll;$(RuntimePath)netstandard.dll"
Exclude="$(RuntimePath)$(MSBuildProjectName).dll" />
<ProjectReference Include="$(CoreLibProject)" />
Copy link
Member

Choose a reason for hiding this comment

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

Neat that this "just works".

@ericstj
Copy link
Member

ericstj commented Jun 22, 2020

Any impact to end-to-end library build perf with this change?

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

LGTM. Great!

@MichalStrehovsky
Copy link
Member

This broke the steps to update reference sources: https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/updating-ref-source.md

Building reference sources for System.Runtime produces an empty System.Runtime.cs. Rolling back this commit fixes it for me.

@ViktorHofer
Copy link
Member Author

@Anipik @ericstj can you please help me out here and take a look?

@safern
Copy link
Member

safern commented Jun 24, 2020

I think we just need to update this condition to consider if the project has a P2P to System.Private.Corelib as well or if the project is a partial facade to pass down the --follow-type-forwards flag:

<GenAPIAdditionalParameters Condition="'@(ReferenceFromRuntime)' != ''">$(GenAPIAdditionalParameters) --follow-type-forwards</GenAPIAdditionalParameters>

<ItemGroup>
<ProjectReference>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<AdditionalProperties Condition="'%(Filename)' == 'System.Private.CoreLib' and '$(RuntimeFlavor)' == 'CoreCLR'">Configuration=$(CoreCLRConfiguration);TargetFramework=$(NetCoreAppCurrent)</AdditionalProperties>
Copy link
Member

Choose a reason for hiding this comment

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

When building the repository I believe this can cause double build of System.Private.CoreLib. Since it will have already been built without these global properties. It can also result in race conditions if CoreLib is being built in the same parallel project graph as traversal.

Do we need to specify TargetFramework? It looks like that's already set in S.P.C. Can't we just UndefineProperties TargetFramework instead so that it doesn't flow?

Can we avoid setting Configuration if it is already set?

Can we append to AdditionalProperties when setting?

Copy link
Member

Choose a reason for hiding this comment

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

@ViktorHofer did you see this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ViktorHofer did you see this?

@ericstj yeah but forgot to respond, sorry.

Do we need to specify TargetFramework? It looks like that's already set in S.P.C. Can't we just UndefineProperties TargetFramework instead so that it doesn't flow?

Sure if that's possible. How would I prevent the property from flowing? Currently the TargetFramework Sdk controls that: https://github.com/dotnet/arcade/blob/master/src/Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk/src/build/Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk.targets#L59. Do we need a hook in that sdk?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we avoid setting Configuration if it is already set?

In which case would configuration already be set? We are not flowing that property.

Copy link
Member

Choose a reason for hiding this comment

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

prevent the property from flowing

You can set the UndefineProperties metadata on the ProjectReference. If the config system doesn't honor it we might have to add a switch.

Global properties automatically flow. So Configuration will always be either 1) whatever the default is (eg: debug) or 2) specified as a global property by build.cmd|sh

In general we need to be extra careful about global property hygine.

@Anipik
Copy link
Contributor

Anipik commented Jun 25, 2020

@ViktorHofer @safern i can throw up a pr to fix up the generateReferenceSource, (if any of u is not actively working on one)

@safern
Copy link
Member

safern commented Jun 25, 2020

Feel free, I'm not actively working on it.

@ViktorHofer
Copy link
Member Author

thanks Anirudh.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

7 participants