Move Windows Compat pack to NuGet pack task (#56686)
authorViktor Hofer <viktor.hofer@microsoft.com>
Tue, 3 Aug 2021 08:46:24 +0000 (10:46 +0200)
committerGitHub <noreply@github.com>
Tue, 3 Aug 2021 08:46:24 +0000 (10:46 +0200)
* Move Windows Compat pack to NuGet pack task

This is a straight port from pkgproj to csproj and also enables building
the compat pack together with its dependencies.

As usual, if the compat pack alone should be built (i.e. for inner loop
tests), the `--no-dependencies` flag should be used,
i.e. `dotnet build --no-dependencies` or `dotnet pack --no-build`.

* Fix traversal builds and don't overbuild packages

* Update libraries-packages.proj

src/libraries/Microsoft.Extensions.HostFactoryResolver/src/Microsoft.Extensions.HostFactoryResolver.Sources.csproj
src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj
src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj [new file with mode: 0644]
src/libraries/libraries-packages.proj
src/libraries/pkg/Microsoft.Windows.Compatibility/Microsoft.Windows.Compatibility.pkgproj [deleted file]
src/libraries/pkg/Microsoft.Windows.Compatibility/Microsoft.Windows.Compatibility.proj [deleted file]
src/libraries/pkg/baseline/packageIndex.json
src/libraries/pkg/runtime.native.System.IO.Ports/runtime.native.System.IO.Ports.proj
src/libraries/src.proj

index dff9038..31cd860 100644 (file)
@@ -3,8 +3,6 @@
        package infra globs for .cs files. -->
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <!-- The project doesn't compile anything therefore create the package during build. -->
-    <GeneratePackageOnBuild Condition="'$(BuildingAnOfficialBuildLeg)' != 'true'">true</GeneratePackageOnBuild>
     <IsShipping>false</IsShipping>
     <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
     <!-- This is a source package which includes all .cs files by default. -->
index 299a8b2..9aad968 100644 (file)
@@ -6,8 +6,6 @@
     <PackageId>$(MSBuildProjectName)</PackageId>
     <AvoidRestoreCycleOnSelfReference>true</AvoidRestoreCycleOnSelfReference>
     <AssemblyName>Microsoft.NETCore.Platforms.BuildTasks</AssemblyName>
-    <!-- The only output of this project is the package as the tasks aren't packaged. -->
-    <GeneratePackageOnBuild Condition="'$(BuildingAnOfficialBuildLeg)' != 'true'">true</GeneratePackageOnBuild>
 
     <IsSourceProject>false</IsSourceProject>
     <IsPackable>true</IsPackable>
diff --git a/src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj b/src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj
new file mode 100644 (file)
index 0000000..86afb92
--- /dev/null
@@ -0,0 +1,70 @@
+<Project Sdk="Microsoft.Build.NoTargets">
+  <PropertyGroup>
+    <!-- Using a csproj extension to get the correct multi-targeting behavior. -->
+    <TargetFrameworks>$(NetCoreAppCurrent);netcoreapp3.1;netstandard2.1;netstandard2.0</TargetFrameworks>
+    <IsPackable>true</IsPackable>
+    <!-- Reference the outputs for the dependency nodes calculation. -->
+    <NoTargetsDoNotReferenceOutputAssemblies>false</NoTargetsDoNotReferenceOutputAssemblies>
+    <!-- This is a meta package and doesn't contain any libs. -->
+    <NoWarn>$(NoWarn);NU5128</NoWarn>
+    <PackageDescription>This Windows Compatibility Pack provides access to APIs that were previously available only for .NET Framework. It can be used from both .NET Core as well as .NET Standard.</PackageDescription>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Win32.Registry.AccessControl\src\Microsoft.Win32.Registry.AccessControl.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.CodeDom\src\System.CodeDom.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.ComponentModel.Composition\src\System.ComponentModel.Composition.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Configuration.ConfigurationManager\src\System.Configuration.ConfigurationManager.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Data.Odbc\src\System.Data.Odbc.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Data.OleDb\src\System.Data.OleDb.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.EventLog\src\System.Diagnostics.EventLog.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.DirectoryServices.AccountManagement\src\System.DirectoryServices.AccountManagement.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.DirectoryServices.Protocols\src\System.DirectoryServices.Protocols.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.DirectoryServices\src\System.DirectoryServices.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Drawing.Common\src\System.Drawing.Common.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.IO.Packaging\src\System.IO.Packaging.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.IO.Ports\src\System.IO.Ports.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Management\src\System.Management.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Reflection.Context\src\System.Reflection.Context.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.Caching\src\System.Runtime.Caching.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Cryptography.ProtectedData\src\System.Security.Cryptography.ProtectedData.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Cryptography.Xml\src\System.Security.Cryptography.Xml.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\src\System.Security.Permissions.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.ServiceModel.Syndication\src\System.ServiceModel.Syndication.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.ServiceProcess.ServiceController\src\System.ServiceProcess.ServiceController.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Speech\src\System.Speech.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Text.Encoding.CodePages\src\System.Text.Encoding.CodePages.csproj" />
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Threading.AccessControl\src\System.Threading.AccessControl.csproj" />
+  </ItemGroup>
+
+  <ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.1'))">
+    <ProjectReference Include="$(LibrariesProjectRoot)System.ComponentModel.Composition.Registration\src\System.ComponentModel.Composition.Registration.csproj" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="System.Data.SqlClient" Version="$(SystemDataSqlClientVersion)" />  
+    <PackageReference Include="System.ServiceModel.Primitives;
+                                     System.ServiceModel.Duplex;
+                                     System.ServiceModel.Http;
+                                     System.ServiceModel.NetTcp;
+                                     System.ServiceModel.Security"
+                      Version="$(ServiceModelVersion)" />
+  </ItemGroup>
+
+  <!-- Packages which are inbox in NET6 and shouldn't and can't be referenced anymore. -->
+  <ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
+    <PackageReference Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" />
+    <PackageReference Include="System.Data.DataSetExtensions" Version="$(SystemDataDataSetExtensionsVersion)" />
+    <PackageReference Include="System.IO.FileSystem.AccessControl" Version="$(SystemIOFileSystemAccessControlVersion)" />
+    <PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" />
+    <PackageReference Include="System.Reflection.Emit" Version="$(SystemReflectionEmitVersion)" />
+    <PackageReference Include="System.Reflection.Emit.ILGeneration" Version="$(SystemReflectionEmitILGenerationVersion)" />
+    <PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(SystemReflectionEmitLightweightVersion)" />
+    <PackageReference Include="System.Security.AccessControl" Version="$(SystemSecurityAccessControlVersion)" />
+    <PackageReference Include="System.Security.Cryptography.Cng" Version="$(SystemSecurityCryptographyCngVersion)" />
+    <PackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />
+  </ItemGroup>
+</Project>
index f67803e..0bc55eb 100644 (file)
@@ -2,13 +2,13 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.DotNet.Build.Tasks.Packaging" Version="$(MicrosoftDotNetBuildTasksPackagingVersion)" />
+  </ItemGroup>
 
-    <ProjectReference Include="$(MSBuildThisFileDirectory)System.Runtime.Experimental\ref\System.Runtime.Experimental.csproj"
-                      Condition="'$(BuildAllConfigurations)' == 'true'" />
+  <ItemGroup Condition="'$(BuildAllConfigurations)' == 'true'">
+    <ProjectReference Include="$(MSBuildThisFileDirectory)System.Runtime.Experimental\ref\System.Runtime.Experimental.csproj" />
     <ProjectReference Include="$(PkgDir)*\*.proj" Exclude="$(PkgDir)test\*" />
     <ProjectReference Include="$(MSBuildThisFileDirectory)*\src\*.*proj"
-                      Condition="'$(BuildAllConfigurations)' == 'true'"
-                      Exclude="$(MSBuildThisFileDirectory)*\src\**\*.shproj"/>
+                      Exclude="$(MSBuildThisFileDirectory)*\src\**\*.shproj" />
   </ItemGroup>
 
   <!-- Need the PackageIndexFile file property from baseline.props -->
diff --git a/src/libraries/pkg/Microsoft.Windows.Compatibility/Microsoft.Windows.Compatibility.pkgproj b/src/libraries/pkg/Microsoft.Windows.Compatibility/Microsoft.Windows.Compatibility.pkgproj
deleted file mode 100644 (file)
index c1a3f16..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-<Project DefaultTargets="Build">
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
-  <PropertyGroup>
-    <!-- We don't need to harvest the stable packages to build this -->
-    <HarvestStablePackage>false</HarvestStablePackage>
-    <PackageDescription>This Windows Compatibility Pack provides access to APIs that were previously available only for .NET Framework. It can be used from both .NET Core as well as .NET Standard.</PackageDescription>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <PrereleaseLibraryPackage>
-      <Version>$(PackageVersion)</Version>
-    </PrereleaseLibraryPackage>
-    <NS21PrereleaseLibraryPackage>
-      <Version>$(PackageVersion)</Version>
-    </NS21PrereleaseLibraryPackage>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <PrereleaseLibraryPackage Include="Microsoft.Win32.Registry.AccessControl" />
-    <PrereleaseLibraryPackage Include="Microsoft.Win32.SystemEvents" />
-    <PrereleaseLibraryPackage Include="System.CodeDom" />
-    <PrereleaseLibraryPackage Include="System.ComponentModel.Composition" />
-    <PrereleaseLibraryPackage Include="System.Configuration.ConfigurationManager" />
-    <PrereleaseLibraryPackage Include="System.Data.Odbc" />
-    <PrereleaseLibraryPackage Include="System.Data.OleDb" />
-    <PrereleaseLibraryPackage Include="System.Drawing.Common" />
-    <PrereleaseLibraryPackage Include="System.Diagnostics.EventLog" />
-    <PrereleaseLibraryPackage Include="System.Diagnostics.PerformanceCounter" />
-    <PrereleaseLibraryPackage Include="System.DirectoryServices" />
-    <PrereleaseLibraryPackage Include="System.DirectoryServices.AccountManagement" />
-    <PrereleaseLibraryPackage Include="System.DirectoryServices.Protocols" />
-    <PrereleaseLibraryPackage Include="System.IO.Packaging" />
-    <PrereleaseLibraryPackage Include="System.IO.Ports" />
-    <PrereleaseLibraryPackage Include="System.Management" />
-    <PrereleaseLibraryPackage Include="System.Runtime.Caching" />
-    <PrereleaseLibraryPackage Include="System.Security.Cryptography.Pkcs" />
-    <PrereleaseLibraryPackage Include="System.Security.Cryptography.ProtectedData" />
-    <PrereleaseLibraryPackage Include="System.Security.Cryptography.Xml" />
-    <PrereleaseLibraryPackage Include="System.Security.Permissions" />
-    <PrereleaseLibraryPackage Include="System.ServiceModel.Syndication" />
-    <PrereleaseLibraryPackage Include="System.ServiceProcess.ServiceController" />
-    <PrereleaseLibraryPackage Include="System.Speech" />
-    <PrereleaseLibraryPackage Include="System.Text.Encoding.CodePages" />
-    <PrereleaseLibraryPackage Include="System.Threading.AccessControl" />
-
-    <NS21PrereleaseLibraryPackage Include="System.ComponentModel.Composition.Registration" />
-    <NS21PrereleaseLibraryPackage Include="System.Reflection.Context" />
-
-    <!-- Packages which are inbox in NET6 and don't need to be referenced. -->
-    <BeforeNET6LibraryPackage Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" />
-    <BeforeNET6LibraryPackage Include="System.Data.DataSetExtensions" Version="$(SystemDataDataSetExtensionsVersion)" />
-    <BeforeNET6LibraryPackage Include="System.IO.FileSystem.AccessControl" Version="$(SystemIOFileSystemAccessControlVersion)" />
-    <BeforeNET6LibraryPackage Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" />
-    <BeforeNET6LibraryPackage Include="System.Reflection.Emit" Version="$(SystemReflectionEmitVersion)" />
-    <BeforeNET6LibraryPackage Include="System.Reflection.Emit.ILGeneration" Version="$(SystemReflectionEmitILGenerationVersion)" />
-    <BeforeNET6LibraryPackage Include="System.Reflection.Emit.Lightweight" Version="$(SystemReflectionEmitLightweightVersion)" />
-    <BeforeNET6LibraryPackage Include="System.Security.AccessControl" Version="$(SystemSecurityAccessControlVersion)" />
-    <BeforeNET6LibraryPackage Include="System.Security.Cryptography.Cng" Version="$(SystemSecurityCryptographyCngVersion)" />
-    <BeforeNET6LibraryPackage Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />
-
-    <!-- External packages -->
-    <ExternalLibraryPackage Include="System.Data.SqlClient" Version="$(SystemDataSqlClientVersion)" />  
-    <ExternalLibraryPackage Include="System.ServiceModel.Primitives;
-                                     System.ServiceModel.Duplex;
-                                     System.ServiceModel.Http;
-                                     System.ServiceModel.NetTcp;
-                                     System.ServiceModel.Security"
-                            Version="$(ServiceModelVersion)" />
-  </ItemGroup>
-
-  <ItemGroup>
-    <IndexedDependency Include="@(PrereleaseLibraryPackage);
-                                @(NS21PrereleaseLibraryPackage)"
-                       TargetFramework="net6.0" />
-    <IndexedDependency Include="@(BeforeNET6LibraryPackage);
-                                @(PrereleaseLibraryPackage);
-                                @(NS21PrereleaseLibraryPackage)"
-                       TargetFramework="netcoreapp3.1" />
-    <IndexedDependency Include="@(BeforeNET6LibraryPackage);
-                                @(PrereleaseLibraryPackage);
-                                @(NS21PrereleaseLibraryPackage)"
-                       TargetFramework="netstandard2.1" />
-    <IndexedDependency Include="@(BeforeNET6LibraryPackage);
-                                @(PrereleaseLibraryPackage)"
-                       TargetFramework="netstandard2.0" />
-  </ItemGroup>
-
-  <ItemGroup>
-    <Dependency Include="@(ExternalLibraryPackage)"
-                TargetFramework="net6.0" />
-    <Dependency Include="@(ExternalLibraryPackage)"
-                TargetFramework="netcoreapp3.1" />
-    <Dependency Include="@(ExternalLibraryPackage)"
-                TargetFramework="netstandard2.0" />
-    <Dependency Include="@(ExternalLibraryPackage)"
-                TargetFramework="netstandard2.1" />
-  </ItemGroup>
-
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
-</Project>
diff --git a/src/libraries/pkg/Microsoft.Windows.Compatibility/Microsoft.Windows.Compatibility.proj b/src/libraries/pkg/Microsoft.Windows.Compatibility/Microsoft.Windows.Compatibility.proj
deleted file mode 100644 (file)
index 17a7f16..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<Project DefaultTargets="Build">
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
-
-  <!-- only build during the AllConfigurations leg because it depends on other nupkgs from this leg -->
-  <ItemGroup Condition="'$(BuildAllConfigurations)' == 'true'">
-    <Project Include="$(MSBuildProjectName).pkgproj" />
-  </ItemGroup>
-
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(dir.traversal.targets))" />
-</Project>
\ No newline at end of file
index 6c24d93..09f1be0 100644 (file)
         "6.0.0.0": "6.0.0"
       }
     },
