Merge pull request #266 from nguerrera/vs-tools-nupkg

Generate nupkg of .NET Core SDK for internal build consumption
This commit is contained in:
Nick Guerrera 2019-01-11 15:59:28 -08:00 committed by GitHub
commit 142fefca40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 95 additions and 93 deletions

16
eng/Signing.props Normal file
View file

@ -0,0 +1,16 @@
<Project>
<ItemGroup>
<!-- Do not sign non-shipping packages -->
<ItemsToSign Remove="$(ArtifactsNonShippingPackagesDir)**\*.nupkg" />
</ItemGroup>
<PropertyGroup>
<!--
Signing of shipping artifacts (layout, msi, bundle) are handled separately.
It is therefore expected that above removal can yield an empty set.
-->
<AllowEmptySignList>true</AllowEmptySignList>
</PropertyGroup>
</Project>

View file

@ -27,12 +27,12 @@ IF /I "%Architecture:~0,3%"=="ARM" (
ECHO ##vso[task.setvariable variable=TestParameter]
ECHO ##vso[task.setvariable variable=RunTests]false
ECHO ##vso[task.setvariable variable=AdditionalBuildParameters]/p:SignCoreSdk=true /p:DotNetSignType=%SignType%
) ELSE (
ECHO NOT ARM
ECHO ##vso[task.setvariable variable=TestParameter]-test
ECHO ##vso[task.setvariable variable=RunTests]true
ECHO ##vso[task.setvariable variable=AdditionalBuildParameters]-sign /p:SignCoreSdk=true /p:DotNetSignType=%SignType%
)
ECHO ##vso[task.setvariable variable=AdditionalBuildParameters]-sign /p:DotNetSignType=%SignType%

View file

@ -7,15 +7,27 @@
param(
[string]$Configuration="Debug",
[string]$Architecture="x64",
[switch]$Sign=$false,
[bool]$WarnAsError=$true,
[Parameter(ValueFromRemainingArguments=$true)][String[]]$ExtraParameters
)
$RepoRoot = "$PSScriptRoot"
$ArchitectureParam="/p:Architecture=$Architecture"
$ConfigurationParam="-configuration $Configuration"
$Parameters = "/p:Architecture=$Architecture"
$Parameters = "$Parameters -configuration $Configuration"
if ($Sign) {
$Parameters = "$Parameters -sign /p:SignCoreSdk=true"
# Workaround https://github.com/dotnet/arcade/issues/1776
$WarnAsError = $false
}
$Parameters = "$Parameters -WarnAsError `$$WarnAsError"
try {
$ExpressionToInvoke = "$RepoRoot\eng\common\build.ps1 -restore -build $ConfigurationParam $ArchitectureParam $ExtraParameters"
$ExpressionToInvoke = "$RepoRoot\eng\common\build.ps1 -restore -build $Parameters $ExtraParameters"
Write-Host "Invoking expression: $ExpressionToInvoke"
Invoke-Expression $ExpressionToInvoke
}

View file

