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

Build the shim assemblies as part of libs.sfx #89005

Merged
merged 15 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" />

<PropertyGroup>
<!-- Libraries non test projects shouldn't reference compat shims. -->
<!-- Libraries ref and source projects which don't bring in dependencies from outside the repository shouldn't reference compat shims. -->
<SkipTargetingPackShimReferences Condition="'$(UseLocalTargetingRuntimePack)' == 'true' and
'$(IsTestProject)' != 'true' and
'$(IsTestSupportProject)' != 'true'">true</SkipTargetingPackShimReferences>
'$(IsTestSupportProject)' != 'true' and
'$(IsGeneratorProject)' != 'true'">true</SkipTargetingPackShimReferences>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)codeOptimization.targets" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum)</TargetFrameworks>
<SkipValidateReferenceAssemblyProjectReferences>true</SkipValidateReferenceAssemblyProjectReferences>
</PropertyGroup>

<ItemGroup>
Expand All @@ -9,7 +11,8 @@
</ItemGroup>

<ItemGroup>
<!-- Avoid a PackageReference to System.Drawing.Common this reference is only needed for TypeForwards -->
<PackageReference Include="System.Drawing.Common" Version="$(SystemDrawingCommonVersion)" PrivateAssets="All" />
<!-- Avoid a product dependency to System.Drawing.Common, this reference is only needed for TypeForwards -->
<ProjectReference Include="$(LibrariesProjectRoot)shims\stubs\System.Drawing.Common.csproj" PrivateAssets="all" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppPrevious)-windows;$(NetCoreAppPrevious);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum)</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -93,7 +94,8 @@ System.Security.Cryptography.X509Certificates.X509SelectionFlag</PackageDescript
</ItemGroup>

<ItemGroup>
<!-- Avoid a PackageReference to System.Drawing.Common this reference is only needed for TypeForwards -->
<PackageReference Include="System.Drawing.Common" Version="$(SystemDrawingCommonVersion)" PrivateAssets="All" />
<!-- Avoid a product dependency to System.Drawing.Common, this reference is only needed for TypeForwards -->
<ProjectReference Include="$(LibrariesProjectRoot)shims\stubs\System.Drawing.Common.csproj" PrivateAssets="all" />
</ItemGroup>

</Project>
46 changes: 40 additions & 6 deletions src/libraries/apicompat/ApiCompat.proj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<!-- For API comparison, ApiCompat needs the inbox assemblies (including shims) and to resolve type forwards, the out-of-band assemblies. -->
<ItemGroup>
<ProjectReference Include="..\sfx-src.proj" OutputItemType="SharedFrameworkAssembly" />
<ProjectReference Include="..\shims.proj" OutputItemType="SharedFrameworkAssembly" />
<ProjectReference Include="..\oob-src.proj" OutputItemType="OOBAssembly" />
</ItemGroup>

Expand All @@ -42,18 +41,52 @@
<PackageDownload Include="NETStandard.Library.Ref" Version="[$(NETStandardLibraryRefVersion)]" />
<PackageDownload Include="NETStandard.Library" Version="[$(NetStandardLibraryVersion)]" />
<PackageReference Include="Microsoft.DotNet.ApiCompat.Task" Version="$(MicrosoftDotNetApiCompatTaskVersion)" IsImplicitlyDefined="true" />

<!-- Restore and reference assemblies not built in runtime anymore, required for resolving type forward on both comparison sides. -->
<ApiCompatTypeForwardDestinationPackage Include="System.Data.SqlClient" PackageVersion="$(SystemDataSqlClientVersion)" TargetFramework="netcoreapp2.1" />
<ApiCompatTypeForwardDestinationPackage Include="System.Drawing.Common" PackageVersion="$(SystemDrawingCommonVersion)" TargetFramework="net7.0" />

<!-- Restore and reference assemblies required for resolving type forwards on the baseline (left) side. -->
<ApiCompatLeftTypeForwardDestinationPackage Include="@(ApiCompatTypeForwardDestinationPackage)" />
<ApiCompatLeftTypeForwardDestinationPackage
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you got this all fixed up now, but one thing you might consider is using a project to do an actual restore of the old Microsoft.Windows.Compatibility package and all assets for a particular target framework. That might avoid juggling all the PackageDownload items.

