File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ # This script copies the downloaded runtime into the Program Files directory.
2
+ # This is necessary in certain situations when running tests in Visual Studio.
3
+
4
+ # Check if script is running as admin
5
+ $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity ]::GetCurrent())
6
+ if (-not $currentPrincipal.IsInRole ([Security.Principal.WindowsBuiltInRole ]::Administrator)) {
7
+ Write-Host " This script must be run as an administrator." - ForegroundColor Red
8
+ exit 1
9
+ }
10
+
11
+ # Read the runtime version.
12
+ [xml ]$versionPropsXml = Get-Content " $PSScriptRoot \Versions.props"
13
+ # In XPath expression syntax, `//` means, "select the node that matches regardless of the location".
14
+ $runtimeVersion = $versionPropsXml.SelectSingleNode (" //MicrosoftNETCorePlatformsPackageVersion" ).InnerText
15
+
16
+ # Check if the repo was built.
17
+ $runtimeRepoPath = " $PSScriptRoot \..\.dotnet\shared\Microsoft.NETCore.App\$runtimeVersion "
18
+ if (-not (Test-Path - Path $runtimeRepoPath )) {
19
+ Write-Host " The repo has not been built. Please run 'build.cmd' from the repo root." - ForegroundColor Red
20
+ exit 1
21
+ }
22
+
23
+ # Copy the runtime to the Program Files if it doesn't exist.
24
+ $runtimeProgramFilesPath = " $env: ProgramFiles \dotnet\shared\Microsoft.NETCore.App\$runtimeVersion "
25
+ if (-not (Test-Path - Path $runtimeProgramFilesPath )) {
26
+ Copy-Item - Path $runtimeRepoPath - Destination $runtimeProgramFilesPath - Recurse
27
+ Write-Host " Runtime copied to: $runtimeProgramFilesPath "
28
+ }
You can’t perform that action at this time.
0 commit comments