Convert AspNetCore transport pkgproj to Pack task (#56674)
authorViktor Hofer <viktor.hofer@microsoft.com>
Mon, 2 Aug 2021 18:53:45 +0000 (20:53 +0200)
committerGitHub <noreply@github.com>
Mon, 2 Aug 2021 18:53:45 +0000 (20:53 +0200)
* Convert AspNetCore transport pkgproj to Pack task

Converting the Microsoft.AspNetCore.Internal.Transport package to a proj
file which uses the NuGet Pack task.

Also moving some more packaging related targets into packaging.targets.

* Update Microsoft.AspNetCore.Internal.Transport.proj

eng/packaging.targets
src/libraries/Directory.Build.targets
src/libraries/Microsoft.AspNetCore.Internal.Transport/pkg/Microsoft.AspNetCore.Internal.Transport.pkgproj [deleted file]
src/libraries/Microsoft.AspNetCore.Internal.Transport/src/Microsoft.AspNetCore.Internal.Transport.proj

index d6344a0..8bf2b09 100644 (file)
@@ -8,8 +8,25 @@
     <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>
+    <BuildAnalyzerReferences>$(BuildProjectReferences)</BuildAnalyzerReferences>
+    <BuildAnalyzerReferences Condition="'$(BuildingInsideVisualStudio)' == 'true'">false</BuildAnalyzerReferences>
   </PropertyGroup>
 
+  <ItemGroup>
+    <!-- Ensure AnalyzerReference items are restored and built
+         The target framework of Analyzers has no relationship to that of the refrencing project,
+         so we don't apply TargetFramework filters nor do we pass in TargetFramework.
+         When BuildProjectReferences=false we make sure to set BuildReference=false to make
+         sure not to try to call GetTargetPath in the outerbuild of the analyzer project. -->
+    <ProjectReference Include="@(AnalyzerReference)"
+                      SkipGetTargetFrameworkProperties="true"
+                      UndefineProperties="TargetFramework"
+                      ReferenceOutputAssembly="false"
+                      PrivateAssets="all"
+                      BuildReference="$(BuildAnalyzerReferences)" />
+  </ItemGroup>
+
   <!--     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:
       </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)" />
+    </ItemGroup>
+  </Target>
+
+  <Target Name="IncludeAnalyzersInPackage" Condition="'@(AnalyzerReference)' != ''">
+    <!-- Call a target in the analyzer project to get all the files it would normally place in a package.
+         These will be returned as items with identity pointing to the built file, and PackagePath metadata
+         set to their location in the package.  IsSymbol metadata will be set to distinguish symbols. -->
+    <MSBuild Projects="@(AnalyzerReference)"
+             Targets="GetAnalyzerPackFiles">
+      <Output TaskParameter="TargetOutputs" ItemName="_AnalyzerFile" />
+    </MSBuild>
+
+    <ItemGroup>
+      <Content Include="@(_AnalyzerFile)" Pack="True" Condition="!%(_AnalyzerFile.IsSymbol)" />
+      <!-- Symbols don't honor PackagePath.  By default they are placed in lib/%(TargetFramework).
+           Pack does honor TargetPath and does Path.Combine("lib/%(TargetFramework)", "%(TargetPath)"),
+           so a rooted path value for TargetPath will override lib.
+           https://github.com/NuGet/Home/issues/10860 -->
+      <_TargetPathsToSymbols Include="@(_AnalyzerFile)" TargetPath="/%(_AnalyzerFile.PackagePath)" Condition="%(_AnalyzerFile.IsSymbol)" />
+    </ItemGroup>
+  </Target>
+
+  <Target Name="GetAnalyzerPackFiles"
+          DependsOnTargets="$(GenerateNuspecDependsOn)"
+          Returns="@(_AnalyzerPackFile)">
+    <PropertyGroup>
+      <_analyzerPath>analyzers/dotnet</_analyzerPath>
+      <_analyzerPath Condition="'$(AnalyzerLanguage)' != ''">$(_analyzerPath)/$(AnalyzerLanguage)</_analyzerPath>
+    </PropertyGroup>
+    <ItemGroup>
+      <_AnalyzerPackFile Include="@(_BuildOutputInPackage)" IsSymbol="false" />
+      <_AnalyzerPackFile Include="@(_TargetPathsToSymbols)" IsSymbol="true" />
+      <_AnalyzerPackFile PackagePath="$(_analyzerPath)/%(TargetPath)" />
+    </ItemGroup>
+    <Error Condition="'%(_AnalyzerPackFile.TargetFramework)' != 'netstandard2.0'"
+           Text="Analyzers must only target netstandard2.0 since they run in the compiler which targets netstandard2.0. The following files were found to target '%(_AnalyzerPackFile.TargetFramework)': @(_AnalyzerPackFile)" />
+  </Target>
 </Project>
index 2e90117..2e0e567 100644 (file)
     </When>
   </Choose>
 
-  <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)" />
-    </ItemGroup>
-  </Target>
-
-  <PropertyGroup>
-    <BeforePack>IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
-    <BuildAnalyzerReferences>$(BuildProjectReferences)</BuildAnalyzerReferences>
-    <BuildAnalyzerReferences Condition="'$(BuildingInsideVisualStudio)' == 'true'">false</BuildAnalyzerReferences>
-  </PropertyGroup>
-
-  <ItemGroup>
-    <!-- Ensure AnalyzerReference items are restored and built
-         The target framework of Analyzers has no relationship to that of the refrencing project,
-         so we don't apply TargetFramework filters nor do we pass in TargetFramework.
-         When BuildProjectReferences=false we make sure to set BuildReference=false to make
-         sure not to try to call GetTargetPath in the outerbuild of the analyzer project. -->
-    <ProjectReference Include="@(AnalyzerReference)" SkipGetTargetFrameworkProperties="true" UndefineProperties="TargetFramework" ReferenceOutputAssembly="false" PrivateAssets="all" BuildReference="$(BuildAnalyzerReferences)"  />
-  </ItemGroup>
-
-  <Target Name="IncludeAnalyzersInPackage" Condition="'@(AnalyzerReference)' != ''">
-    <!-- Call a target in the analyzer project to get all the files it would normally place in a package.
-         These will be returned as items with identity pointing to the built file, and PackagePath metadata
-         set to their location in the package.  IsSymbol metadata will be set to distinguish symbols. -->
-    <MSBuild Projects="@(AnalyzerReference)"
-             Targets="GetAnalyzerPackFiles">
-      <Output TaskParameter="TargetOutputs" ItemName="_AnalyzerFile" />
-    </MSBuild>
-
-    <ItemGroup>
-      <Content Include="@(_AnalyzerFile)" Pack="True" Condition="!%(_AnalyzerFile.IsSymbol)" />
-      <!-- Symbols don't honor PackagePath.  By default they are placed in lib/%(TargetFramework).
-           Pack does honor TargetPath and does Path.Combine("lib/%(TargetFramework)", "%(TargetPath)"),
-           so a rooted path value for TargetPath will override lib.
-           https://github.com/NuGet/Home/issues/10860 -->
-      <_TargetPathsToSymbols Include="@(_AnalyzerFile)" TargetPath="/%(_AnalyzerFile.PackagePath)" Condition="%(_AnalyzerFile.IsSymbol)" />
-    </ItemGroup>
-  </Target>
-
-  <Target Name="GetAnalyzerPackFiles" DependsOnTargets="$(GenerateNuspecDependsOn)" Returns="@(_AnalyzerPackFile)">
-    <PropertyGroup>
-      <_analyzerPath>analyzers/dotnet</_analyzerPath>
-      <_analyzerPath Condition="'$(AnalyzerLanguage)' != ''">$(_analyzerPath)/$(AnalyzerLanguage)</_analyzerPath>
-    </PropertyGroup>
-    <ItemGroup>
-      <_AnalyzerPackFile Include="@(_BuildOutputInPackage)" IsSymbol="false" />
-      <_AnalyzerPackFile Include="@(_TargetPathsToSymbols)" IsSymbol="true" />
-      <_AnalyzerPackFile PackagePath="$(_analyzerPath)/%(TargetPath)" />
-    </ItemGroup>
-    <Error Condition="'%(_AnalyzerPackFile.TargetFramework)' != 'netstandard2.0'"
-           Text="Analyzers must only target netstandard2.0 since they run in the compiler which targets netstandard2.0. The following files were found to target '%(_AnalyzerPackFile.TargetFramework)': @(_AnalyzerPackFile)" />
-  </Target>
-
   <Import Project="$(MSBuildThisFileDirectory)workloads-testing.targets" />
 </Project>