@ -20,11 +20,13 @@
<SdkGenerateNupkgPowershellScript>$(MSBuildThisFileDirectory)packaging/windows/clisdk/generatenupkg.ps1</SdkGenerateNupkgPowershellScript>
<SdkInstallerNuspecFile>$(MSBuildThisFileDirectory)packaging/windows/clisdk/VS.Redist.Common.Net.Core.SDK.$(Architecture).nuspec</SdkInstallerNuspecFile>
<SdkInstallerNupkgFile>$(ArtifactsShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.$(Architecture).$(FullNugetVersion).nupkg</SdkInstallerNupkgFile>
<SdkInstallerNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.$(Architecture).$(FullNugetVersion).nupkg</SdkInstallerNupkgFile>
<VSToolsNuspecFile>$(MSBuildThisFileDirectory)/packaging/windows/clisdk/VS.Tools.Net.Core.SDK.$(Architecture).nuspec</VSToolsNuspecFile>
<VSToolsNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Tools.Net.Core.SDK.$(Architecture).$(FullNugetVersion).nupkg</VSToolsNupkgFile>
<!--<SdkMSBuildExtensionsNuspecFile>$(MSBuildThisFileDirectory)packaging/windows/clisdk/VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.nuspec</SdkMSBuildExtensionsNuspecFile>
<SdkMSBuildExtensionsNupkgFile>$(ArtifactsShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.$(FullNugetVersion).nupkg</SdkMSBuildExtensionsNupkgFile>
<SdkMSBuildExtensionsSwrFile>$(ArtifactsShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.swr</SdkMSBuildExtensionsSwrFile>-->
<SdkMSBuildExtensionsNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.$(FullNugetVersion).nupkg</SdkMSBuildExtensionsNupkgFile>
<SdkMSBuildExtensionsSwrFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.swr</SdkMSBuildExtensionsSwrFile>-->
</PropertyGroup>
<PropertyGroup>
@ -160,6 +162,21 @@
'$(SdkInstallerNupkgFile)'" />
</Target>
<Target Name="GenerateVSToolsNupkg"
DependsOnTargets="GenerateLayout;MsiTargetsSetupInputOutputs;GenerateSdkBundle"
Condition=" '$(OS)' == 'Windows_NT' and '$(Architecture)' == 'x86'"
Inputs="$(RedistLayoutPath)/**/*;
$(VSToolsNuspecFile);
$(SdkGenerateNupkgPowershellScript)"
Outputs="$(VSToolsNupkgFile)">
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript) ^
'$(RedistLayoutPath.TrimEnd('\'))' ^
'$(FullNugetVersion)' ^
'$(VSToolsNuspecFile)' ^
'$(VSToolsNupkgFile)'" />
</Target>
<Target Name="GenerateSdkMSBuildExtensionsNupkg"
DependsOnTargets="GenerateLayout;MsiTargetsSetupInputOutputs;GenerateSdkBundle"
Condition=" '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64' "
@ -191,6 +208,7 @@
GenerateSdkBundle;
SignSdkBundle;
GenerateSdkNupkg;
GenerateVSToolsNupkg;
GenerateSdkMSBuildExtensionsNupkg"
Condition=" '$(OS)' == 'Windows_NT' and !$(Architecture.StartsWith('arm'))" />

View file

@ -0,0 +1,5 @@
@echo off
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set DOTNET_MULTILELVEL_LOOKUP=0
set PATH=%~dp0;%PATH%

View file

@ -13,6 +13,6 @@
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
</metadata>
<files>
<file src="[DOTNET_BUNDLE]\**\*" />
<file src="$DOTNET_BUNDLE$\**\*" />
</files>
</package>

View file

@ -13,6 +13,6 @@
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
</metadata>
<files>
<file src="[DOTNET_BUNDLE]" />
<file src="$DOTNET_BUNDLE$" />
</files>
</package>

View file

@ -13,6 +13,6 @@
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
</metadata>
<files>
<file src="[DOTNET_BUNDLE]" />
<file src="$DOTNET_BUNDLE$" />
</files>
</package>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>VS.Tools.Net.Core.SDK.x86</id>
<version>1.0.0</version>
<title>VS.Tools.Net.Core.SDK.x86</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<licenseUrl>https://www.microsoft.com/net/dotnet_library_license.htm</licenseUrl>
<projectUrl>https://github.com/dotnet/cli</projectUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>.Net Core SDK (x86) as a .nupkg for internal VS build consumption</description>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
</metadata>
<files>
<file src="$DOTNET_BUNDLE$\**\*" />
<file src="Init.cmd" />
</files>
</package>

View file

@ -1,26 +0,0 @@
#
# 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.
#
. $PSScriptRoot\_utility.ps1
# Copy things from environment variables that were sent by the build scripts
$Rid = $env:Rid
$Tfm = $env:Tfm
$OutputDir = $env:OutputDir
$Stage1Dir = $env:Stage1Dir
$Stage1CompilationDir = $env:Stage1CompilationDir
$Stage2Dir = $env:Stage2Dir
$Stage2CompilationDir = $env:Stage2CompilationDir
$PackageDir = $env:PackageDir
$TestBinRoot = $env:TestBinRoot
$TestPackageDir = $env:TestPackageDir
$env:Channel = "$env:RELEASE_SUFFIX"
# Set reasonable defaults for unset variables
setEnvIfDefault "DOTNET_INSTALL_DIR" "$RepoRoot\.dotnet_stage0\win7-x64"
setEnvIfDefault "DOTNET_CLI_VERSION" "0.1.0.0"
setPathAndHomeIfDefault "$Stage2Dir"
setVarIfDefault "CONFIGURATION" "Debug"

View file

@ -126,6 +126,6 @@ if(!(Test-Path $DotnetBundleOutput))
Exit -1
}
Write-Output -ForegroundColor Green "Successfully created dotnet bundle - $DotnetBundleOutput"
Write-Output "Successfully created dotnet bundle - $DotnetBundleOutput"
exit $LastExitCode

View file

@ -1,9 +1,6 @@
# 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.
# This script is used to generate a nuget package with the windows installer bundle.
# The generated nupkg file is used to deliver the CLI payload to Visual Studio.
param(
[Parameter(Mandatory=$true)][string]$SdkBundlePath,
[Parameter(Mandatory=$true)][string]$NugetVersion,
@ -11,64 +8,25 @@ param(
[Parameter(Mandatory=$true)][string]$NupkgFile
)
. "$PSScriptRoot\_common.ps1"
$RepoRoot = Convert-Path "$PSScriptRoot\..\..\.."
$NuGetDir = Join-Path $RepoRoot ".nuget"
$RepoRoot = Convert-Path "$PSScriptRoot\..\..\..\..\..\.."
$NuGetDir = Join-Path $RepoRoot "artifacts\Tools\nuget"
$NuGetExe = Join-Path $NuGetDir "nuget.exe"
$OutputDirectory = [System.IO.Path]::GetDirectoryName($NupkgFile)
$SdkBundlePath = [System.IO.Path]::GetFullPath($SdkBundlePath)
function DownloadNugetExe
{
if (-not (Test-Path $NuGetDir))
{
New-Item -ItemType Directory -Force -Path $NuGetDir | Out-Null
}
if (-not (Test-Path $NuGetExe)) {
Write-Output 'Downloading nuget.exe to ' + $NuGetExe
wget https://dist.nuget.org/win-x86-commandline/v4.7.0/nuget.exe -OutFile $NuGetExe
}
if (-not (Test-Path $NuGetDir)) {
New-Item -ItemType Directory -Force -Path $NuGetDir | Out-Null
}
function GenerateNupkg
{
if (-not (Test-Path $NuspecFile))
{
Write-Output 'Error nuspec not found - $NuspecFile'
}
$SdkBundlePath = [System.IO.Path]::GetFullPath($SdkBundlePath)
$NuspecFileName = [System.IO.Path]::GetFileName($NuspecFile)
$TempNuspecFile = [System.IO.Path]::Combine($OutputDirectory, $NuspecFileName)
(Get-Content $NuspecFile) -replace '\[DOTNET_BUNDLE\]', $SdkBundlePath | Set-Content $TempNuspecFile
& $NuGetExe pack $TempNuspecFile -Version $NugetVersion -OutputDirectory $OutputDirectory
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 $SdkBundlePath))
{
throw "$SdkBundlePath not found"
}
Write-Output "Creating nupkg for Sdk installer"
DownloadNugetExe
if(Test-Path $NupkgFile)
{
if (Test-Path $NupkgFile) {
Remove-Item -Force $NupkgFile
}
if(-Not (GenerateNupkg))
{
Exit -1
}
if(!(Test-Path $NupkgFile))
{
throw "$NupkgFile not generated"
}
Write-Output -ForegroundColor Green "Successfully created installer nupkg - $NupkgFile"
exit $LastExitCode
& $NuGetExe pack $NuspecFile -Version $NugetVersion -OutputDirectory $OutputDirectory -NoPackageAnalysis -Properties DOTNET_BUNDLE=$SdkBundlePath
Exit $LastExitCode