Add Csproj pack infra for packages with ref and runtime assemblies and symbols. ...
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Fri, 2 Jul 2021 15:43:52 +0000 (08:43 -0700)
committerGitHub <noreply@github.com>
Fri, 2 Jul 2021 15:43:52 +0000 (08:43 -0700)
* add infra for adding ref and runtime assemblies

delete the project

add a comment

move the warning disable to cenral location

moving props/targets to packaging.props and packaging.targets

use intellisense package for ref and runtime xml files

add comments, flag for ref assemblies, remove xml from runtimes, use outputItem to get the reference assembly

addressing some more feedback

remove ref assemblies

add suppression file and update package validatio

* move PackageValidationBaselineVersion to packaging.targets

* update the package validation version

13 files changed:
NuGet.config
eng/Versions.props
eng/packaging.props
eng/packaging.targets
global.json
src/libraries/Directory.Build.targets
src/libraries/Microsoft.Extensions.DependencyModel/src/CompatibilitySuppressions.xml [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyModel/src/Microsoft.Extensions.DependencyModel.csproj
src/libraries/Microsoft.Extensions.HostFactoryResolver/src/Microsoft.Extensions.HostFactoryResolver.Sources.csproj
src/libraries/System.IO.Hashing/src/System.IO.Hashing.csproj
src/libraries/System.Windows.Extensions/pkg/System.Windows.Extensions.pkgproj [deleted file]
src/libraries/System.Windows.Extensions/src/CompatibilitySuppressions.xml [new file with mode: 0644]
src/libraries/System.Windows.Extensions/src/System.Windows.Extensions.csproj

index 7812fc3..f39fab9 100644 (file)
@@ -17,6 +17,8 @@
     <add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
     <add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
     <add key="dotnet6-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6-transport/nuget/v3/index.json" />
+    <!-- Used for dotnet pack task -->
+    <add key="nuget-build" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/nuget-build/nuget/v3/index.json" />
     <!-- Used for the Rich Navigation indexing task -->
     <add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
   </packageSources>
index 765b461..1c8ae0b 100644 (file)
@@ -64,7 +64,7 @@
     <MicrosoftDotNetVersionToolsTasksVersion>6.0.0-beta.21330.2</MicrosoftDotNetVersionToolsTasksVersion>
     <MicrosoftDotNetPackageTestingVersion>6.0.0-beta.21330.2</MicrosoftDotNetPackageTestingVersion>
     <!-- NuGet dependencies -->
-    <NuGetBuildTasksPackVersion>5.9.0-preview.2</NuGetBuildTasksPackVersion>
+    <NuGetBuildTasksPackVersion>6.0.0-preview.1.102</NuGetBuildTasksPackVersion>
     <!-- Installer dependencies -->
     <MicrosoftNETCoreAppVersion>6.0.0-alpha.1.20612.4</MicrosoftNETCoreAppVersion>
     <MicrosoftNETCoreDotNetHostVersion>6.0.0-preview.7.21321.2</MicrosoftNETCoreDotNetHostVersion>
index 534d3dd..9e992bb 100644 (file)
@@ -13,6 +13,7 @@
     <PackageVersion Condition="'$(PackageVersion)' == '' and '$(MSBuildProjectExtension)' == '.pkgproj'">6.0.0</PackageVersion>
     <SkipValidatePackageTargetFramework>true</SkipValidatePackageTargetFramework>
     <SkipGenerationCheck>true</SkipGenerationCheck>
+    <DefaultAllowedOutputExtensionsInPackageBuildOutputFolder>.dll;.exe;.winmd;.json;.pri;</DefaultAllowedOutputExtensionsInPackageBuildOutputFolder>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(DotNetBuildFromSource)' == 'true'">
 
   <Import Condition="Exists('$(PkgDir)baseline\baseline.props') and '$(MSBuildProjectExtension)' == '.pkgproj'" Project="$(PkgDir)baseline\baseline.props" />
 
-  <PropertyGroup Condition="'$(IsPackable)' == 'true'">
-    <PackageDesignerMarkerFile>$(MSBuildThisFileDirectory)useSharedDesignerContext.txt</PackageDesignerMarkerFile>
-  </PropertyGroup>
-
   <ItemGroup Condition="'$(IsPackable)' == 'true'">
     <!-- Add a marker to help the designer optimize & share .NET Core packages -->
     <None Include="$(PackageDesignerMarkerFile)"
@@ -50,4 +47,9 @@
       <RuntimeIDs>@(NETCoreApp30RIDs)</RuntimeIDs>
     </DefaultValidateFramework>
   </ItemGroup>
+
+  <!-- TODO: Remove when all required nuget pack features are part of the consumed SDK. -->
+  <ItemGroup Condition="'$(IsPackable)' == 'true' and '$(IsSourceProject)' == 'true'">
+    <PackageReference Include="NuGet.Build.Tasks.Pack" Version="$(NuGetBuildTasksPackVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
+  </ItemGroup>
 </Project>
index 1f19f57..d6344a0 100644 (file)
@@ -1,4 +1,15 @@
 <Project InitialTargets="_OverridePackDependsOnForCsProjToPkgProj">
+  
+  <PropertyGroup Condition="'$(IsPackable)' == 'true'">
+    <TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificAssemblies;LibIntellisenseDocs</TargetsForTfmSpecificContentInPackage>
+    <TargetsForTfmSpecificDebugSymbolsInPackage>$(TargetsForTfmSpecificDebugSymbolsInPackage);AddRuntimeDebugSymbolsWithTfm</TargetsForTfmSpecificDebugSymbolsInPackage>
+    <IncludeBuildOutput Condition="'$(TargetsAnyOS)' != 'true' or '$(ExcludeFromPackage)' == 'true'">false</IncludeBuildOutput>  
+    <!-- Don't include target platform specific dependencies, since we use the target platform to represent RIDs instead -->
+    <SuppressDependenciesWhenPacking Condition="'$(ExcludeFromPackage)' == 'true' or ('$(TargetsAnyOS)' != 'true' and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0')))">true</SuppressDependenciesWhenPacking>
+    <PackageDesignerMarkerFile>$(MSBuildThisFileDirectory)useSharedDesignerContext.txt</PackageDesignerMarkerFile>
+    <PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$([MSBuild]::Subtract($(MajorVersion), 1)).0.0</PackageValidationBaselineVersion>
+  </PropertyGroup>
+
   <!--     There are some packages where we require only one ref for a specific framework to be present. In order to avoid problems with this package when targetting 
            dektop with RAR we will make sure there are no exclude=compile references in the package.
     For more info, please check issues:
     <MSBuild Projects="$(PkgProjPath)"
              Targets="Build" />
   </Target>
+
+  <Target Name="AddRuntimeSpecificAssemblies"
+          DependsOnTargets="BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup;$(TargetsForTfmSpecificBuildOutput)"
+          Condition="'$(TargetsAnyOS)' != 'true' and '$(ExcludeFromPackage)' == ''">
+    <ItemGroup>
+      <TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupOutput);
+                            @(BuiltProjectOutputGroupOutput)">
+        <PackagePath>runtimes/$(_runtimeOS)/lib/$(TargetFrameworkWithoutSuffix)</PackagePath>
+      </TfmSpecificPackageFile>
+    </ItemGroup>
+  </Target>
+
+  <!-- Runtime independent symbols are automatically added by the pack task.-->
+  <Target Name="AddRuntimeDebugSymbolsWithTfm"
+          Condition="'$(IncludeSymbols)' == 'true' and '$(TargetsAnyOS)' != 'true' and '$(ExcludeFromPackage)' == ''">
+    <PropertyGroup>
+      <RuntimeSymbolPath>$([System.IO.Path]::GetDirectoryName($(TargetPath)))\$(TargetName).pdb</RuntimeSymbolPath>
+    </PropertyGroup>
+
+    <ItemGroup Condition="Exists('$(RuntimeSymbolPath)')">
+      <TfmSpecificDebugSymbolsFile Include="$(RuntimeSymbolPath)">
+        <TargetPath>/runtimes/$(_runtimeOS)/lib/$(TargetFrameworkWithoutSuffix)/$(TargetName).pdb</TargetPath>
+        <TargetFramework>$(TargetFrameworkWithoutSuffix)</TargetFramework>
+      </TfmSpecificDebugSymbolsFile>
+    </ItemGroup>
+  </Target>
 </Project>
