Fix analyzer, docs file packaging and don't overbuild runtime.native IO.Ports package...
authorViktor Hofer <viktor.hofer@microsoft.com>
Tue, 10 Aug 2021 12:38:45 +0000 (14:38 +0200)
committerGitHub <noreply@github.com>
Tue, 10 Aug 2021 12:38:45 +0000 (14:38 +0200)
* Fix analyzer and docs file packaging

This commit fixes analyzers which were dropped from the package during
the clean-up of pkgprojs and missing documentation files.

1. Analyzers were dropped from the package because the BeforePack
   hook wasn't respected. This happens when the NuGet Pack nuget package
   is referenced which then gets imported before the packaging.targets
   file. The BeforePack property needs to be set in a props file if
   NuGet's targets file isn't used from the SDK but from its package.
2. Documentation files were dropped as the
   DefaultAllowedOutputExtensionsInPackageBuildOutputFolder property
   didn't include the .xml extension.

* Don't overbuild runtime native IO packages

eng/packaging.props
eng/packaging.targets
src/libraries/Directory.Build.props
src/libraries/System.IO.Ports/src/System.IO.Ports.csproj

index 8c4d987..dcaf0ba 100644 (file)
@@ -1,20 +1,9 @@
 <Project>
 
   <PropertyGroup>
-    <DefaultAllowedOutputExtensionsInPackageBuildOutputFolder>.dll;.exe;.winmd;.json;.pri;</DefaultAllowedOutputExtensionsInPackageBuildOutputFolder>
+    <!-- Needs to be set in a props file when package referencing NuGet.Build.Tasks.Pack, as NuGet's targets file is imported before
+         packaging.targets and hence the BeforePack isn't respected. This can be moved back when the PackageReference is removed. -->
+    <BeforePack>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
   </PropertyGroup>
 
-  <ItemGroup>
-    <!-- Add a marker to help the designer optimize & share .NET Core packages -->
-    <None Include="$(PackageDesignerMarkerFile)"
-          PackagePath="$([System.IO.Path]::GetFileName('$(PackageDesignerMarkerFile)'))"
-          Pack="true"
-          Condition="'$(IncludeDesignerMarker)' != 'false'" />
-  </ItemGroup>
-
-  <!-- TODO: Remove when all required nuget pack features are part of the consumed SDK. -->
-  <ItemGroup>
-    <PackageReference Include="NuGet.Build.Tasks.Pack" Version="$(NuGetBuildTasksPackVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
-  </ItemGroup>
-
 </Project>
index 4da9784..ecd2363 100644 (file)
@@ -12,7 +12,6 @@
     <!-- 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>
-    <BeforePack>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
     <!-- Generate packages in the allconfigurations build. -->
     <GeneratePackageOnBuild Condition="'$(BuildAllConfigurations)' == 'true'">true</GeneratePackageOnBuild>
     <!-- Search for the documentation file in the intellisense package and otherwise pick up the generated one. -->
                      Condition="'$(DisablePackageBaselineValidation)' != 'true' and '$(PackageValidationBaselinePath)' == '' and '$(PackageValidationBaselineVersion)' != ''" />
   </ItemGroup>
 
+  <!-- TODO: Remove when all required nuget pack features are part of the consumed SDK. -->
+  <ItemGroup>
+    <PackageReference Include="NuGet.Build.Tasks.Pack" Version="$(NuGetBuildTasksPackVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <!-- Add a marker to help the designer optimize & share .NET Core packages -->
+    <None Include="$(PackageDesignerMarkerFile)"
+          PackagePath="$([System.IO.Path]::GetFileName('$(PackageDesignerMarkerFile)'))"
+          Pack="true"
+          Condition="'$(IncludeDesignerMarker)' != 'false'" />
+  </ItemGroup>
+
   <ItemGroup Condition="'$(AddNETFrameworkAssemblyReferenceToPackage)' == 'true'">
     <_FrameworkAssemblyReferences Include="$(MSBuildProjectName)"
                                   TargetFramework="net461" />
index 2342198..2e52a7c 100644 (file)
@@ -60,7 +60,7 @@
   </ItemGroup>
 
   <Import Project="NetCoreAppLibrary.props" />
-  <Import Project="$(RepositoryEngineeringDir)packaging.props" Condition="'$(IsPackable)' == 'true'" />
+  <Import Project="$(RepositoryEngineeringDir)packaging.props" Condition="'$(IsSourceProject)' == 'true'" />
   <Import Project="$(RepositoryEngineeringDir)referenceAssemblies.props" Condition="'$(IsReferenceAssembly)' == 'true'" />
   <Import Project="$(RepositoryEngineeringDir)targetframeworksuffix.props" Condition="'$(DesignTimeBuild)' != 'true'" />
 
index 024a193..e017d4d 100644 (file)
@@ -153,10 +153,10 @@ System.IO.Ports.SerialPort</PackageDescription>
   </ItemGroup>
 
   <ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
-    <!-- Just reference the runtime meta package but don't build it to avoid unintentional Build/Pack invocations. -->
-    <ProjectReference Include="..\pkg\runtime.native.$(MSBuildProjectName).proj" />
+    <!-- Just reference the runtime packages but don't build them in order to avoid unintentional Build/Pack invocations. -->
+    <ProjectReference Include="..\pkg\runtime.native.$(MSBuildProjectName).proj" BuildReference="false" />
     <!-- Make the runtime specific packages non transitive so that they aren't flowing into other projects. -->
-    <ProjectReference Include="..\pkg\runtime.*.runtime.native.$(MSBuildProjectName).proj" PrivateAssets="all" />
+    <ProjectReference Include="..\pkg\runtime.*.runtime.native.$(MSBuildProjectName).proj" BuildReference="false" PrivateAssets="all" />
   </ItemGroup>
 
   <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">