-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMicrosoft.PowerShell_dotnet-profile.ps1
More file actions
131 lines (110 loc) · 3.86 KB
/
Microsoft.PowerShell_dotnet-profile.ps1
File metadata and controls
131 lines (110 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# 1.0.9538.17986
[CmdletBinding()]
param( [switch] $completions )
$VS_DIR__="C:\Program Files\Microsoft Visual Studio\2022"
"$($VS_DIR__)\Community\MSBuild\Current\Bin\amd64", `
"$($VS_DIR__)\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator", `
"$($VS_DIR__)\Professional\Common7\IDE", `
"$($VS_DIR__)\Professional\MSBuild\Current\Bin\amd64", `
"C:\Portable Apps\IlSpy", `
"C:\Program Files (x86)\GitHub CLI" |? { Test-Path $_ } | Add-DirectoryToPath
if ($completions.IsPresent) {
Write-Host "Loading CLI completions for dotnet." -Foreground Darkgray
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}
$Env:PROJECT_DIRECTORY = Join-Path -Path ([IO.Path]::GetPathRoot($Env:USERPROFILE)) -ChildPath "Projects"
Function me { Push-Location ([IO.Path]::Combine($Env:PROJECT_DIRECTORY, "springcomp")) }
Function pro { Set-Location $Env:PROJECT_DIRECTORY }
Function run-tests {
[CmdletBinding()]
param(
[string]$pattern = "*Tests.csproj",
[Alias("html")]
[switch]$visual
)
Get-ChildItem -Path $PATH -Recurse -Filter $pattern | % {
run-test -Path $_.FullName `
-Html:$visual
}
}
Function run-test {
[CmdletBinding()]
param(
[string]$path,
[Alias("html")]
[switch]$visual
)
$projectDir = Split-Path -Path $path
$resultsDir = Join-Path -Path $projectDir -ChildPath "TestResults"
dotnet test $path `
--collect:"Code Coverage" `
--results-directory:"$resultsDir"
# find test results
if (-not (Test-Path -Path $resultsDir)) {
Write-Host "Missing test results" -ForegroundColor Red
return
}
$collectedDir = (Get-ChildItem -Path $resultsDir |`
Sort-Object -Property LastWriteTime |`
Select-Object -First 1).FullName
if (-not $collectedDir) {
Write-Host "Missing collected code coverage" -ForegroundColor Red
return
}
$coverage = Get-ChildItem -Path $collectedDir -Filter "*.coverage" |`
Select-Object -First 1
if (-not $coverage) {
Write-Host "Missing collected code coverage output" -ForegroundColor Red
return
}
dotnet coverage merge $coverage `
--output $collectedDir/output.xml `
--output-format xml `
--disable-console-output
reportgenerator `
-reports:"$collectedDir/output.xml" `
-targetdir:"$collectedDir/coveragereport" `
-reporttypes:Html `
-verbosity:Error
if ($visual.IsPresent) {
start "$collectedDir/coveragereport/Index.html"
}
reportgenerator `
-reports:"$collectedDir/output.xml" `
-targetdir:"$collectedDir/coveragereport" `
-reporttypes:TextSummary `
-verbosity:Off
Write-Host (Get-Content -Raw -Path "$collectedDir/coveragereport/Summary.txt")
}
Function vs {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias("Solution")]
[Alias("Fullname")]
[Alias("PSPath")]
[string]$path = $null
)
if (-not $path) {
$solution = Get-ChildItem -Path $PWD -Filter "*.sln?" | Select-Object -First 1
} else {
$solution = Get-Item -Path $path
}
Write-Host $solution
if ($solution) { & devenv.exe $solution.FullName }
else {
$project = Get-ChildItem -Path $PWD -Filter "*.csproj" | Select-Object -First 1
Write-Host $project
if ($project) { & devenv.exe $project.FullName }
else {
Write-Host "Launching Visual Studio"
& devenv.exe $args
}
}
}