Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
7 changes: 7 additions & 0 deletions .chronus/changes/disable-vs-build-nuget-audit-2026-8-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "typespec-vs"
---

Disable NuGet package auditing during cross-platform Visual Studio extension builds so restores do not fail when the vulnerability feed is unavailable.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-python"
---

Forward package index and Python mirror environment variables to tox test environments so tests can install dependencies from configured feeds.
1 change: 1 addition & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ words:
- pylint
- pylintrc
- pyodide
- pypi
- pyproject
- pyright
- pyrightconfig
Expand Down
1 change: 1 addition & 0 deletions eng/common/pipelines/templates/1es-redirect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extends:
parameters:
settings:
skipBuildTagsForGitHubPullRequests: true
networkIsolationPolicy: Permissive, CFSClean
sdl:
codeql:
compiled:
Expand Down
17 changes: 17 additions & 0 deletions eng/common/pipelines/templates/steps/maven-authenticate.yml
Comment thread
chidozieononiwu marked this conversation as resolved.
Resolved
Comment thread
iscai-msft marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
parameters:
SourceDirectory: $(Build.SourcesDirectory)

steps:
# Copy mirror settings to default Maven location so all requests go through CFS
- pwsh: |
$m2Dir = if ($env:USERPROFILE) { "$env:USERPROFILE\.m2" } else { "$HOME/.m2" }
New-Item -ItemType Directory -Force -Path $m2Dir | Out-Null
Copy-Item -Path "${{ parameters.SourceDirectory }}/eng/settings.xml" -Destination "$m2Dir/settings.xml"
displayName: "Setup Maven mirror settings"

# Authenticate with Azure Artifacts feeds
# MavenAuthenticate adds <server> entries to ~/.m2/settings.xml matching mirror id 'azure-sdk-for-java'
- task: MavenAuthenticate@0
displayName: "Maven Authenticate"
inputs:
artifactsFeeds: "azure-sdk-for-java"
49 changes: 49 additions & 0 deletions eng/common/pipelines/templates/steps/pypi-auth-dev-feed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
parameters:
DevFeedName: "public/azure-sdk-for-python"
EnableTwineAuth: true
EnablePipAuth: true
EnableUvAuth: true

steps:
- pwsh: |
# For safety default to publishing to the private feed.
# Publish to https://dev.azure.com/azure-sdk/internal/_packaging?_a=feed&feed=azure-sdk-for-python-pr
$devopsFeedName = 'internal/azure-sdk-for-python-pr'
if (-not ('$(Build.Repository.Name)').EndsWith('-pr')) {
# Publish to https://dev.azure.com/azure-sdk/public/_packaging?_a=feed&feed=azure-sdk-for-python
$devopsFeedName = '${{ parameters.DevFeedName }}'
}
echo "##vso[task.setvariable variable=DevFeedName]$devopsFeedName"
echo "Using DevopsFeed = $devopsFeedName"
displayName: Setup DevOpsFeedName

- ${{ if eq(parameters.EnableTwineAuth, true) }}:
- task: TwineAuthenticate@0
displayName: "Twine Authenticate to feed"
inputs:
artifactFeeds: $(DevFeedName)

- ${{ if eq(parameters.EnablePipAuth, true) }}:
- task: PipAuthenticate@1
displayName: "Pip Authenticate to feed"
inputs:
artifactFeeds: $(DevFeedName)
onlyAddExtraIndex: false

- ${{ if eq(parameters.EnableUvAuth, true) }}:
- pwsh: |
if ($env:PIP_INDEX_URL) {
Write-Host "Found pip index URL: $($env:PIP_INDEX_URL)"
# UV_DEFAULT_INDEX is the canonical replacement for the deprecated UV_INDEX_URL (uv 0.4.23+).
# PIP_INDEX_URL is set by PipAuthenticate@1 and contains embedded credentials, which uv
# will use for Basic auth against the ADO feed (and its PyPI upstream) per astral-sh/uv#12651.
Write-Host "##vso[task.setvariable variable=UV_DEFAULT_INDEX]$($env:PIP_INDEX_URL)"
# Disable keyring so uv uses the URL-embedded credentials directly.
Write-Host "##vso[task.setvariable variable=UV_KEYRING_PROVIDER]disabled"
} else {
Write-Host "##[warning]PIP_INDEX_URL not set - uv will fall back to public PyPI."
}
# Force any managed Python downloads to go directly to GitHub releases
# rather than the default CDN (releases.astral.sh).
Write-Host "##vso[task.setvariable variable=UV_PYTHON_INSTALL_MIRROR]https://github.com/astral-sh/python-build-standalone/releases/download"
displayName: "Configure UV Authentication"
18 changes: 14 additions & 4 deletions eng/emitters/pipelines/templates/steps/build-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,27 @@ steps:

- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml

- ${{ if eq(parameters.LanguageShortName, 'csharp') }}:
- task: NuGetAuthenticate@1

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

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

- task: NodeTool@0
displayName: Install Node.js
retryCountOnTaskFailure: 3
inputs:
versionSpec: ${{ parameters.NodeVersion }}
checkLatest: true

- task: UsePythonVersion@0
displayName: "Use Python ${{ parameters.PythonVersion }}"
inputs:
versionSpec: ${{ parameters.PythonVersion }}
- ${{ if eq(parameters.LanguageShortName, 'python') }}:
- task: UsePythonVersion@0
displayName: "Use Python ${{ parameters.PythonVersion }}"
inputs:
versionSpec: ${{ parameters.PythonVersion }}

- ${{ parameters.AdditionalInitializeSteps }}

Expand Down
18 changes: 14 additions & 4 deletions eng/emitters/pipelines/templates/steps/test-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ steps:

- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml

- ${{ if eq(parameters.LanguageShortName, 'csharp') }}:
- task: NuGetAuthenticate@1

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

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

- download: current
artifact: ${{ parameters.BuildArtifactName }}
displayName: Download build artifacts
Expand All @@ -64,10 +73,11 @@ steps:
versionSpec: ${{ parameters.NodeVersion }}
checkLatest: true

- task: UsePythonVersion@0
displayName: "Use Python ${{ parameters.PythonVersion }}"
inputs:
versionSpec: ${{ parameters.PythonVersion }}
- ${{ if eq(parameters.LanguageShortName, 'python') }}:
- task: UsePythonVersion@0
displayName: "Use Python ${{ parameters.PythonVersion }}"
inputs:
versionSpec: ${{ parameters.PythonVersion }}

- ${{ parameters.AdditionalInitializeSteps }}

Expand Down
11 changes: 11 additions & 0 deletions eng/nuget.config
Comment thread
chidozieononiwu marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<!-- Do not add any additional feeds if new packages are needed they need to come from our azure-sdk-for-net DevOps feed which has an upstream set to nuget.org -->
<add key="azure-sdk-for-net" value="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
</disabledPackageSources>
</configuration>
13 changes: 13 additions & 0 deletions eng/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>azure-sdk-for-java</id>
<name>Azure Artifacts Maven Mirror</name>
<url>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-java/maven/v1</url>
<mirrorOf>external:*</mirrorOf>
</mirror>
</mirrors>
</settings>
2 changes: 2 additions & 0 deletions eng/tsp-core/pipelines/pr-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ extends:
displayName: Create TryIt comment
dependsOn: tryit
steps:
- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml

- pwsh: |
$curlCommand = 'curl -s -u :$(System.AccessToken) "$(System.TeamFoundationCollectionUri)/$(System.TeamProject)/_apis/build/builds/$(Build.BuildId)/artifacts?artifactName=vscode-extension"'
$response = Invoke-Expression $curlCommand
Expand Down
2 changes: 1 addition & 1 deletion eng/tsp-core/pipelines/templates/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ steps:
retryCountOnTaskFailure: 3

- ${{ if parameters.useDotNet }}:
- script: dotnet restore
- script: dotnet restore --configfile "$(Build.SourcesDirectory)/eng/nuget.config"
displayName: Restore .NET Dependencies
workingDirectory: packages/typespec-vs
24 changes: 22 additions & 2 deletions packages/http-client-csharp/eng/scripts/Build-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ function Pack-And-Write-Info {
)

$versionOption = $BuildNumber ? "/p:Version=$version" : ""
Invoke-LoggedCommand "dotnet pack ./$package/src/$package.csproj $versionOption -c Release -o $outputPath/packages"
$ciNugetAuditArg = $env:TF_BUILD ? "-p:NuGetAudit=false" : ""
$repoRoot = (Resolve-Path "$packageRoot/../..").Path
$nugetConfigPath = (Join-Path $repoRoot "eng/nuget.config")
Invoke-LoggedCommand "dotnet pack ./$package/src/$package.csproj $versionOption -p:RestoreConfigFile=`"$nugetConfigPath`" $ciNugetAuditArg -c Release -o $outputPath/packages"
Write-PackageInfo -packageName $package -directoryPath "packages/http-client-csharp/generator/$package/src" -version $version
}

Expand Down Expand Up @@ -109,7 +112,24 @@ Push-Location "$packageRoot"
try {
Write-Host "Working in $PWD"

Invoke-LoggedCommand "npm run build" -GroupOutput
# Ensure nested dotnet builds (invoked via `npm run build:generator`) use the repo NuGet.Config
# so restore always targets the Azure DevOps feed instead of nuget.org.
$repoRoot = (Resolve-Path "$packageRoot/../..").Path
$nugetConfigPath = (Join-Path $repoRoot "eng/nuget.config")
$previousRestoreConfigFile = $env:RestoreConfigFile
$previousNuGetAudit = $env:NuGetAudit
try {
$env:RestoreConfigFile = $nugetConfigPath
if ($env:TF_BUILD) {
$env:NuGetAudit = "false"
}

Invoke-LoggedCommand "npm run build" -GroupOutput
}
finally {
$env:RestoreConfigFile = $previousRestoreConfigFile
$env:NuGetAudit = $previousNuGetAudit
}

Copy-Item "$packageRoot/emitter/temp/*.api.json" -Destination "$outputPath/packages"

Expand Down
18 changes: 17 additions & 1 deletion packages/http-client-csharp/eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,24 @@ $packageRoot = (Resolve-Path "$PSScriptRoot/../..").Path.Replace('\', '/')
Set-ConsoleEncoding

Push-Location $packageRoot
$repoRoot = (Resolve-Path "$packageRoot/../..").Path
$nugetConfigPath = (Join-Path $repoRoot "eng/nuget.config")
$ciNugetAuditArg = $env:TF_BUILD ? "-p:NuGetAudit=false" : ""
$previousRestoreConfigFile = $env:RestoreConfigFile
$previousNuGetAudit = $env:NuGetAudit
try {
# Ensure all dotnet processes, including those spawned by npm scripts and generation,
# restore through the repository's Azure DevOps feed instead of nuget.org.
$env:RestoreConfigFile = $nugetConfigPath
if ($env:TF_BUILD) {
$env:NuGetAudit = "false"
}

if ($UnitTests) {
Push-Location "$packageRoot"
try {
Invoke-LoggedCommand "dotnet nuget list source --configfile `"$nugetConfigPath`"" -GroupOutput

# test the emitter
Invoke-LoggedCommand "npm run build" -GroupOutput
Invoke-LoggedCommand "npm run test:emitter" -GroupOutput
Expand All @@ -25,7 +39,7 @@ try {
Invoke-LoggedCommand "./eng/scripts/Invoke-Cop.ps1" -GroupOutput

# test the generator
Invoke-LoggedCommand "dotnet test ./generator" -GroupOutput
Invoke-LoggedCommand "dotnet test ./generator -p:RestoreConfigFile=`"$nugetConfigPath`" $ciNugetAuditArg" -GroupOutput

Invoke-LoggedCommand "./eng/scripts/Get-Spector-Coverage.ps1" -GroupOutput
}
Expand Down Expand Up @@ -64,5 +78,7 @@ try {
}
}
finally {
$env:RestoreConfigFile = $previousRestoreConfigFile
$env:NuGetAudit = $previousNuGetAudit
Pop-Location
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Microsoft.TypeSpec.Generator.Tests
{
[NonParallelizable]
public class GeneratedCodeWorkspaceTests
{
private const string EvaluatedFrameworkTestCategory = "WithEvaluatedFrameworkValue";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void ReadProcessOutput_DrainsStandardOutputAndErrorConcurrently()
Console.Out.Write("stdout");
""");

using var buildProcess = Process.Start(new ProcessStartInfo("dotnet")
var buildStartInfo = new ProcessStartInfo("dotnet")
{
UseShellExecute = false,
ArgumentList =
Expand All @@ -264,7 +264,11 @@ public void ReadProcessOutput_DrainsStandardOutputAndErrorConcurrently()
"--verbosity",
"quiet"
}
});
};
AppendMsBuildPropertyIfSet(buildStartInfo.ArgumentList, "RestoreConfigFile", "RestoreConfigFile");
AppendMsBuildPropertyIfSet(buildStartInfo.ArgumentList, "NuGetAudit", "NuGetAudit");

using var buildProcess = Process.Start(buildStartInfo);
Assert.IsNotNull(buildProcess);
buildProcess!.WaitForExit();
Assert.AreEqual(0, buildProcess.ExitCode);
Expand Down Expand Up @@ -940,6 +944,18 @@ namespace Isolated { public class Dummy { } }");
</PropertyGroup>
</Project>";

private static void AppendMsBuildPropertyIfSet(
System.Collections.ObjectModel.Collection<string> argumentList,
string envVarName,
string propertyName)
{
var value = Environment.GetEnvironmentVariable(envVarName, EnvironmentVariableTarget.Process);
if (!string.IsNullOrWhiteSpace(value))
{
argumentList.Add($"-p:{propertyName}={value}");
}
}

/// <summary>Creates a unique temp directory and removes it on dispose.</summary>
private sealed class TempDirectory : IDisposable
{
Expand Down
Loading
Loading