Skip to content

Commit 69338ab

Browse files
committed
Extract package information from .crate file
1 parent df37d7f commit 69338ab

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

eng/scripts/Language-Settings.ps1

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,29 @@ function Get-rust-AdditionalValidationPackagesFromPackageSet ($packagesWithChang
142142
# $GetPackageInfoFromPackageFileFn = "Get-${Language}-PackageInfoFromPackageFile"
143143
function Get-rust-PackageInfoFromPackageFile([IO.FileInfo]$pkg, [string]$workingDirectory) {
144144
#$pkg will be a FileInfo object for the Cargo.toml file in a package artifact directory
145-
$package = cargo read-manifest --manifest-path $pkg.FullName | ConvertFrom-Json
145+
146+
# Create a temporary folder for extraction
147+
$extractionPath = Join-Path [System.IO.Path]::GetTempPath(), ([System.IO.Path]::GetRandomFileName())
148+
New-Item -ItemType Directory -Path $extractionPath | Out-Null
149+
150+
$originalLocation = Get-Location
151+
try {
152+
Set-Location $extractionPath
153+
tar -xvf $pkg.FullName
154+
}
155+
finally {
156+
Set-Location $originalLocation
157+
}
158+
159+
$cargoTomlPath = Join-Path $extractionPath, $pkg.BaseName, 'Cargo.toml'
160+
161+
Write-Host "Reading package info from $cargoTomlPath"
162+
if (!(Test-Path $cargoTomlPath)) {
163+
LogError "The Cargo.toml file was not found in the package artifact at $cargoTomlPath"
164+
throw "error"
165+
}
166+
167+
$package = cargo read-manifest --manifest-path $cargoTomlPath | ConvertFrom-Json
146168

147169
$packageName = $package.name
148170
$packageVersion = $package.version

0 commit comments

Comments
 (0)