Fix UsePythonVersion@0 installing incomplete Python files on Windows #21077
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The UsePythonVersion@0 task was installing incomplete Python installations on Windows, missing critical files like
python312.lib
and showing warnings about missing platform independent libraries.Problem
From the issue logs, we can see the task would:
setup.ps1
scriptpython312.lib
files needed for linkingLib
directory)The logs showed warnings like:
Root Cause
The issue was in the
setup.ps1
script that comes with Python archives from GitHub Actions python-versions. The script:cd $PythonArchPath && call $PythonExecName $ExecParams /quiet
Solution
Installation Validation
Added
validatePythonInstallation()
function that checks for essential components after installation:Lib
directory (platform independent libraries)libs
directory and specificallypython{major}{minor}.lib
file (e.g.,python312.lib
)include
directory (header files)Alternative Installation Method
Added
installPythonAlternative()
fallback when standard installation fails or produces incomplete results:Enhanced Error Handling
Files Changed
Tasks/UsePythonVersionV0/installpythonversion.ts
: Core fix with validation and alternative installationTasks/UsePythonVersionV0/Tests/L0ValidatesIncompleteInstallation.ts
: Test case for incomplete installationsTesting
This fix resolves the regression in v0.248.1 where Python installations were incomplete, ensuring all necessary components are installed while maintaining backward compatibility.
Fixes #20999.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
03nvsblobprodwcus014.vsblob.vsassets.io
npm install
(dns block)055vsblobprodwcus02.vsblob.vsassets.io
npm install
(dns block)1g1vsblobprodwcus01.vsblob.vsassets.io
npm install
(dns block)3eavsblobprodwcus03.vsblob.vsassets.io
npm install
(dns block)3zgvsblobprodwcus024.vsblob.vsassets.io
npm install
(dns block)40qvsblobprodwcus022.vsblob.vsassets.io
npm install
(dns block)4fdvsblobprodwcus012.vsblob.vsassets.io
npm install
(dns block)5tbvsblobprodwcus06.vsblob.vsassets.io
npm install
(dns block)61cvsblobprodwcus010.vsblob.vsassets.io
npm install
(dns block)73dvsblobprodwcus07.vsblob.vsassets.io
npm install
(dns block)8usvsblobprodwcus011.vsblob.vsassets.io
npm install
(dns block)9owvsblobprodwcus020.vsblob.vsassets.io
npm install
(dns block)arpvsblobprodwcus017.vsblob.vsassets.io
npm install
(dns block)crcvsblobprodwcus021.vsblob.vsassets.io
npm install
(dns block)fslvsblobprodwcus015.vsblob.vsassets.io
npm install
(dns block)grnvsblobprodwcus04.vsblob.vsassets.io
npm install
(dns block)k92vsblobprodwcus08.vsblob.vsassets.io
npm install
(dns block)mnzvsblobprodwcus05.vsblob.vsassets.io
npm install
(dns block)pl8vsblobprodwcus09.vsblob.vsassets.io
npm install
(dns block)uubvsblobprodwcus018.vsblob.vsassets.io
npm install
(dns block)vwmvsblobprodwcus016.vsblob.vsassets.io
npm install
(dns block)x4wvsblobprodwcus013.vsblob.vsassets.io
npm install
(dns block)xg1vsblobprodwcus019.vsblob.vsassets.io
npm install
(dns block)xlkvsblobprodwcus023.vsblob.vsassets.io
npm install
(dns block)If you need me to access, download, or install something from one of these locations, you can either: