Skip to content

Commit b2c1dd8

Browse files
Ensure nuget restore runs before tests and nuget config is used
1 parent 8a1ec44 commit b2c1dd8

8 files changed

Lines changed: 55 additions & 36 deletions

File tree

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
DevFeedName: 'public/azure-sdk-for-python'
2+
DevFeedName: "public/azure-sdk-for-python"
33
EnableTwineAuth: true
44
EnablePipAuth: true
55
EnableUvAuth: true
@@ -18,32 +18,32 @@ steps:
1818
displayName: Setup DevOpsFeedName
1919
2020
- ${{ if eq(parameters.EnableTwineAuth, true) }}:
21-
- task: TwineAuthenticate@0
22-
displayName: 'Twine Authenticate to feed'
23-
inputs:
24-
artifactFeeds: $(DevFeedName)
21+
- task: TwineAuthenticate@0
22+
displayName: "Twine Authenticate to feed"
23+
inputs:
24+
artifactFeeds: $(DevFeedName)
2525

2626
- ${{ if eq(parameters.EnablePipAuth, true) }}:
27-
- task: PipAuthenticate@1
28-
displayName: 'Pip Authenticate to feed'
29-
inputs:
30-
artifactFeeds: $(DevFeedName)
31-
onlyAddExtraIndex: false
27+
- task: PipAuthenticate@1
28+
displayName: "Pip Authenticate to feed"
29+
inputs:
30+
artifactFeeds: $(DevFeedName)
31+
onlyAddExtraIndex: false
3232

3333
- ${{ if eq(parameters.EnableUvAuth, true) }}:
34-
- pwsh: |
35-
if ($env:PIP_INDEX_URL) {
36-
Write-Host "Found pip index URL: $($env:PIP_INDEX_URL)"
37-
# UV_DEFAULT_INDEX is the canonical replacement for the deprecated UV_INDEX_URL (uv 0.4.23+).
38-
# PIP_INDEX_URL is set by PipAuthenticate@1 and contains embedded credentials, which uv
39-
# will use for Basic auth against the ADO feed (and its PyPI upstream) per astral-sh/uv#12651.
40-
Write-Host "##vso[task.setvariable variable=UV_DEFAULT_INDEX]$($env:PIP_INDEX_URL)"
41-
# Disable keyring so uv uses the URL-embedded credentials directly.
42-
Write-Host "##vso[task.setvariable variable=UV_KEYRING_PROVIDER]disabled"
43-
} else {
44-
Write-Host "##[warning]PIP_INDEX_URL not set - uv will fall back to public PyPI."
45-
}
46-
# Force any managed Python downloads to go directly to GitHub releases
47-
# rather than the default CDN (releases.astral.sh).
48-
Write-Host "##vso[task.setvariable variable=UV_PYTHON_INSTALL_MIRROR]https://github.com/astral-sh/python-build-standalone/releases/download"
49-
displayName: 'Configure UV Authentication'
34+
- pwsh: |
35+
if ($env:PIP_INDEX_URL) {
36+
Write-Host "Found pip index URL: $($env:PIP_INDEX_URL)"
37+
# UV_DEFAULT_INDEX is the canonical replacement for the deprecated UV_INDEX_URL (uv 0.4.23+).
38+
# PIP_INDEX_URL is set by PipAuthenticate@1 and contains embedded credentials, which uv
39+
# will use for Basic auth against the ADO feed (and its PyPI upstream) per astral-sh/uv#12651.
40+
Write-Host "##vso[task.setvariable variable=UV_DEFAULT_INDEX]$($env:PIP_INDEX_URL)"
41+
# Disable keyring so uv uses the URL-embedded credentials directly.
42+
Write-Host "##vso[task.setvariable variable=UV_KEYRING_PROVIDER]disabled"
43+
} else {
44+
Write-Host "##[warning]PIP_INDEX_URL not set - uv will fall back to public PyPI."
45+
}
46+
# Force any managed Python downloads to go directly to GitHub releases
47+
# rather than the default CDN (releases.astral.sh).
48+
Write-Host "##vso[task.setvariable variable=UV_PYTHON_INSTALL_MIRROR]https://github.com/astral-sh/python-build-standalone/releases/download"
49+
displayName: "Configure UV Authentication"

eng/common/pipelines/templates/steps/maven-authenticate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ steps:
77
$m2Dir = if ($env:USERPROFILE) { "$env:USERPROFILE\.m2" } else { "$HOME/.m2" }
88
New-Item -ItemType Directory -Force -Path $m2Dir | Out-Null
99
Copy-Item -Path "${{ parameters.SourceDirectory }}/eng/settings.xml" -Destination "$m2Dir/settings.xml"
10-
displayName: 'Setup Maven mirror settings'
10+
displayName: "Setup Maven mirror settings"
1111
1212
# Authenticate with Azure Artifacts feeds
1313
# MavenAuthenticate adds <server> entries to ~/.m2/settings.xml matching mirror id 'azure-sdk-for-java'
1414
- task: MavenAuthenticate@0
15-
displayName: 'Maven Authenticate'
15+
displayName: "Maven Authenticate"
1616
inputs:
17-
artifactsFeeds: 'azure-sdk-for-java'
17+
artifactsFeeds: "azure-sdk-for-java"