diff --git a/src/libraries/Microsoft.AspNetCore.Internal.Transport/pkg/Microsoft.AspNetCore.Internal.Transport.pkgproj b/src/libraries/Microsoft.AspNetCore.Internal.Transport/pkg/Microsoft.AspNetCore.Internal.Transport.pkgproj
deleted file mode 100644 (file)
index 2304609..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<Project DefaultTargets="Build">
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
-  <PropertyGroup>
-    <SkipPackageFileCheck>true</SkipPackageFileCheck>
-    <SkipValidatePackage>true</SkipValidatePackage>
-    <HarvestStablePackage>false</HarvestStablePackage>
-    <IsShipping>false</IsShipping>
-    <PackageDescription>Internal transport package to provide aspnetcore with the assemblies that make up the Microsoft.ASPNetCore.App shared framework.</PackageDescription>
-  </PropertyGroup>
-  <ItemGroup>
-    <_analyzers Include="$(ASPNETCoreAppPackageRootPath)\analyzers\**\*.*" />
-    <File Include="@(_analyzers)" TargetPath="analyzers\%(RecursiveDir)" />
-    <_libDocs Include="$(ASPNETCoreAppPackageRuntimePath)\*.xml" />
-    <File Include="$(ASPNETCoreAppPackageRefPath)\*.*;@(_libDocs)" TargetPath="ref\$(NetCoreAppCurrent)" />
-    <File Include="$(ASPNETCoreAppPackageRuntimePath)\*.*"  Exclude="@(_libDocs)" TargetPath="lib\$(NetCoreAppCurrent)" />
-  </ItemGroup>
-  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
-</Project>
index 8d90792..8f8f7fe 100644 (file)
@@ -1,6 +1,29 @@
-<Project Sdk="Microsoft.Build.NoTargets">
-  <!-- These are wrapper project files for packaging.-->
+<Project Sdk="Microsoft.Build.NoTargets">
   <PropertyGroup>
-    <TargetFramework>netstandard2.0</TargetFramework>
+    <TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
+    <IsPackable>true</IsPackable>
+    <IsShipping>false</IsShipping>
+    <!-- This is non-shipping package. -->
+    <DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
+    <PackageDescription>Internal transport package to provide aspnetcore with the assemblies that make up the Microsoft.ASPNetCore.App shared framework.</PackageDescription>
+    <!-- Reference elements are missing from the nuspec: https://github.com/NuGet/Home/issues/8684. -->
+    <NoWarn>$(NoWarn);NU5131</NoWarn>
   </PropertyGroup>
-</Project>
\ No newline at end of file
+  
+  <ItemGroup>
+    <_analyzer Include="$(ASPNETCoreAppPackageRootPath)\analyzers\**\*.*" />
+    <_libDoc Include="$(ASPNETCoreAppPackageRuntimePath)\*.xml" />
+
+    <Content Include="@(_analyzer)"
+             Pack="true"
+             PackagePath="analyzers" />
+    <Content Include="$(ASPNETCoreAppPackageRefPath)\*.*;
+                      @(_libDoc)"
+             Pack="true"
+             PackagePath="ref\$(NetCoreAppCurrent)" />
+    <Content Include="$(ASPNETCoreAppPackageRuntimePath)\*.*"
+             Exclude="@(_libDoc)"
+             Pack="true"
+             PackagePath="lib\$(NetCoreAppCurrent)" />
+  </ItemGroup>
+</Project>