index 9650ac9..ca21d08 100644 (file)
@@ -13,7 +13,7 @@
   },
   "msbuild-sdks": {
     "Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.21330.3",
-    "Microsoft.DotNet.PackageValidation": "1.0.0-preview.6.21274.7",
+    "Microsoft.DotNet.PackageValidation": "1.0.0-preview.7.21352.4",
     "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21330.2",
     "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21330.2",
     "Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.21330.3",
index b107052..b330933 100644 (file)
@@ -17,7 +17,6 @@
     <NetCoreAppCurrentTestHostPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'testhost', '$(NetCoreAppCurrentBuildSettings)'))</NetCoreAppCurrentTestHostPath>
     <NetCoreAppCurrentTestHostSharedFrameworkPath>$([MSBuild]::NormalizeDirectory('$(NetCoreAppCurrentTestHostPath)', 'shared', '$(MicrosoftNetCoreAppFrameworkName)', '$(ProductVersion)'))</NetCoreAppCurrentTestHostSharedFrameworkPath>
     
-    <TargetsForTfmSpecificContentInPackage Condition="'$(IsPackable)' == 'true'">$(TargetsForTfmSpecificContentInPackage);LibIntellisenseDocs</TargetsForTfmSpecificContentInPackage>
     <SymbolPackageOutputPath>$(PackageOutputPath)</SymbolPackageOutputPath>
 
     <NoWarn Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetFrameworkIdentifier)' == '.NETStandard' or ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '3.0')))">$(NoWarn);nullable</NoWarn>
 
   <Import Sdk="Microsoft.DotNet.PackageValidation" Project="Sdk.targets" Condition="'$(IsSourceProject)' == 'true' and !Exists('$(PkgProjPath)')" />
 
