-
Notifications
You must be signed in to change notification settings - Fork 873
Let contributors F5 the F# VS extension without a matching-Roslyn VS #20303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+67
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Launch VS on VisualFSharp.slnx, building the F# VS extension against the Roslyn your installed VS | ||
| # ships (not the newer one flowed into the repo) so F5 loads it. See DEVGUIDE.md. Needs VS Roslyn >= 5.10. | ||
| # -RoslynVersion forces a version (e.g. if the exact VS build isn't on a feed); any 5.Y.* binds identically. | ||
| [CmdletBinding()] | ||
| param( | ||
| [string]$RoslynVersion, | ||
| [string]$DevEnv, | ||
| [string]$Solution = 'VisualFSharp.slnx', | ||
| [switch]$DryRun | ||
| ) | ||
| Set-StrictMode -Version Latest; $ErrorActionPreference = 'Stop'; $root = $PSScriptRoot | ||
|
|
||
| if (-not $DevEnv) { | ||
| $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' | ||
| $DevEnv = if ($env:DevEnvDir) { Join-Path $env:DevEnvDir 'devenv.exe' } | ||
| elseif (Test-Path $vswhere) { & $vswhere -latest -prerelease -property productPath 2>$null } | ||
| } | ||
| if (-not ($DevEnv -and (Test-Path $DevEnv))) { throw 'devenv.exe not found; run from a VS Developer prompt or pass -DevEnv.' } | ||
|
|
||
| if (-not $RoslynVersion) { | ||
| $dll = "$(Split-Path $DevEnv)\CommonExtensions\Microsoft\VBCSharp\LanguageServices\Microsoft.CodeAnalysis.dll" | ||
| if (-not (Test-Path $dll)) { throw "Can't detect your VS Roslyn version; pass -RoslynVersion." } | ||
| $RoslynVersion = ([System.Diagnostics.FileVersionInfo]::GetVersionInfo($dll).ProductVersion -split '\+')[0] | ||
| } | ||
| $minor = [version](($RoslynVersion -split '-')[0]) | ||
| if ($minor -lt [version]'5.10.0') { | ||
| throw "Your VS ships Roslyn $RoslynVersion but the repo references packages from >= 5.10 (unified ExternalAccess, #20099). Update VS or deploy a local Roslyn." | ||
| } | ||
| Write-Host "Building the F# extension against Roslyn $RoslynVersion ($DevEnv)." | ||
|
|
||
| # Repoint every Roslyn package (versions set in eng/Version.Details.props) via a props file MSBuild | ||
| # imports after it through the CustomAfterMicrosoftCommonProps hook the launched VS inherits. | ||
| $names = 'MicrosoftCodeAnalysis', 'MicrosoftCodeAnalysisCompilers', 'MicrosoftCodeAnalysisCSharp', | ||
| 'MicrosoftCodeAnalysisEditorFeatures', 'MicrosoftCodeAnalysisEditorFeaturesText', 'MicrosoftCodeAnalysisFeatures', | ||
| 'MicrosoftVisualStudioLanguageServices', 'MicrosoftVisualStudioLanguageServicesExternalAccess' | ||
| $override = Join-Path $root 'artifacts\RoslynOverride.props' | ||
| New-Item -ItemType Directory -Force (Split-Path $override) | Out-Null | ||
| "<Project><PropertyGroup>$(-join ($names | ForEach-Object { "<${_}Version>$RoslynVersion</${_}Version>" }))</PropertyGroup></Project>" | | ||
| Set-Content -LiteralPath $override -Encoding UTF8 | ||
|
|
||
| # Apply to THIS process only, restoring in finally so it can't leak into a later build.cmd/CI run | ||
| # (which must keep the flowed Roslyn); the launched VS snapshots the env for its F5/restore builds. | ||
| $vars = @{ | ||
| CustomAfterMicrosoftCommonProps = $override | ||
| DOTNET_ROOT = Join-Path $root '.dotnet' | ||
| 'DOTNET_ROOT(x86)' = Join-Path $root '.dotnet\x86' | ||
| PATH = "$(Join-Path $root '.dotnet');$env:PATH" | ||
| RunNetFrameworkApiCompat = 'false' | ||
| RunRefApiCompat = 'false' | ||
| } | ||
| $saved = @{}; foreach ($k in $vars.Keys) { $saved[$k] = [Environment]::GetEnvironmentVariable($k) } | ||
| try { | ||
| foreach ($k in $vars.Keys) { Set-Item -LiteralPath "Env:\$k" -Value $vars[$k] } | ||
| if ($DryRun) { Write-Host "DryRun: $override"; return } | ||
| & (Join-Path $root 'Restore.cmd') | ||
| if ($LASTEXITCODE) { throw "Restore failed for Roslyn $RoslynVersion; try another 5.$($minor.Minor).* build via -RoslynVersion." } | ||
| Start-Process $DevEnv "`"$(Join-Path $root $Solution)`"" | ||
| Write-Host 'Launched VS. Set VisualFSharpDebug as the startup project, then F5 / Ctrl+F5.' | ||
| } | ||
| finally { | ||
| foreach ($k in $saved.Keys) { | ||
| if ($null -eq $saved[$k]) { Remove-Item -LiteralPath "Env:\$k" -ErrorAction SilentlyContinue } else { Set-Item -LiteralPath "Env:\$k" -Value $saved[$k] } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.