eng/emitters/pipelines/templates/steps/test-step.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ steps:
5454
- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml
5555

5656
- ${{ if eq(parameters.LanguageShortName, 'python') }}:
57-
- template: /eng/common/pipelines/templates/steps/auth-dev-feed.yml
57+
- template: /eng/common/pipelines/templates/steps/auth-dev-feed.yml
5858

5959
- ${{ if eq(parameters.LanguageShortName, 'java') }}:
60-
- template: /eng/common/pipelines/templates/steps/maven-authenticate.yml
60+
- template: /eng/common/pipelines/templates/steps/maven-authenticate.yml
6161

6262
- download: current
6363
artifact: ${{ parameters.BuildArtifactName }}

eng/tsp-core/pipelines/templates/install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ steps:
3737
retryCountOnTaskFailure: 3
3838

3939
- ${{ if parameters.useDotNet }}:
40-
- script: dotnet restore
40+
- script: dotnet restore --configfile "$(Build.SourcesDirectory)/NuGet.Config"
4141
displayName: Restore .NET Dependencies
4242
workingDirectory: packages/typespec-vs

packages/http-client-csharp/eng/scripts/Build-Packages.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ function Pack-And-Write-Info {
4747
)
4848

4949
$versionOption = $BuildNumber ? "/p:Version=$version" : ""
50-
Invoke-LoggedCommand "dotnet pack ./$package/src/$package.csproj $versionOption -c Release -o $outputPath/packages"
50+
$ciNugetAuditArg = $env:TF_BUILD ? "-p:NuGetAudit=false" : ""
51+
Invoke-LoggedCommand "dotnet pack ./$package/src/$package.csproj $versionOption $ciNugetAuditArg -c Release -o $outputPath/packages"
5152
Write-PackageInfo -packageName $package -directoryPath "packages/http-client-csharp/generator/$package/src" -version $version
5253
}
5354

packages/http-client-csharp/eng/scripts/Test-Packages.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ try {
2424
# enforce cop static-analysis rules on the generator sources
2525
Invoke-LoggedCommand "./eng/scripts/Invoke-Cop.ps1" -GroupOutput
2626

27+
# Use the repo NuGet.Config explicitly so restore always targets the Azure DevOps feed.
28+
$repoRoot = (Resolve-Path "$packageRoot/../..").Path
29+
$nugetConfigPath = (Join-Path $repoRoot "NuGet.Config")
30+
$ciNugetAuditArg = $env:TF_BUILD ? "-p:NuGetAudit=false" : ""
31+
Invoke-LoggedCommand "dotnet nuget list source --configfile `"$nugetConfigPath`"" -GroupOutput
32+
2733
# test the generator
28-
Invoke-LoggedCommand "dotnet test ./generator" -GroupOutput
34+
Invoke-LoggedCommand "dotnet test ./generator -p:RestoreConfigFile=`"$nugetConfigPath`" $ciNugetAuditArg" -GroupOutput
2935

3036
Invoke-LoggedCommand "./eng/scripts/Get-Spector-Coverage.ps1" -GroupOutput
3137
}

packages/typespec-vs/scripts/build.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ async function main() {
3434
if (result.type === "dotnet") {
3535
await ensureDotnetVersion({ exitWithSuccessInDevBuilds: true });
3636
await runDotnet(
37-
["build", "--configuration", "Release", `-p:Version=${version}`, "-clp:NoSummary"],
37+
[
38+
"build",
39+
"--configuration",
40+
"Release",
41+
`-p:Version=${version}`,
42+
"-clp:NoSummary",
43+
// Restore may fail with NU1900 when vulnerability feed is unavailable.
44+
"-p:NuGetAudit=false",
45+
],
3846
{
3947
cwd: pkgRoot,
4048
},
@@ -58,7 +66,9 @@ async function buildWithMsbuild(msbuildPath, pkgRoot, version) {
5866
msbuildArgs.push("/restore");
5967
}
6068
msbuildArgs.push(join(pkgRoot, "Microsoft.TypeSpec.VS.sln"));
61-
const result = await run(msbuildPath, msbuildArgs, { throwOnNonZeroExit: false });
69+
const result = await run(msbuildPath, msbuildArgs, {
70+
throwOnNonZeroExit: false,
71+
});
6272
process.exit(result.exitCode);
6373
}
6474

packages/typespec-vs/src/Microsoft.TypeSpec.VS.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<!-- Set this to 'all' explicitly to get a consistent behavior. It's the default value now in latest VS/.Net/NugetMgr, but maybe not in some previous version -->
1111
<!-- https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/9.0/nugetaudit-transitive-packages -->
1212
<NuGetAuditMode>all</NuGetAuditMode>
13+
<!-- Non-Windows CI builds use dotnet restore/build and can fail with NU1900 when the vulnerability feed is unreachable. -->
14+
<NuGetAudit Condition="'$(OS)' != 'Windows_NT'">false</NuGetAudit>
1315
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1416
<!-- Official build will pass in the real version from package.json, see scripts/build.js -->
1517
<Version>42.42.42</Version>

0 commit comments

Comments
 (0)