-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix VS complaining about missing projects in slns (continued) #68543
Conversation
Tagging subscribers to this area: @dotnet/runtime-infrastructure Issue DetailsContributes to #65552 This PR updates the remaining out-of-band projects that need to be updated to fix the broken Visual Studio experience by making sure that the projects correctly build on-top of the targeting pack. The changes are grouped by commits:
Remaining changes that will be submitted via separate pull requests are:
cc @ericstj (just FYI)
|
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"> | ||
<!-- Point MicrosoftNetCoreAppRefPackRefDir to the acquired targeting pack to use it later for AssemblySearchPaths resolution. --> | ||
<PropertyGroup Condition="'$(TargetFrameworkVersion)' != 'v$(NetCoreAppCurrentVersion)'"> | ||
<MicrosoftNetCoreAppRefPackRefDir>%(ResolvedFrameworkReference.TargetingPackPath)\ref\net$(TargetFrameworkVersion.TrimStart('v'))\</MicrosoftNetCoreAppRefPackRefDir> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work now without this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That property was previously set for older .NETCoreApp tfms but that isn't necessary anymore as these now just use the targeting pack's references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what if an OOB that targets say net6.0 references another OOB that also targets net6.0? Wouldn't you want to build against the live version of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In such cases you use ProjectReferences which is the current behavior in main already. Conflict resolution (an SDK task) makes sure that ProjectReferences are preferred over targeting pack assets.
You only use <Reference />
items for NetCoreAppCurrent to reference inbox assets. Everything else is accomplished via ProjectReferences. Eventually the inbox references will be converted to ProjectReferences as well but that's not possible yet without regressing the local innerloop perf.
src/libraries/System.Threading.Tasks.Dataflow/src/System.Threading.Tasks.Dataflow.csproj
Outdated
Show resolved
Hide resolved
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'"> | ||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="$(SystemThreadingTasksExtensionsVersion)" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.1'))"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being removed? I would think we only want the dependency on netstandard2.0 and netfx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project doesn't target netstandard2.1, therefore this condition can be merged with the "TFI != .NetCoreApp" condition above.
src/libraries/System.Security.Cryptography.Cose/ref/System.Security.Cryptography.Cose.csproj
Outdated
Show resolved
Hide resolved
...aries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj
Show resolved
Hide resolved
…fer/runtime into AutoReferencesContinued
eng/generators.targets
Outdated
@@ -16,17 +16,12 @@ | |||
and '$(IsSourceProject)' == 'true' | |||
and '$(MSBuildProjectExtension)' == '.csproj' | |||
and ( | |||
('@(Reference)' != '' | |||
'$(TargetFrameworkMoniker)' != '$(NetCoreAppCurrentTargetFrameworkMoniker)' | |||
or '$(DisableImplicitFrameworkReferences)' != 'true' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: can we please update the comment above to explain the condition in more detail given it is a complex one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simplify these conditions vastly and I originally had that change in this PR but then moved it out as it's unrelated to my change. I will submit a follow-up PR that does the clean-up and update the comment.
<ItemGroup> | ||
<Compile Include="System.ComponentModel.Composition.cs" /> | ||
<Compile Include="System.ComponentModel.Composition.Forwards.cs" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'"> | ||
<ProjectReference Include="$(LibrariesProjectRoot)System.Linq.Expressions\ref\System.Linq.Expressions.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are removing P2Ps from netcoreappcurrent build, how are we supposed to consume the live build of S.L.Expressions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The targeting pack that is resolved is the actual live built one (for NetCoreAppCurrent) which resides under artifacts\bin\microsoft.netcore.app.ref\
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already the current behavior in main. Let me explain it in more details:
- The shared framework libraries (both ref and src) get built as part of the libs.sfx subset.
- These projects binplace their built assets into the live targeting pack and runtime pack folders.
- NetCoreAppCurrent out-of-band libraries build on top of the live targeting pack and/or runtime pack and receive that pack's references.
ProjectReference items are used to reference live built assets that aren't part of the targeting pack (OOBs) or when the library is available in the targeting pack but ships via a package as well, i.e. System.Text.Json. In the case of such special libraries like STJ, we reference them via ProjectReferences so that the library has a package dependency on STJ.
Logging off now. Would be fantastic to get an approval so that I can continue my work tomorrow, on top of these changes. Thanks everyone. |
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'"> | ||
<Compile Include="Polyfills\System.Numerics.BitOperations.netstandard20.cs" /> | ||
<Compile Include="Polyfills\System.Text.Rune.netstandard20.cs" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"> | ||
|
||
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)'))"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way that it'd be compatible with NetCoreAppCurrent without actually being NetCoreAppCurrent? It feels like the compare-to-current is usually an ==
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eerhardt was asking the same question previously. Today these are the possible ways to condition on NetCoreAppCurrent (both platform agnostic and platform specific) that I know of:
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(TargetFrameworkVersion)' == 'v$(NetCoreAppCurrentVersion)'
'$(TargetFrameworkVersion)' == 'v$(NetCoreAppCurrentVersion)'
'$(TargetFrameworkMoniker)' == '$(NetCoreAppCurrentTargetFrameworkMoniker)'
$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)'))
<-- that one works on properties as well$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '$(NETCoreAppCurrentVersion)'))
I chose the TargetFrameworkCompatible function as it works on both properties and items. In the two projects that I updated to use that function, a simple equality check couldn't be performed as the TargetFramework
property doesn't evaluate to net7.0
but to net7.0-platform
, i.e. in the case of System.Text.Encodings.Web net7.0-Browser
.
<ItemGroup> | ||
<ProjectReference Include="$(LibrariesProjectRoot)System.Collections.Immutable\src\System.Collections.Immutable.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"> | ||
|
||
<ItemGroup Condition="'$(TargetFrameworkVersion)' == 'v$(NetCoreAppCurrentVersion)'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be
'$(TargetFramework)' == '$(NetCoreAppCurrent)'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Let me update that line a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last minor comment. Other than that, LGTM.
Contributes to #65552
Continuation of #68488
This PR updates the remaining out-of-band projects to fix the broken Visual Studio experience by making sure that the projects correctly build on-top of the targeting pack.
The changes are grouped by commits:
Remaining changes that will be submitted via separate pull requests:
cc @ericstj (just FYI)