Build netcoreapp targeting pack nupkg (dotnet/core-setup#5085)
authorDavis Goodin <dagood@users.noreply.github.com>
Wed, 6 Feb 2019 15:37:51 +0000 (09:37 -0600)
committerGitHub <noreply@github.com>
Wed, 6 Feb 2019 15:37:51 +0000 (09:37 -0600)
* Build netcoreapp targeting pack nupkg

Copies the Microsoft.NETCore.App packaging project and:

Removes package dependencies and runtime.json.

Stops "runtime.<rid>.Microsoft.NETCore.App.Ref" nupkgs from being created.

Moves ref => data.

Sets PackageType to Data.

Includes platform manifest.

Commit migrated from https://github.com/dotnet/core-setup/commit/9ec8e7ea44f00acf1520e558f510fd0dbcb8b8ab

src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.builds [new file with mode: 0644]
src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.pkgproj [new file with mode: 0644]
src/installer/pkg/projects/Microsoft.NETCore.App/Microsoft.NETCore.App.pkgproj
src/installer/pkg/projects/descriptions.json
src/installer/pkg/projects/dir.props
src/installer/pkg/projects/dir.targets
tools-local/tasks/GenerateFileVersionProps.cs

diff --git a/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.builds b/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.builds
new file mode 100644 (file)
index 0000000..74b865c
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <HasRuntimePackages>false</HasRuntimePackages>
+  </PropertyGroup>
+
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+
+  <ItemGroup>
+    <Project Include="$(MSBuildProjectName).pkgproj" />
+  </ItemGroup>
+
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
+</Project>
diff --git a/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.pkgproj b/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.pkgproj
new file mode 100644 (file)
index 0000000..77a83fe
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+
+  <PropertyGroup>
+    <PackageType>Data</PackageType>
+    <Version>$(SharedFrameworkNugetVersion)</Version>
+    <OmitDependencies>true</OmitDependencies>
+    <SkipValidatePackage>true</SkipValidatePackage>
+
+    <!-- Include the platform manifest in the data dir. -->
+    <PlatformManifestTargetPath>data/</PlatformManifestTargetPath>
+
+    <!-- Exclude runtime.json from the package. -->
+    <IncludeRuntimeJson>false</IncludeRuntimeJson>
+    <IsLineupPackage>false</IsLineupPackage>
+
+    <!-- Remove package dependencies. -->
+    <ExcludeLineupReference>true</ExcludeLineupReference>
+    <PackProjectDependencies>false</PackProjectDependencies>
+  </PropertyGroup>
+
+  <!-- Redistribute package content from other nuget packages. -->
+  <ItemGroup>
+    <ProjectReference Include="..\Microsoft.NETCore.App\src\Microsoft.NETCore.App.depproj" />
+  </ItemGroup>
+
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+
+  <Target Name="GetPackageReport" />
+
+  <Target Name="MoveRefToData"
+          AfterTargets="ExpandProjectReferences">
+    <ItemGroup>
+      <!-- Move all refs into the data dir. Leave files like LICENSE.TXT in the root. -->
+      <File
+        Condition="$([System.String]::new('%(File.TargetPath)').StartsWith('ref'))"
+        TargetPath="data/" />
+    </ItemGroup>
+  </Target>
+
+</Project>
index ae1e549..7ca3db2 100644 (file)
@@ -2,21 +2,15 @@
 <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
 
-  <UsingTask TaskName="GenerateFileVersionProps" AssemblyFile="$(LocalBuildToolsTaskDir)core-setup.tasks.dll"/>
-
   <PropertyGroup>
     <Version>$(SharedFrameworkNugetVersion)</Version>
     <OmitDependencies>true</OmitDependencies>
     <SkipValidatePackage>true</SkipValidatePackage>
     <ShouldCreateLayout>false</ShouldCreateLayout>
-    <PropsFile>$(IntermediateOutputPath)$(MSBuildProjectName).props</PropsFile>
-    <PlatformManifestFile>$(IntermediateOutputPath)$(MSBuildProjectName).PlatformManifest.txt</PlatformManifestFile>
     <PreventImplementationReference Condition="'$(PackageTargetRuntime)' != ''">true</PreventImplementationReference>
-    <!-- During an official build when we can guarantee that all RID-specific dependencies have been built,
-         restore all of those dependencies and gather the prospective content of the RID-specific Core.App
-         packages.  This is needed so that we have a complete platform manifest in the shipping version of
-         the Microsoft.NETCore.App (RID-agnostic/identity package). -->
-    <IncludeAllRuntimePackagesInPlatformManifest Condition="'$(BuildFullPlatformManifest)' == 'true'">true</IncludeAllRuntimePackagesInPlatformManifest>
+    <BuildTargetPath>build/$(NETCoreAppFramework)</BuildTargetPath>
+    <PlatformManifestTargetPath>$(BuildTargetPath)</PlatformManifestTargetPath>
+    <FileVersionPropsTargetPath>$(BuildTargetPath)</FileVersionPropsTargetPath>
   </PropertyGroup>
 
   <!-- Identity / Reference package content -->
        <TargetFramework>$(NETCoreAppFramework)</TargetFramework>
     </Dependency>
 
-    <File Include="$(PropsFile)">
-      <TargetPath>build/$(NETCoreAppFramework)</TargetPath>
-    </File>
-    <File Include="$(PlatformManifestFile)">
-      <TargetPath>build/$(NETCoreAppFramework)</TargetPath>
-    </File>
     <File Include="$(MSBuildProjectName).targets">
-      <TargetPath>build/$(NETCoreAppFramework)</TargetPath>
+      <TargetPath>$(BuildTargetPath)</TargetPath>
     </File>
   </ItemGroup>
 
     </ProjectReference>
   </ItemGroup>
 
-  <Target Name="GenerateFileVersionProps" BeforeTargets="GenerateNuSpec" Condition="'$(PackageTargetRuntime)' == ''">
-    <MSBuild Projects="@(ProjectReference)"
-             Condition="'%(ProjectReference.PackageTargetRuntime)' == '$(PackageRID)' OR
-                        '%(ProjectReference.BuidOnRID)' == '$(PackageRID)' OR
-                        ('$(IncludeAllRuntimePackagesInPlatformManifest)' == 'true' AND
-                         '%(ProjectReference.PackageTargetRuntime)' != '' AND
-                         '%(ProjectReference.ExcludeFromPlatformManifest)' != 'true')"
-             Targets="GetPackageFiles">
-      <Output TaskParameter="TargetOutputs" ItemName="SharedFrameworkRuntimeFiles" />
-    </MSBuild>
-
-    <GenerateFileVersionProps Files="@(SharedFrameworkRuntimeFiles)"
-                              PackageId="$(Id)"
-                              PackageVersion="$(Version)"
-                              PlatformManifestFile="$(PlatformManifestFile)"
-                              PropsFile="$(PropsFile)"
-                              PreferredPackages="$(Id);@(RuntimeDependency)" />
-  </Target>
-
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
 
   <Target Name="GetPackageReport" />
index cc5aa5f..6cecbe1 100644 (file)
@@ -1,7 +1,7 @@
 [
     {
         "Name": "RuntimePackage",
-        "Description": "Internal implementation package not meant for direct consumption.  Please do not reference directly.",
+        "Description": "Internal implementation package not meant for direct consumption. Please do not reference directly.",
         "CommonTypes": [ ]
     },
     {
         "Name": "Microsoft.NETCore.App",
         "Description": "A set of .NET APIs that are included in the default .NET Core application model.",
         "CommonTypes": [ ]
+    },
+    {
+        "Name": "Microsoft.NETCore.App.Ref",
+        "Description": "A set of .NET APIs that are included in the default .NET Core application model. Contains reference assemblies, documentation, and other design-time assets.",
+        "CommonTypes": [ ]
     }
 ]
index 9b49bdb..b240b5b 100644 (file)
@@ -16,6 +16,8 @@
 
     <IncludeSourceFilesInPackage Condition="'$(DotNetBuildFromSource)' == 'true'">false</IncludeSourceFilesInPackage>
     <IncludeSourceFilesInPackage Condition="'$(IncludeSourceFilesInPackage)' == ''">true</IncludeSourceFilesInPackage>
+
+    <PackProjectDependencies>true</PackProjectDependencies>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(PackageTargetRuntime)' == ''">
index a34982c..03da4f3 100644 (file)
@@ -1,6 +1,8 @@
 <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="..\dir.targets" />
 
+  <UsingTask TaskName="GenerateFileVersionProps" AssemblyFile="$(LocalBuildToolsTaskDir)core-setup.tasks.dll"/>
+
   <PropertyGroup>
     <RestorePackages>true</RestorePackages>
     <PrereleaseResolveNuGetPackages>true</PrereleaseResolveNuGetPackages>
     </ItemGroup>
   </Target>
 
-  <Target Name="GetDependenciesToPackage" AfterTargets="ExpandProjectReferences">
+  <Target Name="GetDependenciesToPackage"
+          Condition="'$(PackProjectDependencies)' == 'true'"
+          AfterTargets="ExpandProjectReferences">
     <!-- allow projects to provide dependencies -->
     <MSBuild Targets="GetDependenciesToPackage"
              BuildInParallel="$(BuildInParallel)"
     </MSBuild>
   </Target>
 
+  <!--
+    Creates the platform manifest and props file. Set properties "IncludePlatformManifestFile" and
+    "IncludeFileVersionPropsFile" to true to include them, respectively.
+  -->
+  <Target Name="GenerateFileVersionProps">
+    <PropertyGroup>
+      <PropsFile>$(IntermediateOutputPath)$(MSBuildProjectName).props</PropsFile>
+      <PlatformManifestFile>$(IntermediateOutputPath)$(MSBuildProjectName).PlatformManifest.txt</PlatformManifestFile>
+
+      <!-- During an official build when we can guarantee that all RID-specific dependencies have been built,
+          restore all of those dependencies and gather the prospective content of the RID-specific Core.App
+          packages.  This is needed so that we have a complete platform manifest in the shipping version of
+          the Microsoft.NETCore.App (RID-agnostic/identity package). -->
+      <IncludeAllRuntimePackagesInPlatformManifest
+        Condition="'$(IncludeAllRuntimePackagesInPlatformManifest)' == '' AND
+                   '$(BuildFullPlatformManifest)' == 'true'">true</IncludeAllRuntimePackagesInPlatformManifest>
+    </PropertyGroup>
+
+    <MSBuild Projects="@(ProjectReference)"
+             Condition="'%(ProjectReference.PackageTargetRuntime)' == '$(PackageRID)' OR
+                        '%(ProjectReference.BuidOnRID)' == '$(PackageRID)' OR
+                        ('$(IncludeAllRuntimePackagesInPlatformManifest)' == 'true' AND
+                         '%(ProjectReference.PackageTargetRuntime)' != '' AND
+                         '%(ProjectReference.ExcludeFromPlatformManifest)' != 'true')"
+             Targets="GetPackageFiles">
+      <Output TaskParameter="TargetOutputs" ItemName="SharedFrameworkRuntimeFiles" />
+    </MSBuild>
+
+    <GenerateFileVersionProps Files="@(SharedFrameworkRuntimeFiles)"
+                              PackageId="$(Id)"
+                              PackageVersion="$(Version)"
+                              PlatformManifestFile="$(PlatformManifestFile)"
+                              PropsFile="$(PropsFile)"
+                              PreferredPackages="$(Id);@(RuntimeDependency)" />
+  </Target>
+
+  <Target Name="IncludeFileVersionPropsFile"
+          DependsOnTargets="GenerateFileVersionProps"
+          BeforeTargets="GetFiles"
+          Condition="'$(PackageTargetRuntime)' == '' AND '$(FileVersionPropsTargetPath)' != ''">
+    <ItemGroup>
+      <File Include="$(PropsFile)">
+        <TargetPath>$(FileVersionPropsTargetPath)</TargetPath>
+      </File>
+    </ItemGroup>
+  </Target>
+
+  <Target Name="IncludePlatformManifestFile"
+          DependsOnTargets="GenerateFileVersionProps"
+          BeforeTargets="GetFiles"
+          Condition="'$(PackageTargetRuntime)' == '' AND '$(PlatformManifestTargetPath)' != ''">
+    <ItemGroup>
+      <File Include="$(PlatformManifestFile)">
+        <TargetPath>$(PlatformManifestTargetPath)</TargetPath>
+      </File>
+    </ItemGroup>
+  </Target>
+
 </Project>
\ No newline at end of file
index a679f5b..7e89cf6 100644 (file)
@@ -98,6 +98,7 @@ namespace Microsoft.DotNet.Build.Tasks
             var manifestFileName = Path.GetFileName(PlatformManifestFile);
             itemGroup.AddItem(PlatformManifestsItem, $"$(MSBuildThisFileDirectory){manifestFileName}");
 
+            Directory.CreateDirectory(Path.GetDirectoryName(PlatformManifestFile));
             using (var manifestWriter = File.CreateText(PlatformManifestFile))
             {
                 foreach (var fileData in fileVersions)