Skip to content

Commit

Permalink
Add Csproj pack infra for packages with ref and runtime assemblies an…
Browse files Browse the repository at this point in the history
…d symbols. (dotnet#54250)

* 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
  • Loading branch information
Anipik authored Jul 2, 2021
1 parent bbb7d90 commit b26d811
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 41 deletions.
2 changes: 2 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 6 additions & 4 deletions eng/packaging.props
Original file line number Diff line number Diff line change
Expand Up @@ -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'">
Expand All @@ -29,10 +30,6 @@

<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)"
Expand All @@ -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>
37 changes: 37 additions & 0 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -42,4 +53,30 @@
<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>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 0 additions & 19 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -145,11 +144,6 @@

<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>
Expand Down Expand Up @@ -235,11 +229,6 @@
<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.
Expand Down Expand Up @@ -292,14 +281,6 @@
</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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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'">
Expand Down

0 comments on commit b26d811

Please sign in to comment.