Include="
Microsoft.Win32.SystemEvents;
System.CodeDom;
System.Configuration.ConfigurationManager;
System.Data.Odbc;
System.Data.OleDb;
System.Diagnostics.EventLog;
System.Diagnostics.PerformanceCounter;
System.IO.Packaging;
System.IO.Ports;
System.Runtime.Serialization.Schema;
System.Security.Cryptography.Pkcs;
System.Security.Cryptography.ProtectedData;
System.Security.Cryptography.Xml;
System.Security.Permissions;
System.ServiceModel.Syndication;
System.ServiceProcess.ServiceController;
System.Threading.AccessControl;
System.Windows.Extensions"
PackageVersion="$(ApiCompatNetCoreAppBaselineVersion)"
TargetFramework="$(ApiCompatNetCoreAppBaselineTFM)" />
<PackageDownload Include="@(ApiCompatLeftTypeForwardDestinationPackage)" Version="[%(PackageVersion)]" />
</ItemGroup>

<Target Name="RunApiCompat"
DependsOnTargets="FindReferenceAssembliesForReferences;CollectApiCompatInputs"
AfterTargets="Build"
Inputs="@(ReferencePathWithRefAssemblies);$(ApiCompatNetStandard20BaselineFile);$(ApiCompatNetStandard21BaselineFile);$(ApiCompatNetCoreAppLatestStableBaselineFile);@(ApiCompatExcludeAttributesFile)"
Inputs="$(MSBuildThisFileFullPath);@(ReferencePathWithRefAssemblies);$(ApiCompatNetStandard20BaselineFile);$(ApiCompatNetStandard21BaselineFile);$(ApiCompatNetCoreAppLatestStableBaselineFile);@(ApiCompatExcludeAttributesFile)"
Outputs="$(IntermediateOutputPath)$(TargetArchitecture)-marker.txt">
<Message Text="ApiCompat -> Comparing $(NetCoreAppCurrent) reference assemblies against .NETStandard 2.x and .NETCoreApp $(ApiCompatNetCoreAppBaselineVersion)..." Importance="high" />

<ItemGroup>
<ApiCompatNetCoreAppLatestStableAssemblyReference Include="@(ApiCompatLeftTypeForwardDestinationPackage->'$(NuGetPackageRoot)$([System.String]::new('%(ApiCompatLeftTypeForwardDestinationPackage.Identity)').ToLowerInvariant())\%(ApiCompatLeftTypeForwardDestinationPackage.PackageVersion)\lib\%(ApiCompatLeftTypeForwardDestinationPackage.TargetFramework)\%(ApiCompatLeftTypeForwardDestinationPackage.Identity).dll')" />

<ApiCompatRightAssembly Include="@(ReferencePathWithRefAssemblies->WithMetadataValue('IsPrivateAssembly', 'false')->WithMetadataValue('OutputItemType', 'SharedFrameworkAssembly'))" />
<ApiCompatRightAssemblyReference Include="@(ReferencePathWithRefAssemblies->WithMetadataValue('IsPrivateAssembly', 'false')->WithMetadataValue('OutputItemType', 'OOBAssembly'), ',')" />
<ApiCompatRightAssemblyReferenceFromPackage Include="@(ApiCompatTypeForwardDestinationPackage->'$(NuGetPackageRoot)$([System.String]::new('%(ApiCompatTypeForwardDestinationPackage.Identity)').ToLowerInvariant())\%(ApiCompatTypeForwardDestinationPackage.PackageVersion)\lib\%(ApiCompatTypeForwardDestinationPackage.TargetFramework)\%(ApiCompatTypeForwardDestinationPackage.Identity).dll')" />
<ApiCompatRightAssemblyReference Include="@(ReferencePathWithRefAssemblies->WithMetadataValue('IsPrivateAssembly', 'false')->WithMetadataValue('OutputItemType', 'OOBAssembly'));
@(ApiCompatRightAssemblyReferenceFromPackage)" />
</ItemGroup>

<!-- ApiCompat: NetCoreAppCurrent <-> .NETCoreApp ApiCompatNetCoreAppBaselineVersion -->
Expand All @@ -68,7 +101,8 @@
ExcludeAttributesFiles="@(ApiCompatExcludeAttributesFile)"
LeftAssembliesTransformationPattern="@(ApiCompatNetCoreAppLatestStableLeftAssembliesTransformationPattern)"
RightAssembliesTransformationPattern="@(ApiCompatNetCoreAppCurrentRightAssembliesTransformationPattern)"
RightAssembliesReferences="@(ApiCompatRightAssemblyReference)" />
LeftAssembliesReferences="@(ApiCompatNetCoreAppLatestStableAssemblyReference, ',')"
RightAssembliesReferences="@(ApiCompatRightAssemblyReference, ',')" />

