From fd51fb312cdd6999587b390c8bfaf5f0d3418a26 Mon Sep 17 00:00:00 2001 From: Alex Panov Date: Wed, 5 Oct 2016 21:39:08 -0700 Subject: [PATCH] Build script changes for SxS willow instances Sharing build script changes to support development in SxS willow environment. `configure.ps1` script is now able to identify the latest willow instance and deduce VS install dir and msbuild path. Configuration parameters are store in `artifacts\configure.json` file so that build or test script don't need to run in the same PS session. Fixed VC++ project system interop assembly dependency. Optional. Set VSIX version in manifest to 3.6.99.99 to be able to publish locally built extension to experimental instance. Otherwise this fails due to version conflict. This change is safe as CI overwrites the version string in the manifest on S&P build step. Code cleanup to fix: - Use of unapproved verbs - Use of redundant switch Intentionally setting VSIX manifest version to 99.99.99 --- build.ps1 | 41 +---- build/common.props | 4 - build/common.ps1 | 99 +++++----- build/common.targets | 26 +-- configure.ps1 | 170 +++++++++++++----- runTests.ps1 | 25 +-- scripts/cibuild/CreateEndToEndTestPackage.ps1 | 6 +- scripts/utils/UpdateNuGetVersion.ps1 | 3 - ...uGet.PackageManagement.VisualStudio.csproj | 44 ++--- .../VsExtension/VsExtension.csproj | 16 +- .../source.extension.vs14.vsixmanifest | 2 +- .../source.extension.vs15.vsixmanifest | 2 +- 12 files changed, 243 insertions(+), 195 deletions(-) diff --git a/build.ps1 b/build.ps1 index 6f956302e3a..72f7df9053c 100644 --- a/build.ps1 +++ b/build.ps1 @@ -11,9 +11,6 @@ Release label to use for package and assemblies versioning (zlocal by default) .PARAMETER BuildNumber Build number to use for package and assemblies versioning (auto-generated if not provided) -.PARAMETER SkipRestore -Builds without restoring first - .PARAMETER MSPFXPath Path to a code signing certificate for delay-sigining (optional) @@ -29,11 +26,8 @@ Skips building binaries targeting Visual Studio "14" (released as Visual Studio .PARAMETER SkipVS15 Skips building binaries targeting Visual Studio "15" -.PARAMETER SkipILMerge -Skips creating an ILMerged nuget.exe - .PARAMETER Fast -Runs minimal incremental build. ILMerge and end-to-end packaging steps skipped. +Runs minimal incremental build. Skips end-to-end packaging step. .PARAMETER CI Indicates the build script is invoked from CI @@ -64,8 +58,6 @@ param ( [string]$ReleaseLabel = 'zlocal', [Alias('n')] [int]$BuildNumber, - [Alias('sr')] - [switch]$SkipRestore, [Alias('mspfx')] [string]$MSPFXPath, [Alias('nugetpfx')] @@ -76,8 +68,6 @@ param ( [switch]$SkipVS14, [Alias('s15')] [switch]$SkipVS15, - [Alias('si')] - [switch]$SkipILMerge, [Alias('f')] [switch]$Fast, [switch]$CI @@ -123,54 +113,39 @@ Invoke-BuildStep 'Cleaning artifacts' { -skip:($Fast -or $SkipXProj) ` -ev +BuildErrors -# Restoring tools required for build -Invoke-BuildStep 'Restoring solution packages' { Restore-SolutionPackages } ` - -skip:$SkipRestore ` - -ev +BuildErrors - Invoke-BuildStep 'Enabling delay-signing' { - param($MSPFXPath, $NuGetPFXPath) Enable-DelaySigning $MSPFXPath $NuGetPFXPath } ` - -args $MSPFXPath, $NuGetPFXPath ` -skip:((-not $MSPFXPath) -and (-not $NuGetPFXPath)) ` -ev +BuildErrors Invoke-BuildStep 'Building NuGet.Core projects' { - param($Configuration, $ReleaseLabel, $BuildNumber, $SkipRestore) - Build-CoreProjects $Configuration $ReleaseLabel $BuildNumber -SkipRestore:$SkipRestore + Build-CoreProjects $Configuration $ReleaseLabel $BuildNumber -CI:$CI } ` - -args $Configuration, $ReleaseLabel, $BuildNumber, $SkipRestore ` -skip:$SkipXProj ` -ev +BuildErrors ## Building the VS15 Tooling solution Invoke-BuildStep 'Building NuGet.Clients projects - VS15 Toolset' { - param($Configuration, $ReleaseLabel, $BuildNumber, $SkipRestore) - Build-ClientsProjects $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 15 -SkipRestore:$SkipRestore + Build-ClientsProjects $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 15 } ` - -args $Configuration, $ReleaseLabel, $BuildNumber, $SkipRestore ` -skip:$SkipVS15 ` -ev +BuildErrors ## Building the VS14 Tooling solution Invoke-BuildStep 'Building NuGet.Clients projects - VS14 Toolset' { - param($Configuration, $ReleaseLabel, $BuildNumber, $SkipRestore) - Build-ClientsProjects $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 14 -SkipRestore:$SkipRestore + Build-ClientsProjects $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 14 } ` - -args $Configuration, $ReleaseLabel, $BuildNumber, $SkipRestore ` -skip:$SkipVS14 ` -ev +BuildErrors -Invoke-BuildStep 'Creating NuGet.Clients packages - VS14 Toolset' { - param($Configuration, $MSPFXPath, $SkipILMerge) - Build-ClientsPackages $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 14 -KeyFile $MSPFXPath -SkipILMerge:$SkipILMerge +Invoke-BuildStep 'Publishing NuGet.Clients packages - VS14 Toolset' { + Publish-ClientsPackages $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 14 -KeyFile $MSPFXPath } ` - -args $Configuration, $MSPFXPath, $SkipILMerge ` -skip:($Fast -or $SkipVS14) ` -ev +BuildErrors -Invoke-BuildStep 'Creating the VS14 EndToEnd test package' { +Invoke-BuildStep 'Publishing the VS14 EndToEnd test package' { param($Configuration) $EndToEndScript = Join-Path $PSScriptRoot scripts\cibuild\CreateEndToEndTestPackage.ps1 -Resolve $OutDir = Join-Path $Artifacts VS14 @@ -180,7 +155,7 @@ Invoke-BuildStep 'Creating the VS14 EndToEnd test package' { -skip:($Fast -or $SkipVS14) ` -ev +BuildErrors -Invoke-BuildStep 'Creating the VS15 EndToEnd test package' { +Invoke-BuildStep 'Publishing the VS15 EndToEnd test package' { param($Configuration) $EndToEndScript = Join-Path $PSScriptRoot scripts\cibuild\CreateEndToEndTestPackage.ps1 -Resolve $OutDir = Join-Path $Artifacts VS15 diff --git a/build/common.props b/build/common.props index f7cba38baf9..041597034eb 100644 --- a/build/common.props +++ b/build/common.props @@ -18,10 +18,6 @@ $(EnlistmentRoot)\artifacts $([System.IO.Path]::GetFullPath( $(ArtifactRoot) )) - HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\$(VisualStudioVersion)_Config\InstallDir - $(ProgramFiles)\Microsoft Visual Studio $(VisualStudioVersion)\Common7\IDE\ - $([MSBuild]::GetRegistryValue($(VisualStudioRegistryKey), $(VisualStudioDefaultInstallDir)) - $(VisualStudioVersion)\$(Configuration)\ $(ArtifactRoot)\$(MSBuildProjectName)\$(OutDirFx) $([System.IO.Path]::GetFullPath( $(OutputPath) ))\ diff --git a/build/common.ps1 b/build/common.ps1 index 70d5d3c96fa..84dda7c6989 100644 --- a/build/common.ps1 +++ b/build/common.ps1 @@ -8,16 +8,11 @@ $DefaultMSBuildVersion = 15 $PackageReleaseVersion = "3.6.0" $NuGetClientRoot = Split-Path -Path $PSScriptRoot -Parent - -# allow this to work for scripts/funcTests -if ((Split-Path -Path $PSScriptRoot -Leaf) -eq "scripts") { - $NuGetClientRoot = Split-Path -Path $NuGetClientRoot -Parent -} - -$CLIRoot = Join-Path $NuGetClientRoot 'cli' +$CLIRoot = Join-Path $NuGetClientRoot cli $Nupkgs = Join-Path $NuGetClientRoot nupkgs $Artifacts = Join-Path $NuGetClientRoot artifacts $ReleaseNupkgs = Join-Path $Artifacts ReleaseNupkgs +$ConfigureJson = Join-Path $Artifacts configure.json $DotNetExe = Join-Path $CLIRoot 'dotnet.exe' $NuGetExe = Join-Path $NuGetClientRoot '.nuget\nuget.exe' @@ -68,7 +63,7 @@ Function Error-Log { Write-Error "[$(Trace-Time)]`t$ErrorMessage" } else { - Write-Error "[$(Trace-Time)]`t$ErrorMessage" -ErrorAction Stop + Write-Error "[$(Trace-Time)]`t[FATAL] $ErrorMessage" -ErrorAction Stop } } @@ -101,7 +96,8 @@ Function Invoke-BuildStep { [Alias('args')] [Object[]]$Arguments, [Alias('skip')] - [switch]$SkipExecution + [switch]$SkipExecution, + [switch]$Critical ) if (-not $SkipExecution) { if ($env:TEAMCITY_VERSION) { @@ -148,10 +144,9 @@ Function Update-Submodules { param( [switch]$Force ) - - $SubmodulesDir = Join-Path $NuGetClientRoot submodules -Resolve - $Submodules = gci $SubmodulesDir -ea Ignore - if ($Force -or -not $Submodules) { + $Submodules = Join-Path $NuGetClientRoot submodules -Resolve + $GitAttributes = gci $Submodules\* -Filter '.gitattributes' -r -ea Ignore + if ($Force -or -not $GitAttributes) { $opts = 'submodule', 'update' $opts += '--init' if (-not $VerbosePreference) { @@ -170,11 +165,13 @@ Function Install-NuGet { param( [switch]$Force ) - if ($Force -or -not (Test-Path $NuGetExe)) { Trace-Log 'Downloading nuget.exe' wget https://dist.nuget.org/win-x86-commandline/latest-prerelease/nuget.exe -OutFile $NuGetExe } + + # Display nuget info + & $NuGetExe locals all -list -verbosity detailed } Function Install-DotnetCLI { @@ -182,12 +179,11 @@ Function Install-DotnetCLI { param( [switch]$Force ) - $env:DOTNET_HOME=$CLIRoot $env:DOTNET_INSTALL_DIR=$NuGetClientRoot if ($Force -or -not (Test-Path $DotNetExe)) { - Trace-Log 'Downloading Dotnet CLI' + Trace-Log 'Downloading .NET CLI' New-Item -ItemType Directory -Force -Path $CLIRoot | Out-Null @@ -257,21 +253,33 @@ Function Test-MSBuildVersionPresent { Test-Path $MSBuildExe } -$MSBuildExe = Get-MSBuildExe -Set-Alias msbuild $MSBuildExe - -$VS14Installed = Test-MSBuildVersionPresent -MSBuildVersion 14 -$VS15Installed = Test-MSBuildVersionPresent -MSBuildVersion 15 - -function Test-BuildEnvironment { +Function Test-BuildEnvironment { + [CmdletBinding()] param( [switch]$CI ) + if (-not (Test-Path $ConfigureJson)) { + Error-Log 'Build environment is not configured. Please run configure.ps1 first.' -Fatal + } + $Installed = (Test-Path $DotNetExe) -and (Test-Path $NuGetExe) if (-not $Installed) { Error-Log 'Build environment is not configured. Please run configure.ps1 first.' -Fatal } + $script:ConfigureObject = Get-Content $ConfigureJson -Raw | ConvertFrom-Json + Set-Variable MSBuildExe -Value $ConfigureObject.BuildTools.MSBuildExe -Scope Script -Force + Set-Alias msbuild $script:MSBuildExe -Scope Script -Force + Set-Variable BuildToolsets -Value $ConfigureObject.Toolsets -Scope Script -Force + + $script:VS14Installed = ($BuildToolsets | where vs14 -ne $null) + $script:VS15Installed = ($BuildToolsets | where vs15 -ne $null) + + $ConfigureObject | + select -expand envvars -ea Ignore | + %{ $_.psobject.properties } | + %{ Set-Item -Path "env:$($_.Name)" -Value $_.Value } + if ($CI) { # Explicitly add cli to environment PATH # because dotnet-install script runs in configure.ps1 in previous build step @@ -376,7 +384,7 @@ Function Clear-Artifacts { param() if( Test-Path $Artifacts) { Trace-Log 'Cleaning the Artifacts folder' - Remove-Item $Artifacts\* -Recurse -Force + Remove-Item $Artifacts\* -Recurse -Force -Exclude 'configure.json' } } @@ -549,7 +557,8 @@ Function Build-CoreProjects { [string]$Configuration = $DefaultConfiguration, [string]$ReleaseLabel = $DefaultReleaseLabel, [int]$BuildNumber = (Get-BuildNumber), - [switch]$SkipRestore + [switch]$SkipRestore, + [switch]$CI ) $XProjectsLocation = Join-Path $NuGetClientRoot src\NuGet.Core -Resolve $xprojects = Find-XProjects $XProjectsLocation @@ -561,9 +570,11 @@ Function Build-CoreProjects { # Build .nupkgs for MyGet (which have release label and build number) $xprojects | Invoke-DotnetPack -config $Configuration -label $ReleaseLabel -build $BuildNumber -out $Nupkgs - # Build .nupkgs for release (which have no build number). This will re-use the build from the last - # step because the --build-base-path is the same. - $xprojects | Invoke-DotnetPack -config $Configuration -label $ReleaseLabel -out $ReleaseNupkgs + if ($CI) { + # Build .nupkgs for release (which have no build number). This will re-use the build from the last + # step because the --build-base-path is the same. + $xprojects | Invoke-DotnetPack -config $Configuration -label $ReleaseLabel -out $ReleaseNupkgs + } # Publish NuGet.CommandLine.XPlat $PublishLocation = Join-Path $Artifacts "NuGet.CommandLine.XPlat\publish" @@ -588,7 +599,7 @@ Function Pack-NuGetBuildTasksPack { Remove-Item $Nupkgs\NuGet.Build.Tasks.Pack* Remove-Item $ReleaseNupkgs\NuGet.Build.Tasks.Pack* - + $prereleaseNupkgVersion = "$PackageReleaseVersion-$ReleaseLabel-$BuildNumber" if ($ReleaseLabel -Ne 'rtm') { $releaseNupkgVersion = "$PackageReleaseVersion-$ReleaseLabel" @@ -598,7 +609,7 @@ Function Pack-NuGetBuildTasksPack { $PackProjectLocation = Join-Path $NuGetClientRoot src\NuGet.Core\NuGet.Build.Tasks.Pack $PackBuildTaskNuspecLocation = Join-Path $PackProjectLocation NuGet.Build.Tasks.Pack.nuspec - + Build-NuGetPackage ` -NuspecPath $PackBuildTaskNuspecLocation ` -BasePath $PackProjectLocation ` @@ -795,7 +806,7 @@ Function Build-ClientsProjects { -IsSolution } -Function Build-ClientsPackages { +Function Publish-ClientsPackages { [CmdletBinding()] param( [string]$Configuration = $DefaultConfiguration, @@ -803,8 +814,7 @@ Function Build-ClientsPackages { [int]$BuildNumber = (Get-BuildNumber), [ValidateSet(14,15)] [int]$ToolsetVersion = $DefaultMSBuildVersion, - [string]$KeyFile, - [switch]$SkipILMerge + [string]$KeyFile ) $prereleaseNupkgVersion = "$PackageReleaseVersion-$ReleaseLabel-$BuildNumber" @@ -814,7 +824,6 @@ Function Build-ClientsPackages { $releaseNupkgVersion = "$PackageReleaseVersion" } - if (-not $SkipILMerge){ $exeProjectDir = [io.path]::combine($NuGetClientRoot, "src", "NuGet.Clients", "NuGet.CommandLine") $exeProject = Join-Path $exeProjectDir "NuGet.CommandLine.csproj" $exeNuspec = Join-Path $exeProjectDir "NuGet.CommandLine.nuspec" @@ -835,7 +844,7 @@ Function Build-ClientsPackages { -OutputDir $exeOutputDir ` -KeyFile $KeyFile - Build-NuGetPackage ` + New-NuGetPackage ` -NuspecPath $exeNuspec ` -BasePath $exeOutputDir ` -OutputDir $Nupkgs ` @@ -857,7 +866,7 @@ Function Build-ClientsPackages { -OutputDir $exeOutputDir ` -KeyFile $KeyFile - Build-NuGetPackage ` + New-NuGetPackage ` -NuspecPath $exeNuspec ` -BasePath $exeOutputDir ` -OutputDir $ReleaseNupkgs ` @@ -873,7 +882,7 @@ Function Build-ClientsPackages { Copy-Item -Path "${projectInstallPs1}" -Destination "${projectInputDir}" - Build-NuGetPackage ` + New-NuGetPackage ` -NuspecPath $projectNuspec ` -BasePath $projectInputDir ` -OutputDir $Nupkgs ` @@ -881,7 +890,7 @@ Function Build-ClientsPackages { -Configuration $Configuration # Pack the NuGet.VisualStudio project with just the release label. - Build-NuGetPackage ` + New-NuGetPackage ` -NuspecPath $projectNuspec ` -BasePath $projectInputDir ` -OutputDir $ReleaseNupkgs ` @@ -889,14 +898,15 @@ Function Build-ClientsPackages { -Configuration $Configuration } -Function Build-NuGetPackage { +Function New-NuGetPackage { + [CmdletBinding()] param( [string]$NuspecPath, [string]$BasePath, [string]$OutputDir, [string]$Version, [string]$Configuration=$DefaultConfiguration - ) + ) $opts = 'pack', $NuspecPath $opts += '-BasePath', $BasePath @@ -904,6 +914,15 @@ Function Build-NuGetPackage { $opts += '-Symbols' $opts += '-Version', $Version $opts += '-Properties', "Configuration=$Configuration" + + if ($VerbosePreference) { + $opts += '-verbosity', 'detailed' + } + else { + $opts += '-verbosity', 'quiet' + } + + Trace-Log "$NuGetExe $opts" & $NuGetExe $opts } diff --git a/build/common.targets b/build/common.targets index 33c01a30079..eb79512f919 100644 --- a/build/common.targets +++ b/build/common.targets @@ -1,13 +1,13 @@ - - - - - - True - - - - \ No newline at end of file + + + + + + True + + + + diff --git a/configure.ps1 b/configure.ps1 index b9ef8da5529..302e7fa24ad 100644 --- a/configure.ps1 +++ b/configure.ps1 @@ -1,9 +1,7 @@ <# .SYNOPSIS -Configures NuGet.Client build environment. - -.PARAMETER ToolsetVersion -Sets environment variables relevant to the desired VS toolset. +Configures NuGet.Client build environment. Detects and initializes +VS build toolsets. Configuration settings are stored at configure.json file. .PARAMETER CleanCache Cleans NuGet packages cache before build @@ -15,16 +13,15 @@ Switch to force installation of required tools. Indicates the build script is invoked from CI .EXAMPLE -Clean install using VS14 (default) toolset .\configure.ps1 -cc -v +Clean repo build environment configuration -Incremental install for VS15 toolset -.\configure.ps1 -tv 15 -v +.EXAMPLE +.\configure.ps1 -v +Incremental install of build tools #> [CmdletBinding(SupportsShouldProcess=$True)] Param ( - [Alias('tv')] - [int]$ToolsetVersion = 14, [Alias('cc')] [switch]$CleanCache, [Alias('f')] @@ -34,50 +31,139 @@ Param ( . "$PSScriptRoot\build\common.ps1" -Trace-Log "Configuring NuGet.Client build environment for VS${ToolsetVersion} Toolset" +Trace-Log "Configuring NuGet.Client build environment" + +$BuildErrors = @() -Update-SubModules -Force:$Force +Invoke-BuildStep 'Configuring git repo' { + Update-SubModules -Force:$Force +} -ev +BuildErrors -Install-NuGet -Force:$Force +Invoke-BuildStep 'Installing NuGet.exe' { + Install-NuGet -Force:$Force +} -ev +BuildErrors -Install-DotnetCLI -Force:$Force +Invoke-BuildStep 'Installing .NET CLI' { + Install-DotnetCLI -Force:$Force +} -ev +BuildErrors -if ($CleanCache) { +# Restoring tools required for build +Invoke-BuildStep 'Restoring solution packages' { + Restore-SolutionPackages +} -ev +BuildErrors + +Invoke-BuildStep 'Cleaning package cache' { Clear-PackageCache +} -skip:(-not $CleanCache) -ev +BuildErrors + +$ConfigureObject = @{ + BuildTools = @{} + Toolsets = @{} } -Trace-Log "Validating VS${ToolsetVersion} toolset installation" +Function New-BuildToolset { + param( + [int]$ToolsetVersion + ) + $CommonToolsVar = "Env:VS${ToolsetVersion}0COMNTOOLS" + if (Test-Path $CommonToolsVar) { + $CommonToolsValue = gci $CommonToolsVar | select -expand value -ea Ignore + Verbose-Log "Using environment variable `"$CommonToolsVar`" = `"$CommonToolsValue`"" + $ToolsetObject = @{ + VisualStudioInstallDir = [System.IO.Path]::GetFullPath((Join-Path $CommonToolsValue '..\IDE')) + } + } -$CommonToolsVar = "Env:VS${ToolsetVersion}0COMNTOOLS" -if (Test-Path $CommonToolsVar) { - $CommonToolsValue = gci $CommonToolsVar | select -expand value -ea Ignore - Verbose-Log "Using environment variable `"$CommonToolsVar`" = `"$CommonToolsValue`"" - $VisualStudioInstallDir = [System.IO.Path]::GetFullPath((Join-Path $CommonToolsValue '..\IDE')) -} -else { - $VisualStudioRegistryKey = "HKCU:\SOFTWARE\Microsoft\VisualStudio\${ToolsetVersion}.0_Config" - Verbose-Log "Retrieving Visual Studio installation path from registry '$VisualStudioRegistryKey'" - - $VisualStudioInstallDir = gp $VisualStudioRegistryKey | select -expand InstallDir -ea Ignore - if (-not $VisualStudioInstallDir) { - Verbose-Log "Using default location of Visual Studio installation path" - $VisualStudioInstallDir = "${env:ProgramFiles}\Microsoft Visual Studio ${ToolsetVersion}.0\Common7\IDE\" + if (-not $ToolsetObject) { + $VisualStudioRegistryKey = "HKCU:\SOFTWARE\Microsoft\VisualStudio\${ToolsetVersion}.0_Config" + if (Test-Path $VisualStudioRegistryKey) { + Verbose-Log "Retrieving Visual Studio installation path from registry '$VisualStudioRegistryKey'" + $ToolsetObject = @{ + VisualStudioInstallDir = gp $VisualStudioRegistryKey | select -expand InstallDir -ea Ignore + } + } + } + + if (-not $ToolsetObject -and $ToolsetVersion -gt 14) { + $WillowInstance = Get-ChildItem $env:ProgramData\Microsoft\VisualStudio\Packages\_Instances -filter state.json -recurse | + sort LastWriteTime | + select -last 1 | + Get-Content -raw | + ConvertFrom-Json + + if ($WillowInstance) { + Verbose-Log "Using willow instance '$($WillowInstance.installationName)' installation path" + $ToolsetObject = @{ + VisualStudioInstallDir = [System.IO.Path]::GetFullPath((Join-Path $WillowInstance.installationPath Common7\IDE\)) + } + } } -} -Resolve-Path $VisualStudioInstallDir | Out-Null + if (-not $ToolsetObject) { + $DefaultInstallDir = Join-Path $env:ProgramFiles "Microsoft Visual Studio ${ToolsetVersion}.0\Common7\IDE\" + if (Test-Path $DefaultInstallDir) { + Verbose-Log "Using default location of Visual Studio installation path" + $ToolsetObject = @{ + $VisualStudioInstallDir = $DefaultInstallDir + } + } + } + + if (-not $ToolsetObject) { + Warning-Log "Toolset VS${ToolsetVersion} is not found." + } + + # return toolset build configuration object + $ToolsetObject +} -Verbose-Log "VisualInstallDir = '$VisualStudioInstallDir'" +$MSBuildDefaultRoot = Join-Path ${env:ProgramFiles(x86)} MSBuild +$MSBuildRelativePath = 'bin\msbuild.exe' -if ($ToolsetVersion -eq 15) { - $MSBuildDefaultRoot = Get-MSBuildRoot 15 -Default - $VSToolsPath = Join-Path $MSBuildDefaultRoot 'Microsoft\VisualStudio\v15.0' - $Targets = Join-Path $VSToolsPath 'VSSDK\Microsoft.VsSDK.targets' - if (-not (Test-Path $Targets)) { - Warning-Log "VSSDK is not found at default location '$VSToolsPath'. Attempting to override." - # Attempting to fix VS SDK path for VS15 willow install builds - # as MSBUILD failes to resolve it correctly - $env:VSToolsPath = Join-Path $VisualStudioInstallDir '..\..\MSBuild\Microsoft\VisualStudio\v15.0' -Resolve - Trace-Log "VSToolsPath now is '${env:VSToolsPath}'" +Invoke-BuildStep 'Validating VS14 toolset installation' { + $vs14 = New-BuildToolset 14 + if ($vs14) { + $ConfigureObject.Toolsets.Add('vs14', $vs14) + $script:MSBuildExe = Join-Path $MSBuildDefaultRoot "14.0\${MSBuildRelativePath}" } +} -ev +BuildErrors + +Invoke-BuildStep 'Validating VS15 toolset installation' { + $vs15 = New-BuildToolset 15 + if ($vs15) { + $ConfigureObject.Toolsets.Add('vs15', $vs15) + $WillowMSBuild = Join-Path $vs15.VisualStudioInstallDir ..\..\MSBuild + $script:MSBuildExe = switch (Test-Path $WillowMSBuild) { + $True { Join-Path $WillowMSBuild "15.0\${MSBuildRelativePath}" } + $False { Join-Path $MSBuildDefaultRoot "15.0\${MSBuildRelativePath}" } + } + + # Hack VSSDK path + $VSToolsPath = Join-Path $MSBuildDefaultRoot 'Microsoft\VisualStudio\v15.0' + $Targets = Join-Path $VSToolsPath 'VSSDK\Microsoft.VsSDK.targets' + if (-not (Test-Path $Targets)) { + Warning-Log "VSSDK is not found at default location '$VSToolsPath'. Attempting to override." + # Attempting to fix VS SDK path for VS15 willow install builds + # as MSBUILD failes to resolve it correctly + $VSToolsPath = Join-Path $vs15.VisualStudioInstallDir '..\..\MSBuild\Microsoft\VisualStudio\v15.0' -Resolve + $ConfigureObject.Add('EnvVars', @{ VSToolsPath = $VSToolsPath }) + } + } +} -ev +BuildErrors + +if ($MSBuildExe) { + $MSBuildExe = [System.IO.Path]::GetFullPath($MSBuildExe) + $MSBuildVersion = & $MSBuildExe '/version' '/nologo' + Trace-Log "Using MSBUILD version $MSBuildVersion found at '$MSBuildExe'" + $ConfigureObject.BuildTools.Add('MSBuildExe', $MSBuildExe) } + +New-Item $Artifacts -ItemType Directory -ea Ignore | Out-Null +$ConfigureObject | ConvertTo-Json | Set-Content $ConfigureJson + +Trace-Log "Configuration data has been written to '$ConfigureJson'" + +if ($BuildErrors) { + $ErrorLines = $BuildErrors | %{ ">>> $($_.Exception.Message)" } + Write-Error "Build's completed with $($BuildErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -ErrorAction Stop +} \ No newline at end of file diff --git a/runTests.ps1 b/runTests.ps1 index 74ab3ab7b0d..ddd45ab3d71 100644 --- a/runTests.ps1 +++ b/runTests.ps1 @@ -85,74 +85,53 @@ if (-not $SkipVS15 -and -not $VS15Installed) { $BuildErrors = @() -# Restoring tools required for build -Invoke-BuildStep 'Restoring solution packages' { Restore-SolutionPackages } ` - -skip:$SkipRestore ` - -ev +BuildErrors - Invoke-BuildStep 'Running NuGet.Core unit-tests' { - param($Configuration) Test-CoreProjects $Configuration } ` - -args $Configuration ` -skip:($SkipXProj -or $SkipUnitTests) ` -ev +BuildErrors Invoke-BuildStep 'Running NuGet.Core functional tests' { - param($Configuration) Test-FuncCoreProjects $Configuration } ` - -args $Configuration ` -skip:($SkipXProj -or $SkipFuncTests) ` -ev +BuildErrors Invoke-BuildStep 'Building NuGet.Clients projects - VS14 Toolset' { - param($Configuration, $ReleaseLabel, $BuildNumber) - Build-ClientsProjects $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 14 + Build-ClientsProjects $Configuration $DefaultReleaseLabel $BuildNumber -ToolsetVersion 14 } ` - -args $Configuration, $DefaultReleaseLabel, $BuildNumber ` -skip:$SkipVS14 ` -ev +BuildErrors Invoke-BuildStep 'Running NuGet.Clients unit-tests - VS14 Toolset' { - param($Configuration) Test-ClientsProjects $Configuration -ToolsetVersion 14 } ` - -args $Configuration ` -skip:($SkipVS14 -or $SkipUnitTests) ` -ev +BuildErrors Invoke-BuildStep 'Running NuGet.Clients functional tests - VS14 Toolset' { - param($Configuration) Test-FuncClientsProjects $Configuration -ToolsetVersion 14 } ` - -args $Configuration ` -skip:($SkipVS14 -or $SkipFuncTests) ` -ev +BuildErrors Invoke-BuildStep 'Building NuGet.Clients projects - VS15 Toolset' { - param($Configuration, $ReleaseLabel, $BuildNumber) - Build-ClientsProjects $Configuration $ReleaseLabel $BuildNumber -ToolsetVersion 15 + Build-ClientsProjects $Configuration $DefaultReleaseLabel $BuildNumber -ToolsetVersion 15 } ` - -args $Configuration, $DefaultReleaseLabel, $BuildNumber ` -skip:$SkipVS15 ` -ev +BuildErrors Invoke-BuildStep 'Running NuGet.Clients tests - VS15 Toolset' { - param($Configuration) # We don't run command line tests on VS15 as we don't build a nuget.exe for this version Test-ClientsProjects $Configuration -ToolsetVersion 15 -SkipProjects 'NuGet.CommandLine.Test' } ` - -args $Configuration ` -skip:($SkipVS15 -or $SkipUnitTests) ` -ev +BuildErrors Invoke-BuildStep 'Running NuGet.Clients functional tests - VS15 Toolset' { - param($Configuration) # We don't run command line tests on VS15 as we don't build a nuget.exe for this version Test-FuncClientsProjects $Configuration -ToolsetVersion 15 -SkipProjects 'NuGet.CommandLine.FuncTest' } ` - -args $Configuration ` -skip:($SkipVS15 -or $SkipFuncTests) ` -ev +BuildErrors diff --git a/scripts/cibuild/CreateEndToEndTestPackage.ps1 b/scripts/cibuild/CreateEndToEndTestPackage.ps1 index 3c08afa2c3a..00ed0c95074 100644 --- a/scripts/cibuild/CreateEndToEndTestPackage.ps1 +++ b/scripts/cibuild/CreateEndToEndTestPackage.ps1 @@ -48,6 +48,9 @@ $opts = '/s', '/z', '/r:3', '/w:30', '/np', '/nfl' if ($VerbosePreference) { $opts += '/v' } +else { + $opts += '/ndl', '/njs' +} try { $TestSource = Join-Path $NuGetRoot test\EndToEnd -Resolve @@ -71,10 +74,11 @@ try { $TestPackage = Join-Path $OutputDirectory EndToEnd.zip Write-Verbose "Creating test package '$TestPackage'" + Remove-Item $TestPackage -Force -ea Ignore | Out-Null New-ZipArchive $WorkingDirectory $TestPackage Write-Output "Created end-to-end test package for toolset '${ToolsetVersion}.0' at '$TestPackage'" } finally { - rm $workingDirectory -r -force -WhatIf:$false + rm $workingDirectory -r -Force -WhatIf:$false } \ No newline at end of file diff --git a/scripts/utils/UpdateNuGetVersion.ps1 b/scripts/utils/UpdateNuGetVersion.ps1 index e38311cf6e7..254c34d9c6d 100644 --- a/scripts/utils/UpdateNuGetVersion.ps1 +++ b/scripts/utils/UpdateNuGetVersion.ps1 @@ -58,9 +58,6 @@ Write-Output "Updating NuGet version [$OldVersion => $NewVersion]" gci -r project.json | %{ $_.FullName } | ReplaceTextInFiles -old $OldVersion -new $NewVersion $miscFiles = @( - "src\NuGet.Clients\NuGet.CommandLine\NuGet.CommandLine.nuspec" - "src\NuGet.Clients\VsExtension\source.extension.dev14.vsixmanifest", - "src\NuGet.Clients\VsExtension\source.extension.dev15.vsixmanifest", "src\NuGet.Clients\VsExtension\NuGetPackage.cs", "build\common.props", "build\common.ps1", diff --git a/src/NuGet.Clients/PackageManagement.VisualStudio/NuGet.PackageManagement.VisualStudio.csproj b/src/NuGet.Clients/PackageManagement.VisualStudio/NuGet.PackageManagement.VisualStudio.csproj index a100326100c..4a0dde3c0b2 100644 --- a/src/NuGet.Clients/PackageManagement.VisualStudio/NuGet.PackageManagement.VisualStudio.csproj +++ b/src/NuGet.Clients/PackageManagement.VisualStudio/NuGet.PackageManagement.VisualStudio.csproj @@ -1,7 +1,7 @@  - + Debug {306CDDFA-FF0B-4299-930C-9EC6C9308160} @@ -18,35 +18,23 @@ - - - - - - - - - - - - - False - - - False - - - - + + + True + $(EnlistmentRoot)\packages\Microsoft.VisualStudio.ProjectSystem.14.1.127-pre\lib\net451\Microsoft.VisualStudio.ProjectSystem.Interop.dll True - + + + + True + $(EnlistmentRoot)\packages\Microsoft.VisualStudio.ProjectSystem.15.0.183-pre\lib\net451\Microsoft.VisualStudio.ProjectSystem.Interop.dll True @@ -54,16 +42,20 @@ + + + False + + + False + + $(MSBuildToolsPath)\Microsoft.Build.dll False - - $(VisualStudioInstallDir)PublicAssemblies\Microsoft.VisualStudio.VCProjectEngine.dll - True - diff --git a/src/NuGet.Clients/VsExtension/VsExtension.csproj b/src/NuGet.Clients/VsExtension/VsExtension.csproj index a641b562fde..0b8cc6522e6 100644 --- a/src/NuGet.Clients/VsExtension/VsExtension.csproj +++ b/src/NuGet.Clients/VsExtension/VsExtension.csproj @@ -32,7 +32,7 @@ Program - $(VisualStudioInstallDir)\Common7\IDE\devenv.exe + $(DevEnvDir)devenv.exe /rootsuffix Exp /log True True @@ -230,13 +230,13 @@ - - - - - - - + + + + + + + diff --git a/src/NuGet.Clients/VsExtension/source.extension.vs14.vsixmanifest b/src/NuGet.Clients/VsExtension/source.extension.vs14.vsixmanifest index 8709916f3f6..54285f32e59 100644 --- a/src/NuGet.Clients/VsExtension/source.extension.vs14.vsixmanifest +++ b/src/NuGet.Clients/VsExtension/source.extension.vs14.vsixmanifest @@ -1,7 +1,7 @@ - + NuGet Package Manager for Visual Studio 2015 A collection of tools to automate the process of downloading, installing, upgrading, configuring, and removing packages from a VS Project. Resources/nuget_96.png diff --git a/src/NuGet.Clients/VsExtension/source.extension.vs15.vsixmanifest b/src/NuGet.Clients/VsExtension/source.extension.vs15.vsixmanifest index a6c785ead34..f458138210c 100644 --- a/src/NuGet.Clients/VsExtension/source.extension.vs15.vsixmanifest +++ b/src/NuGet.Clients/VsExtension/source.extension.vs15.vsixmanifest @@ -1,7 +1,7 @@ - + NuGet Package Manager for Visual Studio 15 A collection of tools to automate the process of downloading, installing, upgrading, configuring, and removing packages from a VS Project. Resources/nuget_96.png