Skip to content

[Dogfood] Show changes in prompt #48120

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions eng/dogfood.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function Print-Usage() {
Write-Host "if it is set, will be used."
}

function Global:prompt {"(dogfood) PS $PWD> "}

if ($help -or (($command -ne $null) -and ($command.Contains("/help") -or $command.Contains("/?")))) {
Print-Usage
Expand All @@ -38,10 +37,10 @@ try {
. $PSScriptroot\restore-toolset.ps1

$env:SDK_REPO_ROOT = $RepoRoot

$TestDotnetRoot = Join-Path $ArtifactsDir "bin\redist\$configuration\dotnet"

$testDotnetVersion = (Get-Childitem -Directory "$TestDotnetRoot\sdk")[-1].Name

$env:TestDotnetSdkHash = Get-Content -Path (Join-Path $TestDotnetRoot "sdk\$testDotnetVersion\.version") -TotalCount 1
$env:DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR = Join-Path $TestDotnetRoot "sdk\$testDotnetVersion\Sdks"
$env:MicrosoftNETBuildExtensionsTargets = Join-Path $ArtifactsDir "bin\$configuration\Sdks\Microsoft.NET.Build.Extensions\msbuildExtensions\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.targets"

Expand All @@ -52,13 +51,25 @@ try {
# Locally built SDK package version is Major.Minor.0-dev, which won't be available.
$env:BuildWithNetFrameworkHostedCompiler = $false

# Prompt
function global:prompt {
# Run command agains $env:SDK_REPO_ROOT to see if there are any changes
$testDotnetSdkCurrentHash = git -C $env:SDK_REPO_ROOT rev-parse HEAD
$hasGitChanges = $testDotnetSdkCurrentHash -ne $env:TestDotnetSdkHash
if ($hasGitChanges) {
"$([char]0x1b)[0;35m(dotnet dogfood *)$([char]0x1b)[0m $PWD > "
} else {
"$([char]0x1b)[0;35m(dotnet dogfood)$([char]0x1b)[0m $PWD > "
}
}

if ($command -eq $null -and $env:DOTNET_SDK_DOGFOOD_SHELL -ne $null) {
$command = , $env:DOTNET_SDK_DOGFOOD_SHELL
}

if ($command -ne $null) {
$Host.UI.RawUI.WindowTitle = "SDK Test ($RepoRoot) ($configuration)"
& $command[0] $command[1..($command.Length-1)]
& $command[0] $command[1..($command.Length-1)]
}
}
catch {
Expand Down
13 changes: 12 additions & 1 deletion eng/dogfood.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ export SDK_REPO_ROOT="$repo_root"
testDotnetRoot="$artifacts_dir/bin/redist/$configuration/dotnet"
testDotnetVersion=$(ls $testDotnetRoot/sdk)
export DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR="$testDotnetRoot/sdk/$testDotnetVersion/Sdks"
export TestDotnetSdkHash=$(head -1 "$testDotnetRoot/sdk/$testDotnetVersion/.version")
export MicrosoftNETBuildExtensionsTargets="$artifacts_dir/bin/$configuration/Sdks/Microsoft.NET.Build.Extensions/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.targets"

export PATH=$testDotnetRoot:$PATH
export DOTNET_ROOT=$testDotnetRoot
export PS1="(dogfood) $PS1"

testDotnetSdkCurrentHash = git -c $SDK_REPO_ROOT rev-parse HEAD
hasGitChanges = $testDotnetSdkCurrentHash != $TestDotnetSdkHash

if [$hasGitChanges]; then
export PS1="\x1b[0;35m(dotnet dogfood*)\x1b[0m $PS1"
else
export PS1="\x1b[0;35m(dotnet dogfood)\x1b[0m $PS1"
fi


35 changes: 35 additions & 0 deletions eng/eng.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dependabot", "dependabot\dependabot.csproj", "{8F679A97-6BF2-8E61-764F-4CB50EF6848F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{881589EE-639B-0A35-DBCE-5D94E4FC90C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tools", "common\internal\Tools.csproj", "{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Release|Any CPU.Build.0 = Release|Any CPU
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB} = {881589EE-639B-0A35-DBCE-5D94E4FC90C0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0D38F9D6-853D-4DB5-A726-8C01C293B732}
EndGlobalSection
EndGlobal