<!-- ApiCompat: NetCoreAppCurrent <-> netstandard2.1 -->
<Microsoft.DotNet.ApiCompat.Task.ValidateAssembliesTask
Expand All @@ -81,7 +115,7 @@
ExcludeAttributesFiles="@(ApiCompatExcludeAttributesFile)"
LeftAssembliesTransformationPattern="@(ApiCompatNetStandard21LeftAssembliesTransformationPattern)"
RightAssembliesTransformationPattern="@(ApiCompatNetCoreAppCurrentRightAssembliesTransformationPattern)"
RightAssembliesReferences="@(ApiCompatRightAssemblyReference)" />
RightAssembliesReferences="@(ApiCompatRightAssemblyReference, ',')" />

<!-- ApiCompat: NetCoreAppCurrent <-> netstandard2.0 -->
<Microsoft.DotNet.ApiCompat.Task.ValidateAssembliesTask
Expand All @@ -94,7 +128,7 @@
ExcludeAttributesFiles="@(ApiCompatExcludeAttributesFile)"
LeftAssembliesTransformationPattern="@(ApiCompatNetStandard20LeftAssembliesTransformationPattern)"
RightAssembliesTransformationPattern="@(ApiCompatNetCoreAppCurrentRightAssembliesTransformationPattern)"
RightAssembliesReferences="@(ApiCompatRightAssemblyReference)" />
RightAssembliesReferences="@(ApiCompatRightAssemblyReference, ',')" />

<!-- Create a marker file which serves as the target's output to enable incremental builds. -->
<Touch Files="$(IntermediateOutputPath)$(TargetArchitecture)-marker.txt"
Expand Down
44 changes: 0 additions & 44 deletions src/libraries/frameworklist.targets

This file was deleted.

6 changes: 0 additions & 6 deletions src/libraries/oob.proj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
</PropertyGroup>

<ItemGroup Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''">
<ProjectReference Include="sfx-gen.proj" OutputItemType="SharedFrameworkAnalyzerAssembly" />
<ProjectReference Include="sfx-src.proj" OutputItemType="SharedFrameworkAssembly" />
<ProjectReference Include="oob-src.proj" OutputItemType="OOBAssembly" />
<ProjectReference Include="shims.proj" OutputItemType="SharedFrameworkAssembly" />

<ProjectReference Include="apicompat\ApiCompat.proj"
Condition="'$(DotNetBuildFromSource)' != 'true' and '$(ApiCompatValidateAssemblies)' != 'false'" />
Expand All @@ -23,15 +21,11 @@
<!-- Support building reference projects only. -->
<ItemGroup Condition="'$(RefOnly)' == 'true'">
<ProjectReference Remove="@(ProjectReference)" />
<ProjectReference Include="sfx-gen.proj" OutputItemType="SharedFrameworkAnalyzerAssembly" />
<ProjectReference Include="sfx-ref.proj" OutputItemType="SharedFrameworkAssembly" />
<ProjectReference Include="oob-ref.proj" />
<ProjectReference Include="shims.proj" OutputItemType="SharedFrameworkAssembly" />
</ItemGroup>

<ImportGroup Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''">
<!-- Re-generate the targeting pack's framework list to include shims. -->
<Import Project="frameworklist.targets" />
<!-- Import the illink file which contains some of the logic required to illink the out-of-band assemblies. -->
<Import Project="$(RepositoryEngineeringDir)illink.targets" />
</ImportGroup>
Expand Down
8 changes: 8 additions & 0 deletions src/libraries/sfx-ref.proj
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@
System.Private.CoreLib\ref\System.Private.CoreLib.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(RefOnly)' == 'true'">
<ProjectReference Include="shims\*\src\*.csproj" />
<ReferenceShimProject Include="shims\*\ref\*.csproj" />
<ProjectReference Include="@(ReferenceShimProject)" />
<!-- Omit projects which depend on source projects to be built. -->
<ProjectReference Remove="@(ReferenceShimProject->'shims\%(Filename)\src\%(Filename)%(Extension)')" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/libraries/sfx-src.proj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
Exclude="@(NetCoreAppLibrary->'%(Identity)\src\%(Identity).csproj');
Microsoft.VisualBasic.Core\src\Microsoft.VisualBasic.Core.vbproj" />
<ProjectReference Include="@(AnyProject);
$(CoreLibProject)"
$(CoreLibProject);
shims\*\src\*.csproj"
Exclude="@(NonNetCoreAppProject)" />
</ItemGroup>

Expand Down
45 changes: 40 additions & 5 deletions src/libraries/sfx.proj
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<Project Sdk="Microsoft.Build.NoTargets">

<Sdk Name="Microsoft.DotNet.SharedFramework.Sdk" />

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)-$(TargetOS)</TargetFramework>
<BuildInParallel>false</BuildInParallel>
<IsPackable>false</IsPackable>
<FrameworkListOutputPath>$(MicrosoftNetCoreAppRefPackDataDir)FrameworkList.xml</FrameworkListOutputPath>
</PropertyGroup>

<ItemGroup>
Expand All @@ -11,16 +15,47 @@
<ProjectReference Include="sfx-ref.proj">
<OutputItemType Condition="'$(RefOnly)' == 'true'">SharedFrameworkAssembly</OutputItemType>
</ProjectReference>
<!-- The RefOnly condition exists to support building the reference source projects only. -->
<ProjectReference Include="sfx-src.proj" OutputItemType="SharedFrameworkAssembly" Condition="'$(RefOnly)' != 'true'" />
<ProjectReference Include="sfx-gen.proj" OutputItemType="SharedFrameworkAnalyzerAssembly" />
</ItemGroup>

<!-- Support building only the reference assemblies. -->
<ItemGroup Condition="'$(RefOnly)' != 'true'">
<ProjectReference Include="sfx-src.proj" OutputItemType="SharedFrameworkAssembly" />
</ItemGroup>
<Target Name="GetGenerateFrameworkListFileInputs">
<Error Text="Shared framework assemblies must be built before the framework list can be generated."
Condition="'@(SharedFrameworkAssembly)' == '' or '@(SharedFrameworkAnalyzerAssembly)' == ''" />

<ItemGroup>
<SharedFrameworkAssemblyWithReferenceAssembly Include="@(SharedFrameworkAssembly->WithMetadataValue('IsPrivateAssembly', 'false')->HasMetadata('ReferenceAssembly'))" />
<SharedFrameworkAssemblyWithoutReferenceAssembly Include="@(SharedFrameworkAssembly->WithMetadataValue('IsPrivateAssembly', 'false'))"
Exclude="@(SharedFrameworkAssemblyWithReferenceAssembly)" />

<FrameworkListInputFile Include="@(SharedFrameworkAssemblyWithReferenceAssembly->Metadata('ReferenceAssembly'));
@(SharedFrameworkAssemblyWithoutReferenceAssembly)"
TargetPath="ref/$(NetCoreAppCurrent)" />
<FrameworkListInputFile Include="@(SharedFrameworkAnalyzerAssembly)"
TargetPath="%(SharedFrameworkAnalyzerAssembly.GeneratorProjectBaseTargetPath)" />
</ItemGroup>
</Target>

<!-- Generate the targeting pack's framework list so that out-of-band projects can leverage it. -->
<Import Project="frameworklist.targets" />
<UsingTask TaskName="CreateFrameworkListFile" AssemblyFile="$(DotNetSharedFrameworkTaskFile)"/>
<Target Name="GenerateFrameworkListFile"
DependsOnTargets="GetGenerateFrameworkListFileInputs"
AfterTargets="Build"
Inputs="@(FrameworkListInputFile)"
Outputs="$(FrameworkListOutputPath)">
<ItemGroup>
<FrameworkListRootAttribute Include="Name" Value="$(NetCoreAppCurrentBrandName)" />
<FrameworkListRootAttribute Include="TargetFrameworkIdentifier" Value="$(NetCoreAppCurrentIdentifier)" />
<FrameworkListRootAttribute Include="TargetFrameworkVersion" Value="$(NetCoreAppCurrentVersion)" />
<FrameworkListRootAttribute Include="FrameworkName" Value="$(MicrosoftNetCoreAppFrameworkName)" />
</ItemGroup>

<CreateFrameworkListFile Files="@(FrameworkListInputFile)"
TargetFile="$(FrameworkListOutputPath)"
TargetFilePrefixes="ref/;runtimes/;analyzers/"
RootAttributes="@(FrameworkListRootAttribute)" />
</Target>

<!-- Copy the intellisense file to the targeting pack directory. -->
<Target Name="CopyDocumentationFiles"
Expand Down
19 changes: 0 additions & 19 deletions src/libraries/shims.proj

This file was deleted.

5 changes: 0 additions & 5 deletions src/libraries/shims/Directory.Build.targets

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Configuration.ConfigurationManager\src\System.Configuration.ConfigurationManager.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\src\System.Runtime.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\src\System.Security.Permissions.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)shims\stubs\System.Configuration.ConfigurationManager.csproj" PrivateAssets="all" />
<ProjectReference Include="$(LibrariesProjectRoot)shims\stubs\System.Security.Permissions.csproj" PrivateAssets="all" />
</ItemGroup>

</Project>
Loading
Loading