Manufacturing of the Visual Studio NuPkgs. (dotnet/core-setup#6913)
authorJohn Beisner <johnbeisner@users.noreply.github.com>
Tue, 25 Jun 2019 18:39:15 +0000 (11:39 -0700)
committerGitHub <noreply@github.com>
Tue, 25 Jun 2019 18:39:15 +0000 (11:39 -0700)
* Manufacturing of the Visual Studio NuPkgs.

Commit migrated from https://github.com/dotnet/core-setup/commit/0524eae56d0bb16ec93a7313e237d6c5758bae90

src/installer/pkg/packaging/dir.proj
src/installer/pkg/packaging/dir.props
src/installer/pkg/packaging/windows/vscomponents/VS.Redist.Common.Component.nuspec [new file with mode: 0644]
src/installer/pkg/packaging/windows/vscomponents/generatenupkg.ps1 [new file with mode: 0644]
src/installer/publish/dir.props
src/installer/publish/publish.proj

index 64c178d..e520e4f 100644 (file)
@@ -15,7 +15,7 @@
 
   <Target Name="Build" DependsOnTargets="BuildInstallers;BuildCombinedInstallers" Condition="'$(DOTNET_BUILD_SKIP_PACKAGING)' != 'true'" />
   <Target Name="BuildInstallers" DependsOnTargets="$(PackageTargets)" Condition="'$(DOTNET_BUILD_SKIP_PACKAGING)' != 'true'" />
-  <Target Name="BuildCombinedInstallers" DependsOnTargets="GenerateCombinedInstallers" Condition="'$(DOTNET_BUILD_SKIP_PACKAGING)' != 'true'" />
+  <Target Name="BuildCombinedInstallers" DependsOnTargets="GenerateCombinedInstallers;GenerateVSNugetPackages" Condition="'$(DOTNET_BUILD_SKIP_PACKAGING)' != 'true'" />
 
   <Target Name="InitPackage">
     <ItemGroup>
           Condition="'@(PackageProjects)' != ''" />
   </Target>
 
-</Project>
+  <Target Name="GenerateVSNugetPackages"
+          Condition="'$(OS)' == 'Windows_NT' AND '$(TargetArchitecture)' != 'arm' AND '$(TargetArchitecture)' != 'arm64'"
+          DependsOnTargets="SetupVSNugetPackages;GenerateInstallers;GenerateProjectInstallers;GenerateCombinedInstallers"
+          Inputs="@(SdkMsiComponent->'%(MsiInstallerFile)');
+                    $(NuSpecFile);
+                    $(GenerateNupkgPowershellScript)"
+          Outputs="@(SdkMsiComponent->'$(PackageOutputPath)%(ComponentId).%(ComponentVersion).nupkg')">
+
+    <Exec Command="powershell -NoProfile -NoLogo $(GenerateNupkgPowershellScript) ^
+                      '%(SdkMsiComponent.MsiInstallerFile)' ^
+                      '@(SdkMsiComponent->'%(ComponentVersion)')' ^
+                      '$(NuSpecFile)' ^
+                      '@(SdkMsiComponent->'$(PackageOutputPath)%(ComponentId).%(ComponentVersion).nupkg')' ^
+                      '$(TargetArchitecture)' ^
+                      '@(SdkMsiComponent->'%(ComponentId)')' ^
+                      '@(SdkMsiComponent->'%(ComponentFriendlyName)')' ^
+                      '$(ProjectUrl)' ^
+                      '$(BinDir)'" />
+  </Target>
+  
+  <Target Name="SetupVSNugetPackages">
+      <PropertyGroup>
+        <NuSpecFile>$(MSBuildThisFileDirectory)windows/vscomponents/VS.Redist.Common.Component.nuspec</NuSpecFile>
+        <GenerateNupkgPowershellScript>$(MSBuildThisFileDirectory)windows/vscomponents/generatenupkg.ps1</GenerateNupkgPowershellScript>
+        <ProjectUrl>https://github.com/dotnet/core-setup</ProjectUrl>
+      </PropertyGroup>
+
+      <ItemGroup>
+        <SdkMsiComponent Include="HostFxrMsiNupkg">
+          <MsiInstallerFile>$(HostFxrInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.NetCore.HostFXR.$(TargetArchitecture).$(NETCoreAppFrameworkVersion)</ComponentId>
+          <ComponentVersion>$(SharedFrameworkNugetVersion)</ComponentVersion>
+          <ComponentFriendlyName>$(NETCoreAppFrameworkVersion) .NET Core HostFX Resolver</ComponentFriendlyName>
+        </SdkMsiComponent>
+        <SdkMsiComponent Include="AppHostPackMsiNupkg">
+          <MsiInstallerFile>$(AppHostPackInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.NetCore.AppHostPack.$(TargetArchitecture).$(NETCoreAppFrameworkVersion)</ComponentId>
+          <ComponentVersion>$(SharedFrameworkNugetVersion)</ComponentVersion>
+          <ComponentFriendlyName>$(NETCoreAppFrameworkVersion) .NET Core AppHost Pack</ComponentFriendlyName>
+        </SdkMsiComponent>
+        <SdkMsiComponent Include="SharedFrameworkMsiNupkg">
+          <MsiInstallerFile>$(SharedFrameworkInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.NetCore.SharedFramework.$(TargetArchitecture).$(NETCoreAppFrameworkVersion)</ComponentId>
+          <ComponentVersion>$(SharedFrameworkNugetVersion)</ComponentVersion>
+          <ComponentFriendlyName>$(NETCoreAppFrameworkVersion) .NET Core SharedFramework</ComponentFriendlyName>
+        </SdkMsiComponent>
+        <SdkMsiComponent Include="SharedHostMsiNupkg">
+          <MsiInstallerFile>$(SharedHostInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.NetCore.SharedHost.$(TargetArchitecture).$(NETCoreAppFrameworkVersion)</ComponentId>
+          <ComponentVersion>$(SharedFrameworkNugetVersion)</ComponentVersion>
+          <ComponentFriendlyName>$(NETCoreAppFrameworkVersion) .NET Core SharedHost</ComponentFriendlyName>
+        </SdkMsiComponent>
+        <SdkMsiComponent Include="NetStandardTargetingPackMsiNupkg">
+          <MsiInstallerFile>$(NetStandardTargetingPackInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.NetStandard.TargetingPack.$(TargetArchitecture).$(NetStandardProductBandVersion)</ComponentId>
+          <ComponentVersion>$(NetStandardProductBandVersion).$(PatchVersion)$(ProductVersionSuffix)</ComponentVersion>
+          <ComponentFriendlyName>$(NetStandardProductBandVersion) .NET Standard TargetingPack</ComponentFriendlyName>
+        </SdkMsiComponent>
+        <SdkMsiComponent Include="NetCoreTargetingPackMsiNupkg">
+          <MsiInstallerFile>$(TargetingPackInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.NetCore.TargetingPack.$(TargetArchitecture).$(NETCoreAppFrameworkVersion)</ComponentId>
+          <ComponentVersion>$(SharedFrameworkNugetVersion)</ComponentVersion>
+          <ComponentFriendlyName>$(NETCoreAppFrameworkVersion) .NET Core TargetingPack</ComponentFriendlyName>
+        </SdkMsiComponent>
+        <SdkMsiComponent Include="WindowsDesktopMsiNupkg">
+          <MsiInstallerFile>$(WindowsDesktopSharedFrameworkInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.WindowsDesktop.SharedFramework.$(TargetArchitecture).$(NETCoreAppFrameworkVersion)</ComponentId>
+          <ComponentVersion>$(SharedFrameworkNugetVersion)</ComponentVersion>
+          <ComponentFriendlyName>$(NETCoreAppFrameworkVersion) WindowsDesktop SharedFramework</ComponentFriendlyName>
+        </SdkMsiComponent>
+        <SdkMsiComponent Include="WindowsDesktopTargetingPackMsiNupkg">
+          <MsiInstallerFile>$(WindowsDesktopTargetingPackInstallerFile)</MsiInstallerFile>
+          <ComponentId>VS.Redist.Common.WindowsDesktop.TargetingPack.$(TargetArchitecture).$(NETCoreAppFrameworkVersion)</ComponentId>
+          <ComponentVersion>$(SharedFrameworkNugetVersion)</ComponentVersion>
+          <ComponentFriendlyName>$(NETCoreAppFrameworkVersion) WindowsDesktop TargetingPack</ComponentFriendlyName>
+        </SdkMsiComponent>
+      </ItemGroup>
+    </Target>
+
+  </Project>
index 186e74e..7d7d4d7 100644 (file)
     <SharedFrameworkCompressedFile>dotnet-runtime-internal-$(ProductMoniker)$(CompressedFileExtension)</SharedFrameworkCompressedFile>
     <SharedFrameworkSymbolsCompressedFile>dotnet-runtime-symbols-$(ProductMoniker)$(CompressedFileExtension)</SharedFrameworkSymbolsCompressedFile>
   </PropertyGroup>
-</Project>
\ No newline at end of file
+  <PropertyGroup>
+    <TargetingPackInstallerFile>$(AssetOutputPath)dotnet-targeting-pack-$(ProductMoniker)$(InstallerExtension)</TargetingPackInstallerFile>
+    <AppHostPackInstallerFile>$(AssetOutputPath)dotnet-apphost-pack-$(ProductMoniker)$(InstallerExtension)</AppHostPackInstallerFile>
+    <NetStandardProductBandVersion>2.1</NetStandardProductBandVersion>
+    <NetStandardProductMoniker>$(NetStandardProductBandVersion).$(PatchVersion)$(ProductVersionSuffix)-$(PackageTargetRid)</NetStandardProductMoniker>
+    <NetStandardTargetingPackInstallerFile>$(AssetOutputPath)netstandard-targeting-pack-$(NetStandardProductMoniker)$(InstallerExtension)</NetStandardTargetingPackInstallerFile>
+    <WindowsDesktopSharedFrameworkInstallerFile>$(AssetOutputPath)windowsdesktop-runtime-$(ProductMoniker)$(InstallerExtension)</WindowsDesktopSharedFrameworkInstallerFile>
+    <WindowsDesktopTargetingPackInstallerFile>$(AssetOutputPath)windowsdesktop-targeting-pack-$(ProductMoniker)$(InstallerExtension)</WindowsDesktopTargetingPackInstallerFile>
+  </PropertyGroup>
+</Project>
diff --git a/src/installer/pkg/packaging/windows/vscomponents/VS.Redist.Common.Component.nuspec b/src/installer/pkg/packaging/windows/vscomponents/VS.Redist.Common.Component.nuspec
new file mode 100644 (file)
index 0000000..e9bb74c
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
+  <metadata>
+    <id>$COMPONENT_NAME$</id>
+    <version>1.0.0</version>
+    <title>$COMPONENT_NAME$</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <licenseUrl>https://www.microsoft.com/net/dotnet_library_license.htm</licenseUrl>
+    <projectUrl>$PROJECT_URL$</projectUrl>
+    <requireLicenseAcceptance>true</requireLicenseAcceptance>
+    <description>$FRIENDLY_NAME$ ($ARCH$) Windows Installer MSI as a .nupkg for internal Visual Studio build consumption</description>
+    <copyright>© Microsoft Corporation. All rights reserved.</copyright>
+  </metadata>
+  <files>
+    <file src="$COMPONENT_MSI$" />
+  </files>
+</package>
diff --git a/src/installer/pkg/packaging/windows/vscomponents/generatenupkg.ps1 b/src/installer/pkg/packaging/windows/vscomponents/generatenupkg.ps1
new file mode 100644 (file)
index 0000000..52cf538
--- /dev/null
@@ -0,0 +1,35 @@
+# Copyright (c) .NET Foundation and contributors. All rights reserved.
+# Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+param(
+    [Parameter(Mandatory=$true)][string]$MsiPath,
+    [Parameter(Mandatory=$true)][string]$MsiVersion,
+    [Parameter(Mandatory=$true)][string]$NuspecFile,
+    [Parameter(Mandatory=$true)][string]$NupkgFile,
+    [Parameter(Mandatory=$true)][string]$Architecture,
+    [Parameter(Mandatory=$true)][string]$ComponentName,
+    [Parameter(Mandatory=$true)][string]$ComponentFriendlyName,
+    [Parameter(Mandatory=$true)][string]$ProjectUrl,
+    [Parameter(Mandatory=$true)][string]$BinDir
+)
+
+$NuGetDir = Join-Path $BinDir  "nuget"
+$NuGetExe = Join-Path $NuGetDir "nuget.exe"
+$OutputDirectory = [System.IO.Path]::GetDirectoryName($NupkgFile)
+
+if (-not (Test-Path $NuGetDir)) {
+    New-Item -ItemType Directory -Force -Path $NuGetDir | Out-Null
+}
+
+if (-not (Test-Path $NuGetExe)) {
+    # Using 3.5.0 to workaround https://github.com/NuGet/Home/issues/5016
+    Write-Output "Downloading nuget.exe to $NuGetExe"
+    wget https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe -OutFile $NuGetExe
+}
+
+if (Test-Path $NupkgFile) {
+    Remove-Item -Force $NupkgFile
+}
+
+& $NuGetExe pack $NuspecFile -Version $MsiVersion -OutputDirectory $OutputDirectory -NoDefaultExcludes -NoPackageAnalysis -Properties COMPONENT_MSI=$MsiPath`;ARCH=$Architecture`;COMPONENT_NAME=$ComponentName`;FRIENDLY_NAME=$ComponentFriendlyName`;PROJECT_URL=$ProjectUrl
+Exit $LastExitCode
index e743bfe..3b9ec85 100644 (file)
@@ -31,7 +31,8 @@
       Include="
         $(PackageOutputPath)**/runtime.*.nupkg;
         $(PackageOutputPath)**/*.Runtime.*.nupkg;
-        $(PackageOutputPath)**/*.App.Host.*.nupkg"
+        $(PackageOutputPath)**/*.App.Host.*.nupkg;
+        $(PackageOutputPath)**/VS.Redist.Common.*.nupkg"
       RelativeBlobPath="$(BinariesRelativePath)"/>
 
     <RidAgnosticPackageFile Include="$(PackageOutputPath)**/*.nupkg" Exclude="@(RuntimePackageFile)" >
index 98487e1..6423a79 100644 (file)
 
   <Target Name="GatherShippingPackages">
     <ItemGroup>
-      <PackagesToShip Include="$(DownloadDirectory)*.nupkg" Exclude="$(DownloadDirectory)*.symbols.nupkg" />
-      <PackagesToShip Remove="%(PackagesToShip.Identity)" Condition="$([System.String]::Copy('%(PackagesToShip.Identity)').Contains('latest'))" />
+      <PackagesToShip Include="$(DownloadDirectory)*.nupkg"
+                      Exclude="$(DownloadDirectory)*.symbols.nupkg;
+                               $(DownloadDirectory)VS.Redist.Common.*.nupkg" />
+      <PackagesToShip Remove="%(PackagesToShip.Identity)"
+                      Condition="$([System.String]::Copy('%(PackagesToShip.Identity)').Contains('latest'))" />
       <ShippedNuGetPackage Include="@(PackagesToShip)" />
     </ItemGroup>
   </Target>