[dev/arcade-migration] Fix package and shared framework diffs (dotnet/core-setup...
authorDavis Goodin <dagood@users.noreply.github.com>
Thu, 18 Jul 2019 19:31:57 +0000 (14:31 -0500)
committerGitHub <noreply@github.com>
Thu, 18 Jul 2019 19:31:57 +0000 (14:31 -0500)
* Always include CoreCLR in NCA versions txt file

This makes it appear where it's expected. It shouldn't be a problem that it now appears in a package that doesn't truly use CoreCLR. If anything, it makes it easier to find, which could be useful.

* Fix M.NETCore.App.Internal build file differences

Fix GetDependencyDataFileInclusionDefaults to actually affect the condition.

Use a template for the props file and have each pkgproj fill it, so that each pkgproj can configure it. Use non-".Internal" name to refer to platform manifest to keep that filename consistent.

* Fix latest commit usage

* Fix names of deps.json and runtimeconfig.json

* Remove Packaging tools package from sfx deps json

* Add comment about props file placeholders

Commit migrated from https://github.com/dotnet/core-setup/commit/32d0950119e1537f136efc5ee5bb13b800f4bda0

src/installer/pkg/Directory.Build.props
src/installer/pkg/packaging-tools/framework.dependency.props [new file with mode: 0644]
src/installer/pkg/packaging-tools/framework.dependency.targets
src/installer/pkg/packaging-tools/framework.packaging.props [new file with mode: 0644]
src/installer/pkg/packaging-tools/framework.sharedfx.props
src/installer/pkg/packaging-tools/framework.sharedfx.targets
src/installer/pkg/packaging-tools/packaging-tools.props
src/installer/pkg/packaging-tools/packaging-tools.targets
src/installer/pkg/projects/Directory.Build.targets
src/installer/pkg/projects/netcoreapp/src/netcoreapp.depproj

index 48b51e9..7c741f2 100644 (file)
     <SkipIndexCheck>true</SkipIndexCheck>
   </PropertyGroup>
 
-  <ItemGroup>
-    <PackageReference Include="Microsoft.DotNet.Build.Tasks.Packaging" Version="$(MicrosoftDotNetBuildTasksPackagingPackageVersion)" />
-  </ItemGroup>
-
   <PropertyGroup>
     <PackagingToolsDir>$(MSBuildThisFileDirectory)packaging-tools/</PackagingToolsDir>
 
diff --git a/src/installer/pkg/packaging-tools/framework.dependency.props b/src/installer/pkg/packaging-tools/framework.dependency.props
new file mode 100644 (file)
index 0000000..8ac7169
--- /dev/null
@@ -0,0 +1,10 @@
+<Project>
+  <!--
+    Shared properties specific to dependency projects (depproj).
+  -->
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.DotNet.Build.Tasks.Packaging" Version="$(MicrosoftDotNetBuildTasksPackagingPackageVersion)" />
+  </ItemGroup>
+
+</Project>
index 14f18e3..2b48826 100644 (file)
@@ -68,7 +68,9 @@
 
   <!-- Creates the *.versions.txt file describing where data in this package came from. -->
   <Target Name="GenerateHashVersionsFile"
-          DependsOnTargets="GetDependencyVersionFiles"
+          DependsOnTargets="
+            GetDependencyVersionFiles;
+            GetLatestCommit"
           Condition="'$(FrameworkPackageName)' != ''">
     <Error
       Condition="'@(DependencyVersionFile)' != '' AND !Exists('%(DependencyVersionFile.Identity)')"
@@ -91,8 +93,8 @@
   <Target Name="SetupGenerateFileVersionProps"
           Condition="'$(FrameworkPackageName)' != ''">
     <PropertyGroup>
-      <PropsFile>$(IntermediateOutputPath)$(MSBuildProjectName).props</PropsFile>
-      <PlatformManifestFile>$(IntermediateOutputPath)$(MSBuildProjectName).PlatformManifest.txt</PlatformManifestFile>
+      <PropsFile>$(IntermediateOutputPath)$(FrameworkPackageName).props</PropsFile>
+      <PlatformManifestFile>$(IntermediateOutputPath)$(FrameworkPackageName).PlatformManifest.txt</PlatformManifestFile>
     </PropertyGroup>
 
     <ItemGroup>
       <PermitDllAndExeFilesLackingFileVersion>true</PermitDllAndExeFilesLackingFileVersion>
     </PropertyGroup>
 
+    <!--
+      Generate the props file using placeholders for __PackageId__ and __PreferredPackages__. Each
+      pkgproj that depends on this depproj needs to fill it in with unique info. The depproj's copy
+      of the props file is considered a template. The tokens use underscores because the PackageId
+      string needs to be valid XML.
+    -->
     <GenerateFileVersionProps Files="@(SharedFrameworkRuntimeFiles)"
-                              PackageId="$(FrameworkPackageName)"
+                              PackageId="__PackageId__"
                               PackageVersion="$(Version)"
                               PlatformManifestFile="$(PlatformManifestFile)"
                               PropsFile="$(PropsFile)"
-                              PreferredPackages="$(Id);@(RuntimeDependency)"
+                              PreferredPackages="__PreferredPackages__"
                               PermitDllAndExeFilesLackingFileVersion="$(PermitDllAndExeFilesLackingFileVersion)" />
   </Target>
 
diff --git a/src/installer/pkg/packaging-tools/framework.packaging.props b/src/installer/pkg/packaging-tools/framework.packaging.props
new file mode 100644 (file)
index 0000000..672ed07
--- /dev/null
@@ -0,0 +1,10 @@
+<Project>
+  <!--
+    Shared properties specific to packaging projects (pkgproj).
+  -->
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.DotNet.Build.Tasks.Packaging" Version="$(MicrosoftDotNetBuildTasksPackagingPackageVersion)" />
+  </ItemGroup>
+
+</Project>
index ddd7592..0293dd9 100644 (file)
@@ -7,8 +7,6 @@
     <TargetFramework>$(NETCoreAppFramework)</TargetFramework>
     <PackageId>unused</PackageId>
 
-    <ProjectDepsFileName>$(SharedFrameworkName).deps.json</ProjectDepsFileName>
-
     <!--
       When blank, MicrosoftNETPlatformLibrary defaults to Microsoft.NETCore.App. This property
       causes the SDK to trim dependencies when publishing a framework-dependent app. We want to be
index 1ccad24..7fa7e5d 100644 (file)
     </PropertyGroup>
 
     <WriteLinesToFile
-      File="$(PublishDir)$(MSBuildProjectName).runtimeconfig.json"
+      File="$(PublishDir)$(SfxIdentity).runtimeconfig.json"
       Lines="$(_runtimeConfigContent)"
       Overwrite="true" />
   </Target>
 
   <Target Name="GenerateVersionFile"
-          DependsOnTargets="GetPackageReference"
+          DependsOnTargets="
+            GetPackageReference;
+            GetLatestCommitFromPkgproj"
           BeforeTargets="Publish">
     <!-- Generate .version file -->
     <ItemGroup>
   </Target>
 
   <!--
+    This project doesn't have access to SourceLink because Restore happened in the same MSBuild
+    context and the generated NuGet props haven't applied. Call into a pkgproj to get this info.
+  -->
+  <Target Name="GetLatestCommitFromPkgproj">
+    <PropertyGroup>
+      <OnePkgProjectReference>%(PkgProjectReference.Identity)</OnePkgProjectReference>
+    </PropertyGroup>
+
+    <MSBuild Projects="$(OnePkgProjectReference)" Targets="ReturnLatestCommit">
+      <Output TaskParameter="TargetOutputs" PropertyName="LatestCommit" />
+    </MSBuild>
+  </Target>
+
+  <!--
     NETCoreApp (and only NETCoreApp) carries the host and host resolver in the shared framework,
     which lives outside the shared/ directory. These were included in publish through package
     references and the files must be moved.
     <Copy SourceFiles="@(SharedFrameworkSymbols)" DestinationFolder="$(SharedFrameworkPublishSymbolsDir)" />
   </Target>
 
+  <Target Name="FixDepsJsonFileName"
+          AfterTargets="Publish">
+    <PropertyGroup>
+      <SharedFrameworkDepsOriginFile>$(PublishDir)$(ProjectDepsFileName)</SharedFrameworkDepsOriginFile>
+      <SharedFrameworkDepsDestinationFile>$(PublishDir)$(SfxIdentity).deps.json</SharedFrameworkDepsDestinationFile>
+    </PropertyGroup>
+
+    <Move
+      SourceFiles="$(SharedFrameworkDepsOriginFile)"
+      DestinationFiles="$(SharedFrameworkDepsDestinationFile)" />
+  </Target>
+
   <Target Name="GenerateRuntimeGraph"
           Condition="'$(GenerateRuntimeGraph)' == 'true'"
+          DependsOnTargets="FixDepsJsonFileName"
           AfterTargets="Publish">
     <PropertyGroup>
-      <SharedFrameworkDepsFile>$(PublishDir)$(ProjectDepsFileName)</SharedFrameworkDepsFile>
       <RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='Windows_NT'">win</RuntimeGraphGeneratorRuntime>
       <RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='OSX'">osx</RuntimeGraphGeneratorRuntime>
       <RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='FreeBSD'">freebsd</RuntimeGraphGeneratorRuntime>
     </ItemGroup>
 
     <ProcessSharedFrameworkDeps AssetsFilePath="$(ProjectAssetsFile)"
-                                DepsFilePath="$(SharedFrameworkDepsFile)"
+                                DepsFilePath="$(SharedFrameworkDepsDestinationFile)"
                                 PackagesToRemove="@(TrimPkgsFromDeps)"
                                 Runtime="$(RuntimeGraphGeneratorRuntime)"
                                 BuildTasksAssemblyPath="$(PackagingTaskDir)Microsoft.DotNet.Build.Tasks.Packaging.dll" />
index e58a878..83633db 100644 (file)
@@ -1,5 +1,7 @@
 <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 
+  <Import Project="framework.dependency.props" Condition="'$(MSBuildProjectExtension)' == '.depproj'" />
+  <Import Project="framework.packaging.props" Condition="'$(MSBuildProjectExtension)' == '.pkgproj'" />
   <Import Project="framework.sharedfx.props" Condition="'$(MSBuildProjectExtension)' == '.sfxproj'" />
 
   <PropertyGroup>
index dd3c4cc..853f605 100644 (file)
     </PropertyGroup>
   </Target>
 
+  <Target Name="GetLatestCommit"
+          DependsOnTargets="InitializeSourceControlInformationFromSourceControlManager">
+    <PropertyGroup>
+      <LatestCommit Condition="'$(LatestCommit)' == ''">$(SourceRevisionId)</LatestCommit>
+    </PropertyGroup>
+  </Target>
+
+  <Target Name="ReturnLatestCommit"
+          DependsOnTargets="GetLatestCommit"
+          Returns="$(LatestCommit)" />
+
+  <!-- Override pkgproj tool target to provide commit info. -->
+  <Target Name="GetSyncInfo"
+          DependsOnTargets="GetLatestCommit">
+    <ItemGroup>
+      <SyncInfoLines Include="$(LatestCommit)" />
+    </ItemGroup>
+  </Target>
+
   <!--
     By default, shared frameworks are generated based on the package. This can be overridden by the
     project, and in the future, the runtime pack is likely to be used to assemble the sfx.
index 7a6fb2d..8d9d6a8 100644 (file)
   <Target Name="GetDependencyDataFileInclusionDefaults">
     <PropertyGroup Condition="'$(BuildTargetPath)' != ''">
       <FileVersionPropsTargetPath Condition="'$(FileVersionPropsTargetPath)' == ''">$(BuildTargetPath)$(Id).props</FileVersionPropsTargetPath>
-      <PlatformManifestTargetPath Condition="'$(PlatformManifestTargetPath)' == ''">$(BuildTargetPath)$(Id).props</PlatformManifestTargetPath>
+      <PlatformManifestTargetPath Condition="'$(PlatformManifestTargetPath)' == ''">$(BuildTargetPath)$(Id.Replace('.Internal', '')).PlatformManifest.txt</PlatformManifestTargetPath>
     </PropertyGroup>
   </Target>
 
 
   <Target Name="IncludeFileVersionPropsFile"
           DependsOnTargets="GetDepprojDependencyDataFiles;GetDependencyDataFileInclusionDefaults"
-          BeforeTargets="GetFiles"
-          Condition="'$(PackageTargetRuntime)' == '' AND '$(FileVersionPropsTargetPath)' != ''">
-    <ItemGroup>
+          BeforeTargets="GetFiles">
+    <!-- Create a copy with some per-pkgproj templates replaced. -->
+    <PropertyGroup>
+      <_propsFileTemplateFile Condition="'%(_depprojDataFile.PropsFile)' == 'true'">%(_depprojDataFile.Identity)</_propsFileTemplateFile>
+    </PropertyGroup>
+
+    <PropertyGroup Condition="Exists('$(_propsFileTemplateFile)')">
+      <_runtimeDependencyItems>@(RuntimeDependency)</_runtimeDependencyItems>
+      <_filledPropsFileContent>$([System.IO.File]::ReadAllText('$(_propsFileTemplateFile)')
+        .Replace("__PackageId__", "$(Id.Replace('.', '_'))")
+        .Replace("__PreferredPackages__", "$(Id);$(_runtimeDependencyItems)"))
+      </_filledPropsFileContent>
+
+      <_filledPropsFile>$(IntermediateOutputPath)$(MSBuildProjectName).props</_filledPropsFile>
+    </PropertyGroup>
+
+    <WriteLinesToFile
+      Condition="'$(_filledPropsFile)' != ''"
+      File="$(_filledPropsFile)"
+      Lines="$(_filledPropsFileContent)"
+      Overwrite="true" />
+
+    <ItemGroup Condition="'$(PackageTargetRuntime)' == '' AND '$(FileVersionPropsTargetPath)' != ''">
       <File
-        Include="@(_depprojDataFile)"
-        Condition="'%(_depprojDataFile.PropsFile)' == 'true'"
+        Include="$(_filledPropsFile)"
         TargetPath="$(FileVersionPropsTargetPath)" />
     </ItemGroup>
   </Target>
 
   <Target Name="IncludePlatformManifestFile"
           DependsOnTargets="GetDepprojDependencyDataFiles;GetDependencyDataFileInclusionDefaults"
-          BeforeTargets="GetFiles"
-          Condition="'$(PackageTargetRuntime)' == '' AND '$(PlatformManifestTargetPath)' != ''">
-    <ItemGroup>
+          BeforeTargets="GetFiles">
+    <ItemGroup Condition="'$(PackageTargetRuntime)' == '' AND '$(PlatformManifestTargetPath)' != ''">
       <File
         Include="@(_depprojDataFile)"
         Condition="'%(_depprojDataFile.PlatformManifestFile)' == 'true'"
index 69b5115..fcd37d7 100644 (file)
@@ -35,7 +35,6 @@
         Name="corefx" />
       <_coreClrVersionFile
         Include="$(_runtimePackageDir)version.txt"
-        Condition="'$(PackageTargetRuntime)' != ''"
         Name="coreclr" />
 
       <DependencyVersionFile Include="@(_coreFxVersionFile);@(_coreClrVersionFile)" />
@@ -46,7 +45,7 @@
       Text="Failed to locate corefx version.txt file." />
 
     <Error
-      Condition="'@(_coreClrVersionFile)' == '' AND '$(PackageTargetRuntime)' != ''"
+      Condition="'@(_coreClrVersionFile)' == ''"
       Text="Failed to locate coreclr version.txt file." />
   </Target>