diff --git a/docs/BuildFromSource.md b/docs/BuildFromSource.md index 0a95e6cd55e9..06a901a91388 100644 --- a/docs/BuildFromSource.md +++ b/docs/BuildFromSource.md @@ -16,6 +16,7 @@ Building ASP.NET Core on Windows requires: * Windows 7 or higher * At least 10 GB of disk space and a good internet connection (our build scripts download a lot of tools and dependencies) * Visual Studio 2017. + * To install the exact required components, run scripts\install_vs.ps1. This will use VS2017. * Git. * (Optional) some optional components, like the SignalR Java client, may require * NodeJS diff --git a/scripts/VsRequirements/vs.json b/scripts/VsRequirements/vs.json new file mode 100644 index 000000000000..f30994f9f53a --- /dev/null +++ b/scripts/VsRequirements/vs.json @@ -0,0 +1,31 @@ +{ + "channelUri": "https://aka.ms/vs/15/release/channel", + "channelId": "VisualStudio.15.Release", + "productId": "Microsoft.VisualStudio.Product.Enterprise", + "includeRecommended": false, + "addProductLang": [ + "en-US" + ], + "add": [ + "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Microsoft.VisualStudio.Component.Windows81SDK", + "Microsoft.Net.Component.4.7.2.TargetingPack", + "Microsoft.Net.Component.4.7.2.SDK", + "Microsoft.Net.Component.4.7.1.TargetingPack", + "Microsoft.Net.Component.4.7.TargetingPack", + "Microsoft.Net.Component.4.6.2.TargetingPack", + "Microsoft.Net.Component.4.6.1.TargetingPack", + "Microsoft.Net.Component.4.6.TargetingPack", + "Microsoft.Net.Component.4.5.2.TargetingPack", + "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81", + "Microsoft.VisualStudio.Component.Azure.Storage.Emulator", + "Microsoft.VisualStudio.Component.VC.ATL", + "Microsoft.VisualStudio.Component.Windows10SDK.15063.Desktop", + "Microsoft.VisualStudio.Component.Windows10SDK.17134", + "Microsoft.VisualStudio.Workload.ManagedDesktop", + "Microsoft.VisualStudio.Workload.NetWeb", + "Microsoft.VisualStudio.Workload.NetCoreTools", + "Microsoft.VisualStudio.Workload.NativeDesktop", + "Microsoft.VisualStudio.Workload.VisualStudioExtension" + ] +} diff --git a/scripts/install_vs.ps1 b/scripts/install_vs.ps1 new file mode 100644 index 000000000000..bb2c506fce6c --- /dev/null +++ b/scripts/install_vs.ps1 @@ -0,0 +1,66 @@ +<# +.SYNOPSIS + Installs or updates Visual Studio on a local developer machine +.PARAMETER Update + Update VS to latest version instead of modifying the installation to include new workloads. +.PARAMETER Quiet + Whether to run installer in the background +#> +[CmdletBinding(DefaultParameterSetName = 'Default')] +param( + [switch]$Update, + [switch]$Quiet +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 1 + +$intermedateDir = "$PSScriptRoot\obj" +mkdir $intermedateDir -ErrorAction Ignore | Out-Null + +$bootstrapper = "$intermedateDir\vs_enterprise1.exe" +Invoke-WebRequest -Uri 'https://aka.ms/vs/15/release/vs_enterprise.exe' -OutFile $bootstrapper + +$vsJson = "$PSScriptRoot\VsRequirements\vs.json" +# no backslashes - this breaks the installer +$vsInstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise" +$arguments = @( + '--installPath', "`"$vsInstallPath`"", + '--in', $vsJson, + '--wait', + '--norestart') + +if ($Update) { + $arguments = ,'update' + $arguments +} +else { + $arguments = ,'modify' + $arguments +} + +if ($Quiet) { + $arguments += '--quiet' +} + +Write-Host "Running '$bootstrapper $arguments' on $(hostname)" +$process = Start-Process -FilePath $bootstrapper ` + -ArgumentList $arguments ` + -Verb runas ` + -PassThru ` + -ErrorAction Stop +Write-Host "pid = $($process.Id)" +Wait-Process -InputObject $process +Write-Host "exit code = $($process.ExitCode)" + +# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio#error-codes +if ($process.ExitCode -eq 3010) { + Write-Warning "Agent $(hostname) requires restart to finish the VS update" +} +elseif ($process.ExitCode -eq 5007) { + Write-Error "Operation was blocked - the computer does not meet the requirements" +} +elseif (($process.ExitCode -eq 5004) -or ($process.ExitCode -eq 1602)) { + Write-Error "Operation was canceled" +} +elseif ($process.ExitCode -ne 0) { + Write-Error "Installation failed on $(hostname) for unknown reason" +} \ No newline at end of file diff --git a/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs b/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs index 570a60af724e..bd8a6afe68a1 100644 --- a/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs +++ b/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs @@ -60,7 +60,8 @@ public async Task RunClientTests() private static async Task CreateDeployments(ILoggerFactory loggerFactory) { - var solutionPath = TestPathUtilities.GetSolutionRootDirectory("CORS"); + var solutionPath = TestPathUtilities.GetSolutionRootDirectory("Middleware"); + var configuration = #if RELEASE "Release"; @@ -73,7 +74,7 @@ private static async Task CreateDeployments(ILoggerFact TargetFramework = "netcoreapp3.0", RuntimeFlavor = RuntimeFlavor.CoreClr, ServerType = ServerType.Kestrel, - ApplicationPath = Path.Combine(solutionPath, "samples", "SampleDestination"), + ApplicationPath = Path.Combine(solutionPath, "CORS", "samples", "SampleDestination"), PublishApplicationBeforeDeployment = false, ApplicationType = ApplicationType.Portable, Configuration = configuration, @@ -87,7 +88,7 @@ private static async Task CreateDeployments(ILoggerFact TargetFramework = "netcoreapp3.0", RuntimeFlavor = RuntimeFlavor.CoreClr, ServerType = ServerType.Kestrel, - ApplicationPath = Path.Combine(solutionPath, "samples", "SampleOrigin"), + ApplicationPath = Path.Combine(solutionPath, "CORS", "samples", "SampleOrigin"), PublishApplicationBeforeDeployment = false, ApplicationType = ApplicationType.Portable, Configuration = configuration,