Skip to content

Commit

Permalink
Replace all remaining pkgprojs with NuGet Pack task (dotnet#56712)
Browse files Browse the repository at this point in the history
* Runtime specific and doc file packaging fixes

* Replace all remaining pkgprojs with NuGet Pack task

* Avoid NuGet/Home/issues/10368

* Update PackageValidation package to latest
  • Loading branch information
ViktorHofer authored Aug 5, 2021
1 parent 81b6502 commit 503ae51
Show file tree
Hide file tree
Showing 214 changed files with 1,770 additions and 2,052 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
<SuppressFinalPackageVersion Condition="'$(SuppressFinalPackageVersion)' == '' and ($(IsExperimentalAssembly) or $(IsPrivateAssembly))">true</SuppressFinalPackageVersion>
<IsShippingAssembly Condition="$(IsExperimentalAssembly)">false</IsShippingAssembly>
<!-- We don't want Private packages to be shipped to NuGet.org -->
<IsShippingPackage Condition="($(MSBuildProjectName.Contains('Private')) or $(IsExperimentalAssembly)) and '$(MSBuildProjectExtension)' == '.pkgproj'">false</IsShippingPackage>
<IsShippingPackage Condition="$(MSBuildProjectName.Contains('Private')) or $(IsExperimentalAssembly)">false</IsShippingPackage>
<!-- A package isn't generated if in servicing or in runtimelab. Intended to be overridden at project level.
Excluding .sfxprojs as they have their own incremental servicing infra. -->
<GeneratePackage Condition="'$(GeneratePackage)' == ''">true</GeneratePackage>
Expand Down
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.10.0</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisCSharpVersion>3.10.0</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-rc1.21375.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
<!-- SDK dependencies -->
<MicrosoftDotNetPackageValidationVersion>1.0.0-rc.1.21404.21</MicrosoftDotNetPackageValidationVersion>
<!-- Arcade dependencies -->
<MicrosoftDotNetApiCompatVersion>6.0.0-beta.21373.11</MicrosoftDotNetApiCompatVersion>
<MicrosoftDotNetBuildTasksFeedVersion>6.0.0-beta.21373.11</MicrosoftDotNetBuildTasksFeedVersion>
Expand Down
125 changes: 92 additions & 33 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
@@ -1,16 +1,55 @@
<Project InitialTargets="_OverridePackDependsOnForCsProjToPkgProj">

<PropertyGroup Condition="'$(IsPackable)' == 'true'">
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificAssemblies;LibIntellisenseDocs</TargetsForTfmSpecificContentInPackage>
<TargetsForTfmSpecificDebugSymbolsInPackage>$(TargetsForTfmSpecificDebugSymbolsInPackage);AddRuntimeDebugSymbolsWithTfm</TargetsForTfmSpecificDebugSymbolsInPackage>
<EnablePackageValidation Condition="'$(IsSourceProject)' == 'true' and !Exists('$(PkgProjPath)')">true</EnablePackageValidation>
<!-- Don't restore prebuilt packages during sourcebuild. -->
<DisablePackageBaselineValidation Condition="'$(DotNetBuildFromSource)' == 'true'">true</DisablePackageBaselineValidation>
<PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$([MSBuild]::Subtract($(MajorVersion), 1)).0.0</PackageValidationBaselineVersion>
<SymbolPackageOutputPath>$(PackageOutputPath)</SymbolPackageOutputPath>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddDocumentationFileToPackage;AddRuntimeSpecificFilesToPackage</TargetsForTfmSpecificContentInPackage>
<TargetsForTfmSpecificDebugSymbolsInPackage>$(TargetsForTfmSpecificDebugSymbolsInPackage);AddRuntimeSpecificSymbolToPackage</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>
<BeforePack>IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
<GenerateNuspecDependsOn>IncludeAnalyzersInPackage;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn>
</PropertyGroup>

<ItemGroup Condition="'$(EnablePackageValidation)' == 'true'">
<PackageReference Include="Microsoft.DotNet.PackageValidation" Version="$(MicrosoftDotNetPackageValidationVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
<!-- TODO: Remove when the SDK is upgraded to RC1. -->
<PackageDownload Include="$([MSBuild]::ValueOrDefault('$(PackageValidationBaselineName)', '$(PackageId)'))"
Version="[$(PackageValidationBaselineVersion)]"
Condition="'$(DisablePackageBaselineValidation)' != 'true' and '$(PackageValidationBaselinePath)' == '' and '$(PackageValidationBaselineVersion)' != ''" />
</ItemGroup>

<ItemGroup Condition="'$(AddNETFrameworkAssemblyReferenceToPackage)' == 'true'">
<_FrameworkAssemblyReferences Include="$(MSBuildProjectName)"
TargetFramework="net461" />
</ItemGroup>

<Choose>
<When Condition="'$(IsPackable)' == 'true' and
('$(AddXamarinPlaceholderFilesToPackage)' == 'true' or '$(AddNETFrameworkPlaceholderFileToPackage)' == 'true')">
<PropertyGroup>
<!-- Placeholders don't need a dependency group. -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
</PropertyGroup>
<ItemGroup Condition="'$(AddNETFrameworkPlaceholderFileToPackage)' == 'true'">
<None Include="$(PlaceholderFile)" PackagePath="lib/net461" Pack="true" />
<None Include="$(PlaceholderFile)" PackagePath="runtimes/win/lib/net461" Pack="true" Condition="$(TargetFrameworks.Contains('netstandard2.0-windows'))" />
</ItemGroup>
<ItemGroup Condition="'$(AddXamarinPlaceholderFilesToPackage)' == 'true'">
<None Include="$(PlaceholderFile)" PackagePath="lib\MonoAndroid10" Pack="true" />
<None Include="$(PlaceholderFile)" PackagePath="lib\MonoTouch10" Pack="true" />
<None Include="$(PlaceholderFile)" PackagePath="lib\xamarinios10" Pack="true" />
<None Include="$(PlaceholderFile)" PackagePath="lib\xamarinmac20" Pack="true" />
<None Include="$(PlaceholderFile)" PackagePath="lib\xamarintvos10" Pack="true" />
<None Include="$(PlaceholderFile)" PackagePath="lib\xamarinwatchos10" Pack="true" />
</ItemGroup>
</When>
</Choose>

<!-- 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 All @@ -22,7 +61,7 @@
<Dependency>
<Exclude></Exclude>
</Dependency>
</ItemGroup>
</ItemGroup>
</Target>

<Target Name="ValidateExcludeCompileDesktop"
Expand Down Expand Up @@ -55,42 +94,62 @@
Targets="Build" />
</Target>

<Target Name="AddRuntimeSpecificAssemblies"
DependsOnTargets="BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup;$(TargetsForTfmSpecificBuildOutput)"
Condition="'$(TargetsAnyOS)' != 'true' and '$(ExcludeFromPackage)' == ''">
<Target Name="AddDocumentationFileToPackage"
Condition="'$(ExcludeFromPackage)' != 'true'">
<PropertyGroup>
<!-- Search for the documentation file in the intellisense package and otherwise pick up the generated one. -->
<_documentationFileToPackage Condition="Exists('$(XmlDocFileRoot)1033\$(TargetName).xml')">$(XmlDocFileRoot)1033\$(TargetName).xml</_documentationFileToPackage>
<_documentationFileToPackage Condition="'$(_documentationFileToPackage)' == '' and Exists('$(DocumentationFile)')">$(DocumentationFile)</_documentationFileToPackage>
</PropertyGroup>
<ItemGroup Condition="'$(_documentationFileToPackage)' != ''">
<!-- Place the documentation file into the lib or runtimes/lib folder depending on if the build is runtime agnostic or specific. -->
<TfmSpecificPackageFile Include="$(_documentationFileToPackage)"
PackagePath="$([MSBuild]::ValueOrDefault('$(BuildOutputTargetFolder)', 'lib'))/$(TargetFrameworkWithoutSuffix)"
Condition="'$(TargetsAnyOS)' == 'true'" />
<TfmRuntimeSpecificPackageFile Include="$(_documentationFileToPackage)"
Condition="'$(TargetsAnyOS)' != 'true'" />
</ItemGroup>
</Target>

<Target Name="AddRuntimeSpecificFilesToPackage"
DependsOnTargets="BuiltProjectOutputGroup;
SatelliteDllsProjectOutputGroup;
$(TargetsForTfmSpecificBuildOutput);
AddDocumentationFileToPackage"
Condition="'$(ExcludeFromPackage)' != 'true' and
'$(TargetsAnyOS)' != 'true'">
<ItemGroup>
<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupOutput);
@(BuiltProjectOutputGroupOutput)">
<PackagePath>runtimes/$(_runtimeOS)/lib/$(TargetFrameworkWithoutSuffix)</PackagePath>
</TfmSpecificPackageFile>
<TfmRuntimeSpecificPackageFile Include="@(BuiltProjectOutputGroupOutput);
@(SatelliteDllsProjectOutputGroupOutput)" />
<TfmSpecificPackageFile Include="@(TfmRuntimeSpecificPackageFile)"
PackagePath="runtimes/$(PackageTargetRuntime)/lib/$(TargetFrameworkWithoutSuffix)" />
<!-- Copy runtime specific assemblies into the rid agnostic 'lib' folder if the ridless tfm doesn't exist on .NETFramework.
The assumption holds that a ridless tfm doesn't follow a '-' charater. This is necessary to avoid NU5128. -->
<TfmSpecificPackageFile Include="@(TfmRuntimeSpecificPackageFile)"
PackagePath="$([MSBuild]::ValueOrDefault('$(BuildOutputTargetFolder)', 'lib'))/$(TargetFrameworkWithoutSuffix)"
Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and !$([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFrameworks)', '$(TargetFrameworkWithoutSuffix)(?!-)'))" />
</ItemGroup>
</Target>

<!-- Runtime independent symbols are automatically added by the pack task.-->
<Target Name="AddRuntimeDebugSymbolsWithTfm"
Condition="'$(IncludeSymbols)' == 'true' and '$(TargetsAnyOS)' != 'true' and '$(ExcludeFromPackage)' == ''">
<!-- Runtime agnostic symbols are automatically added by the pack task.-->
<Target Name="AddRuntimeSpecificSymbolToPackage"
Condition="'$(ExcludeFromPackage)' != 'true' and
'$(TargetsAnyOS)' != 'true' and
'$(IncludeSymbols)' == 'true'">
<PropertyGroup>
<RuntimeSymbolPath>$([System.IO.Path]::GetDirectoryName($(TargetPath)))\$(TargetName).pdb</RuntimeSymbolPath>
<RuntimeSymbolPath>$(TargetDir)$(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>

<Target Name="LibIntellisenseDocs"
Condition="'$(IncludeBuildOutput)' == 'true'">
<PropertyGroup>
<_intellisenseRootFolder>$(BuildOutputTargetFolder)</_intellisenseRootFolder>
<_intellisenseRootFolder Condition="'$(_intellisenseRootFolder)' == ''">lib</_intellisenseRootFolder>
</PropertyGroup>
<ItemGroup>
<TfmSpecificPackageFile Include="$(XmlDocFileRoot)1033\$(TargetName).xml"
Condition="Exists('$(XmlDocFileRoot)1033\$(TargetName).xml')"
PackagePath="$(_intellisenseRootFolder)/$(TargetFramework)" />
<TfmSpecificDebugSymbolsFile Include="$(RuntimeSymbolPath)"
TargetPath="/runtimes/$(PackageTargetRuntime)/lib/$(TargetFrameworkWithoutSuffix)"
TargetFramework="$(TargetFrameworkWithoutSuffix)" />
<!-- Copy runtime specific symbol into the rid agnostic 'lib' folder if the ridless tfm doesn't exist on .NETFramework.
The assumption holds that a ridless tfm doesn't follow a '-' charater. This is necessary to avoid NU5128. -->
<TfmSpecificDebugSymbolsFile Include="$(RuntimeSymbolPath)"
TargetPath="/$([MSBuild]::ValueOrDefault('$(BuildOutputTargetFolder)', 'lib'))/$(TargetFrameworkWithoutSuffix)"
TargetFramework="$(TargetFrameworkWithoutSuffix)"
Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and !$([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFrameworks)', '$(TargetFrameworkWithoutSuffix)(?!-)'))" />
</ItemGroup>
</Target>

Expand Down
1 change: 0 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
},
"msbuild-sdks": {
"Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.21373.11",
"Microsoft.DotNet.PackageValidation": "1.0.0-preview.7.21352.4",
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21373.11",
"Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21373.11",
"Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.21373.11",
Expand Down
2 changes: 0 additions & 2 deletions src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
<!-- Import packaging props -->
<Import Project="$(RepositoryEngineeringDir)packaging.props" />

<Import Sdk="Microsoft.DotNet.PackageValidation" Project="Sdk.props" Condition="'$(IsSourceProject)' == 'true'" />

<PropertyGroup>
<RefRootPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'ref'))</RefRootPath>
</PropertyGroup>
Expand Down
7 changes: 1 addition & 6 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
<Import Project="..\..\Directory.Build.targets" />

<PropertyGroup>
<GenerateNuspecDependsOn>IncludeAnalyzersInPackage;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn>
<NetCoreAppCurrentBuildSettings>$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture)</NetCoreAppCurrentBuildSettings>
<NativeBinDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'native', '$(NetCoreAppCurrentBuildSettings)'))</NativeBinDir>
<NetCoreAppCurrentTestHostPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'testhost', '$(NetCoreAppCurrentBuildSettings)'))</NetCoreAppCurrentTestHostPath>
<NetCoreAppCurrentTestHostSharedFrameworkPath>$([MSBuild]::NormalizeDirectory('$(NetCoreAppCurrentTestHostPath)', 'shared', '$(MicrosoftNetCoreAppFrameworkName)', '$(ProductVersion)'))</NetCoreAppCurrentTestHostSharedFrameworkPath>