-  <PropertyGroup>
-    <PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$([MSBuild]::Subtract($(MajorVersion), 1)).0.0</PackageValidationBaselineVersion>
-    <EnablePackageBaselineValidation Condition="'$(IsPackable)' == 'true' and '$(MSBuildProjectExtension)' != '.pkgproj' and '$(EnablePackageBaselineValidation)' == ''">true</EnablePackageBaselineValidation>
-  </PropertyGroup>
-
   <Target Name="SetGenApiProperties"
           BeforeTargets="GenerateReferenceAssemblySource">
     <PropertyGroup>
     <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\NullableAttributes.cs" Link="System\Diagnostics\CodeAnalysis\NullableAttributes.cs" />
   </ItemGroup>
 
-  <PropertyGroup Condition="'$(IsCrossTargetingBuild)' != 'true' and '$(DotnetBuildFromSource)' == 'true' and '$(IsPackable)' == 'true' and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)')) and '$(TargetFrameworkIdentifier)' != '.NETStandard' and '$(TargetFrameworkVersion)' != 'v2.0'">
-    <IncludeBuildOutput>false</IncludeBuildOutput>
-    <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
-  </PropertyGroup>
-
   <!-- If a project is downlevel from net5.0 but uses the platform support attributes, then we include the
        System.Runtime.Versioning*Platform* annotation attribute classes in the project as internal.
 
     </ItemGroup>
   </Target>
 
-  <!-- TODO: Remove this after https://github.com/NuGet/NuGet.Client/pull/3980 is merged.-->
-  <Target Name="RemoveXmlFilesFromBuildOutput" BeforeTargets="GenerateNuspec">
-    <PropertyGroup>
-      <AllowedOutputExtensionsInPackageBuildOutputFolder>.dll;.exe;.winmd;.json;.pri;</AllowedOutputExtensionsInPackageBuildOutputFolder> 
-      <AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>.pdb;.mdb;$(AllowedOutputExtensionsInPackageBuildOutputFolder)</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>
-    </PropertyGroup>
-  </Target>
-
   <PropertyGroup>
     <BeforePack>IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
   </PropertyGroup>
diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/src/CompatibilitySuppressions.xml b/src/libraries/Microsoft.Extensions.DependencyModel/src/CompatibilitySuppressions.xml
new file mode 100644 (file)
index 0000000..d088c3c
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <!-- NETFramework,Version=v4.5.1, .NETStandard,Version=v1.3 and NETStandard,Version=v1.6 are out of support and dropped from the package. -->    
+  <Suppression>
+    <DiagnosticId>PKV006</DiagnosticId>
+    <Target>.NETFramework,Version=v4.5.1</Target>
+  </Suppression>
+  <Suppression>
+    <DiagnosticId>PKV006</DiagnosticId>
+    <Target>.NETStandard,Version=v1.3</Target>
+  </Suppression>
+  <Suppression>
+    <DiagnosticId>PKV006</DiagnosticId>
+    <Target>.NETStandard,Version=v1.6</Target>
+  </Suppression>
+</Suppressions>
\ No newline at end of file
index b7ccc5b..81b60b7 100644 (file)
@@ -2,8 +2,6 @@
   <PropertyGroup>
     <TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
     <EnableDefaultItems>true</EnableDefaultItems>
-    <!-- PKV006 is due to intentional removal of .NETFramework,Version=v4.5.1, .NETStandard,Version=v1.3 and NETStandard,Version=v1.6 target frameworks from the package as they are no longer supported. -->
-    <NoWarn>$(NoWarn);PKV006</NoWarn>
     <PackageDescription>Abstractions for reading `.deps` files.
 
 Commonly Used Types:
index 43edfb9..dff9038 100644 (file)
@@ -10,7 +10,7 @@
     <!-- This is a source package which includes all .cs files by default. -->
     <IsSourcePackage>true</IsSourcePackage>
     <!-- This is non-shipping package. -->
-    <EnablePackageBaselineValidation>false</EnablePackageBaselineValidation>
+    <DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
     <PackageDescription>Internal package for sharing Microsoft.Extensions.Hosting.HostFactoryResolver type.</PackageDescription>
   </PropertyGroup>
 </Project>
index 3ef2ef3..acfa86b 100644 (file)
@@ -5,7 +5,7 @@
     <TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461</TargetFrameworks>
     <IsPackable>true</IsPackable>
     <!-- TODO: Remove when the package ships with .NET 6. -->
-    <EnablePackageBaselineValidation>false</EnablePackageBaselineValidation>
+    <DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
     <PackageDescription>Provides non-cryptographic hash algorithms, such as CRC-32.
 
 Commonly Used Types:
diff --git a/src/libraries/System.Windows.Extensions/pkg/System.Windows.Extensions.pkgproj b/src/libraries/System.Windows.Extensions/pkg/System.Windows.Extensions.pkgproj
deleted file mode 100644 (file)
index 240cfdf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<Project DefaultTargets="Build">
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
-  <ItemGroup>
-    <ProjectReference Include="..\ref\System.Windows.Extensions.csproj">
-      <SupportedFramework>netcoreapp3.1</SupportedFramework>
-    </ProjectReference>
-    <ProjectReference Include="..\src\System.Windows.Extensions.csproj" />
-    <!-- Exclude TFMs that aren't supported by the package anymore from validation. -->
-    <ExcludeHarvestedSupportedFramework Include="netcoreapp3.0" />
-  </ItemGroup>
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
-</Project>
\ No newline at end of file
diff --git a/src/libraries/System.Windows.Extensions/src/CompatibilitySuppressions.xml b/src/libraries/System.Windows.Extensions/src/CompatibilitySuppressions.xml
new file mode 100644 (file)
index 0000000..c6379c3
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <!-- .NETCoreapp,Version=v3.0 is out of support and dropped from the package. -->
+  <Suppression>
+    <DiagnosticId>PKV006</DiagnosticId>
+    <Target>.NETCoreapp,Version=v3.0</Target>
+  </Suppression>
+  <Suppression>
+    <DiagnosticId>PKV007</DiagnosticId>
+    <Target>.NETCoreapp,Version=v3.0-win</Target>
+  </Suppression>
+</Suppressions>
\ No newline at end of file
index e995c09..276e986 100644 (file)
@@ -2,6 +2,7 @@
   <PropertyGroup>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);netcoreapp3.1-windows;netcoreapp3.1</TargetFrameworks>
+    <IsPackable>true</IsPackable>
   </PropertyGroup>
   <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
   <PropertyGroup Condition="'$(TargetsWindows)' != 'true'">