Skip to content
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

Fix MakeApiBaselines.ps1 script #4587

Merged
merged 6 commits into from
Oct 23, 2023
Merged

Conversation

iliar-turdushev
Copy link
Contributor

@iliar-turdushev iliar-turdushev commented Oct 19, 2023

When running MakeApiBaselines.ps1 script it was failing and reporting an error that it couldn't find SDK 8.x.x-rtm.... The error was occurring because the script was using global dotnet tool rather than locally installed .\.dotnet\dotnet.exe.

The PR fixes the script to use the local dotnet tool.

Microsoft Reviewers: Open in CodeFlow

Copy link
Member

@geeknoid geeknoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@RussKie RussKie self-requested a review October 19, 2023 21:29
@RussKie
Copy link
Member

RussKie commented Oct 19, 2023

Please let me review this.

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst this change technically is not incorrect, it requires the caller the have restored the toolset.

I suggest the following change which allows the scripts to be run as a standalone:

diff --git a/scripts/MakeApiBaselines.ps1 b/scripts/MakeApiBaselines.ps1
index c524a201d9..3fc3c3d390 100644
--- a/scripts/MakeApiBaselines.ps1
+++ b/scripts/MakeApiBaselines.ps1
@@ -10,14 +10,17 @@ if ($PSVersionTable.PSVersion.Major -lt 6) {
     exit
 }
 
+# Install required toolset
+. $PSScriptRoot/../eng/common/tools.ps1
+InitializeDotNetCli -install $true | Out-Null
+
 $Project = $PSScriptRoot + "/../eng/Tools/ApiChief/ApiChief.csproj"
 $Command = $PSScriptRoot + "/../artifacts/bin/ApiChief/Debug/net8.0/ApiChief.dll"
-$DotnetCommand = $PSScriptRoot + "/../.dotnet/dotnet"
 $LibrariesFolder = $PSScriptRoot + "/../src/Libraries"
 
 Write-Output "Building ApiChief tool"
 
-& $DotnetCommand build $Project --nologo --verbosity q
+dotnet build $Project --nologo --verbosity q
 
 Write-Output "Creating API baseline files in the src/Libraries folder"
 
@@ -26,5 +29,5 @@ Get-ChildItem -Path $LibrariesFolder -Depth 1 -Include *.csproj | ForEach-Object
     $name = Split-Path $_.FullName -LeafBase
     $path = "$PSScriptRoot\..\artifacts\bin\$name\Debug\net8.0\$name.dll"
     Write-Host "  Processing" $name
-    & $DotnetCommand $Command $path emit baseline -o "$LibrariesFolder/$name/$name.json"
+    dotnet $Command $path emit baseline -o "$LibrariesFolder/$name/$name.json"
 }

@iliar-turdushev
Copy link
Contributor Author

@RussKie I've applied the changes. Thank you.

@RussKie RussKie merged commit d74d9f4 into release/8.0 Oct 23, 2023
6 checks passed
@RussKie RussKie deleted the iliarturdu/fix-makeapibaselines branch October 23, 2023 00:58
@ghost ghost locked as resolved and limited conversation to collaborators Nov 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MakeApiBaselines.ps1 script fails reporting it cannot find the required .NET SDK
4 participants