Set IsPackable and validate PackageDescription (#46329)
authorViktor Hofer <viktor.hofer@microsoft.com>
Tue, 22 Dec 2020 21:41:05 +0000 (22:41 +0100)
committerGitHub <noreply@github.com>
Tue, 22 Dec 2020 21:41:05 +0000 (22:41 +0100)
* Set IsPackable and validate PackageDescription

Directory.Build.props
Directory.Build.targets
eng/packaging.props
eng/packaging.targets
src/libraries/libraries-packages.proj

index 6e8d5c5..5586f44 100644 (file)
@@ -93,6 +93,9 @@
 
     <!-- By default the SDK produces ref assembly for 5.0 or later -->
     <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
+
+    <!-- Set IsPackable true for all pkgproj as Arcade unconditionally overrides the value. -->
+    <IsPackable Condition="'$(MSBuildProjectExtension)' == '.pkgproj'">true</IsPackable>
   </PropertyGroup>
 
   <!-- Language configuration -->
index 7af5848..6b1d210 100644 (file)
@@ -1,5 +1,4 @@
-<Project>
-
+<Project InitialTargets="ErrorForMissingPackageDescription">
   <PropertyGroup>
     <!--
     For non-SDK projects that import this file and then import Microsoft.Common.targets,
     <!-- Keep in sync as required by the Packaging SDK in Arcade. -->
     <Description>$(PackageDescription)</Description>
   </PropertyGroup>
+
+  <!-- Remove when https://github.com/NuGet/Home/issues/10405 is implemented and consumed. -->
+  <Target Name="ErrorForMissingPackageDescription"
+          Condition="'$(IsPackable)' == 'true' and '$(PackageDescription)' == ''">
+    <Error Text="Required property 'PackageDescription' is missing for $(MSBuildProjectName)." />
+  </Target>
 </Project>
\ No newline at end of file
index 07b3879..7d06318 100644 (file)
     <SkipValidatePackage>true</SkipValidatePackage>
   </PropertyGroup>
 
+  <PropertyGroup>
+    <PkgProjPath>$(MSBuildProjectDirectory)\..\pkg\$(MSBuildProjectName).pkgproj</PkgProjPath>
+    <!-- Controls if packages for libraries should be created in (traversal) builds. -->
+    <PackAllLibraries Condition="'$(PackAllLibraries)' == '' and
+                                 ('$(PreReleaseVersionLabel)' != 'servicing' or
+                                  '$(BuildAllProjects)' != 'true')">true</PackAllLibraries>
+    <IsPackable Condition="('$(MSBuildProjectExtension)' == '.pkgproj' or
+                            ('$(IsSourceProject)' == 'true' and Exists('$(PkgProjPath)'))) and
+                           '$(PackAllLibraries)' == 'true'">true</IsPackable>
+  </PropertyGroup>
+
   <Import Condition="Exists('$(PkgDir)baseline\baseline.props') and '$(MSBuildProjectExtension)' == '.pkgproj'" Project="$(PkgDir)baseline\baseline.props" />
 
-  <PropertyGroup Condition="'$(OsEnvironment)'=='Unix'">
+  <PropertyGroup Condition="'$(OsEnvironment)' == 'Unix'">
     <!--
       Building packages fails for two reasons.
       First, nuget doesn't like the paths in the nuspec having backslashes as directory separators.
index 47484ae..30a8caa 100644 (file)
@@ -1,4 +1,4 @@
-<Project>
+<Project InitialTargets="_OverridePackDependsOn">
   <!--     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:
                       '%(Dependency.Identity)' != '_._'" />
   </Target>
 
-  <PropertyGroup>
-    <PkgProjPath>$(MSBuildProjectDirectory)\..\pkg\$(MSBuildProjectName).pkgproj</PkgProjPath>
-    <!-- Point to our custom pack target which builds the pkgproj instead. -->
-    <PackDependsOn Condition="'$(IsSourceProject)' == 'true' and
-                              Exists('$(PkgProjPath)')">_BuildPkgProj</PackDependsOn>
-  </PropertyGroup>
+  <Target Name="_OverridePackDependsOn"
+          Condition="'$(IsSourceProject)' == 'true' and
+                     '$(IsPackable)' == 'true' and
+                     Exists('$(PkgProjPath)')">
+    <PropertyGroup>
+      <!-- Point to the custom pack target which invokes the pkgproj. -->
+      <PackDependsOn>_BuildPkgProj</PackDependsOn>
+    </PropertyGroup>
+  </Target>
 
   <Target Name="_BuildPkgProj">
     <MSBuild Projects="$(PkgProjPath)"
index 1545e5f..491cd14 100644 (file)
@@ -3,7 +3,6 @@
   <PropertyGroup>
     <TraversalGlobalProperties>BuildAllProjects=true</TraversalGlobalProperties>
     <AdditionalBuildTargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">$(AdditionalBuildTargetFrameworks);package-$(Configuration)</AdditionalBuildTargetFrameworks>
-    <BuildAllOOBPackages Condition="'$(BuildAllOOBPackages)' == ''">true</BuildAllOOBPackages>
   </PropertyGroup>
   
   <PropertyGroup>
@@ -15,8 +14,9 @@
 
   <ItemGroup>
     <ProjectReference Include="$(PkgDir)*\*.proj" Exclude="$(PkgDir)test\*" />
-    <ProjectReference Include="$(MSBuildThisFileDirectory)*\src\*.*proj" Condition="('$(BuildAllConfigurations)' == 'true' or '$(DotNetBuildFromSource)' == 'true') And '$(BuildAllOOBPackages)' == 'true'" Exclude="$(MSBuildThisFileDirectory)*\src\**\*.shproj"/>
-    <!-- If setting BuildAllOOBPackages to false, add bellow the individual OOB packages you want to continue to build -->
+    <ProjectReference Include="$(MSBuildThisFileDirectory)*\src\*.*proj"
+                      Condition="('$(BuildAllConfigurations)' == 'true' or '$(DotNetBuildFromSource)' == 'true')"
+                      Exclude="$(MSBuildThisFileDirectory)*\src\**\*.shproj"/>
   </ItemGroup>
 
   <!-- Need the PackageIndexFile file property from baseline.props -->