-    "Microsoft.Windows.Compatibility": {
-      "StableVersions": [
-        "2.0.0",
-        "2.0.1",
-        "2.1.0",
-        "2.1.1",
-        "3.0.0",
-        "3.0.1",
-        "5.0.0"
-      ],
-      "InboxOn": {}
-    },
-    "Microsoft.Windows.Compatibility.Shims": {
-      "StableVersions": [
-        "2.0.0",
-        "2.0.1"
-      ],
-      "InboxOn": {}
-    },
     "Microsoft.XmlSerializer.Generator": {
       "StableVersions": [
         "1.0.0",
index a1ec1ea..4cccee8 100644 (file)
@@ -1,7 +1,7 @@
 <Project DefaultTargets="Build">
   <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
 
-  <ItemGroup Condition="'$(BuildAllConfigurations)' == 'true'">
+  <ItemGroup>
     <!-- identity project built in AllConfigurations leg, runtime specific projects are included through netcoreapp.rids.props -->
     <Project Include="$(MSBuildProjectName).pkgproj" />
   </ItemGroup>
index 5862082..0faa260 100644 (file)
@@ -7,6 +7,12 @@
   <ItemGroup>
     <_allSrc Include="$(MSBuildThisFileDirectory)*\src\*.csproj"
              Exclude="@(ProjectExclusions)" />
+    <!-- Don't build ProjectReferences of the compat pack in a traversal build to avoid unnecessary incremental builds. -->
+    <_allSrc Update="$(MSBuildThisFileDirectory)Microsoft.Windows.Compatibility\src\Microsoft.Windows.Compatibility.csproj"
+             AdditionalProperties="BuildProjectReferences=false" />
+    <!-- Only build the compat pack in the allconfigurations leg. -->
+    <_allSrc Remove="$(MSBuildThisFileDirectory)Microsoft.Windows.Compatibility\src\Microsoft.Windows.Compatibility.csproj"
+             Condition="'$(BuildAllConfigurations)' != 'true'" />
     <NonNetCoreAppProject Include="@(_allSrc)"
                           Exclude="@(NetCoreAppLibrary->'%(Identity)\src\%(Identity).csproj')" />
     <NetCoreAppProject Include="$(CoreLibProject);