<SymbolPackageOutputPath>$(PackageOutputPath)</SymbolPackageOutputPath>

<NoWarn Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetFrameworkIdentifier)' == '.NETStandard' or ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '3.0')))">$(NoWarn);nullable</NoWarn>
<NoWarn Condition="'$(GeneratePlatformNotSupportedAssembly)' == 'true' or '$(GeneratePlatformNotSupportedAssemblyMessage)' != ''">$(NoWarn);nullable;CA1052</NoWarn>
<!-- Ignore Obsolete errors within the generated shims that type-forward types.
Expand All @@ -43,7 +40,7 @@
<!-- Reset these properties back to blank, since they are defaulted by Microsoft.NET.Sdk -->
<WarningsAsErrors Condition="'$(WarningsAsErrors)' == 'NU1605'" />
<!-- Set the documentation output file globally. -->
<DocumentationFile Condition="'$(IsSourceProject)' == 'true' and '$(DocumentationFile)' == '' and '$(MSBuildProjectExtension)' != '.vbproj'">$(OutputPath)$(MSBuildProjectName).xml</DocumentationFile>
<DocumentationFile Condition="'$(IsSourceProject)' == 'true' and '$(DocumentationFile)' == '' and '$(MSBuildProjectExtension)' != '.vbproj'">$(OutputPath)$(TargetName).xml</DocumentationFile>
<IsNETCoreAppSrc Condition="'$(IsNETCoreAppSrc)' == '' and
'$(IsSourceProject)' == 'true' and
$(NetCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsNETCoreAppSrc>
Expand Down Expand Up @@ -151,8 +148,6 @@
<PackageReference Include="Microsoft.DotNet.GenFacades" Version="$(MicrosoftDotNetGenFacadesVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
</ItemGroup>

<Import Sdk="Microsoft.DotNet.PackageValidation" Project="Sdk.targets" Condition="'$(IsSourceProject)' == 'true' and !Exists('$(PkgProjPath)')" />

<Target Name="SetGenApiProperties"
BeforeTargets="GenerateReferenceAssemblySource">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,5 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Open</StrongNameKeyId>
<!-- This assembly should never be placed inbox as it is only for downlevel compatibility. -->
<PackageDescription>Provides the IAsyncEnumerable&lt;T&gt; and IAsyncDisposable interfaces and helper types for .NET Standard 2.0. This package is not required starting with .NET Standard 2.1 and .NET Core 3.0.

Commonly Used Types:
System.IAsyncDisposable
System.Collections.Generic.IAsyncEnumerable
System.Collections.Generic.IAsyncEnumerator</PackageDescription>
</PropertyGroup>
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Left>lib/netstandard2.0/Microsoft.Bcl.AsyncInterfaces.dll</Left>
<Right>lib/netstandard2.1/Microsoft.Bcl.AsyncInterfaces.dll</Right>
</Suppression>
</Suppressions>
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<IsPackable>true</IsPackable>
<!-- This assembly should never be placed inbox as it is only for downlevel compatibility. -->
<PackageDescription>Provides the IAsyncEnumerable&lt;T&gt; and IAsyncDisposable interfaces and helper types for .NET Standard 2.0. This package is not required starting with .NET Standard 2.1 and .NET Core 3.0.

Commonly Used Types:
System.IAsyncDisposable
System.Collections.Generic.IAsyncEnumerable
System.Collections.Generic.IAsyncEnumerator</PackageDescription>
</PropertyGroup>
<PropertyGroup>
<IsPartialFacadeAssembly Condition="'$(TargetFramework)' == 'netstandard2.1'">true</IsPartialFacadeAssembly>
Expand Down Expand Up @@ -33,8 +41,9 @@
<Link>System.Private.CoreLib\System\Runtime\CompilerServices\EnumeratorCancellationAttribute.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.1'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="$(SystemThreadingTasksExtensionsVersion)" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj" />
<!-- S.R.C.Unsafe isn't a primary but transitive dependency and this P2P makes sure that the live version is used. -->
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj" PrivateAssets="all" />
</ItemGroup>
</Project>
Loading

0 comments on commit 503ae51

Please sign in to comment.