Skip to content

Commit d330f71

Browse files
cobyaCoby Allred
and
Coby Allred
authored
Update install scripts to support single RID parameters (#553)
To reduce the overhead of adopting new installation script versions, allow users to only configure the runtime version without additional parameters being required to default to .NET 8. Additionally, add a warning to users for .NET Framework 3.1 installation and when lower priority parameters are selected. ![image](https://github.com/user-attachments/assets/c45cf6a0-c0c0-437a-b341-097c86e1839c) ![image](https://github.com/user-attachments/assets/ed596bdd-7fce-4fd6-9654-7cb885a8859b) --------- Co-authored-by: Coby Allred <[email protected]>
1 parent 6f431df commit d330f71

File tree

3 files changed

+154
-38
lines changed

3 files changed

+154
-38
lines changed

build/validate-install-script.yml

+64-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ jobs:
2626
repo: self
2727
scriptInputs: '-InstallNet8 -RuntimeIdentifier win-x64'
2828
expectedCredentialProviderVersion: 'Microsoft.Net8.win-x64.NuGet.CredentialProvider'
29+
- job: WindowsInstallNet8winx64NoParams
30+
pool:
31+
vmImage: windows-latest
32+
steps:
33+
- template: validate-install-script-powershell.yml@self
34+
parameters:
35+
repo: self
36+
scriptInputs: '-RuntimeIdentifier win-x64'
37+
expectedCredentialProviderVersion: 'Microsoft.Net8.win-x64.NuGet.CredentialProvider'
38+
- job: WindowsInstallNet8winx64Net6Params
39+
pool:
40+
vmImage: windows-latest
41+
steps:
42+
- template: validate-install-script-powershell.yml@self
43+
parameters:
44+
repo: self
45+
scriptInputs: '-InstallNet6 -RuntimeIdentifier win-x64'
46+
expectedCredentialProviderVersion: 'Microsoft.Net8.win-x64.NuGet.CredentialProvider'
2947
- job: WindowsInstallNetfxDefault
3048
pool:
3149
vmImage: windows-latest
@@ -64,6 +82,28 @@ jobs:
6482
export USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=false
6583
export USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER=true
6684
expectedCredentialProviderVersion: 'Microsoft.Net8.NuGet.CredentialProvider'
85+
- job: LinuxInstallNet8Net6Param
86+
pool:
87+
vmImage: ubuntu-latest
88+
steps:
89+
- template: validate-install-script-bash.yml@self
90+
parameters:
91+
repo: self
92+
scriptEnvVariables: |
93+
export USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=true
94+
export USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER=true
95+
expectedCredentialProviderVersion: 'Microsoft.Net8.NuGet.CredentialProvider'
96+
- job: LinuxInstallNetFx
97+
pool:
98+
vmImage: ubuntu-latest
99+
steps:
100+
- template: validate-install-script-bash.yml@self
101+
parameters:
102+
repo: self
103+
scriptEnvVariables: |
104+
export USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=false
105+
export USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER=false
106+
expectedCredentialProviderVersion: 'Microsoft.NuGet.CredentialProvider'
67107
- job: LinuxInstallNet8linuxx64
68108
pool:
69109
vmImage: ubuntu-latest
@@ -75,7 +115,7 @@ jobs:
75115
export USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=false
76116
export USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER=true
77117
export ARTIFACTS_CREDENTIAL_PROVIDER_RID=linux-x64
78-
expectedCredentialProviderVersion: 'Microsoft.Net8.linux-x64.NuGet.CredentialProvider'
118+
expectedCredentialProviderVersion: 'Microsoft.Net8.linux-x64.NuGet.CredentialProvider'
79119
- job: LinuxInstallNet8linuxarm64
80120
pool:
81121
vmImage: ubuntu-latest
@@ -87,7 +127,7 @@ jobs:
87127
export USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=false
88128
export USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER=true
89129
export ARTIFACTS_CREDENTIAL_PROVIDER_RID=linux-arm64
90-
expectedCredentialProviderVersion: 'Microsoft.Net8.linux-arm64.NuGet.CredentialProvider'
130+
expectedCredentialProviderVersion: 'Microsoft.Net8.linux-arm64.NuGet.CredentialProvider'
91131
- job: LinuxInstallNet8osxarm64
92132
pool:
93133
vmImage: ubuntu-latest
@@ -99,7 +139,7 @@ jobs:
99139
export USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=false
100140
export USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER=true
101141
export ARTIFACTS_CREDENTIAL_PROVIDER_RID=osx-arm64
102-
expectedCredentialProviderVersion: 'Microsoft.Net8.osx-arm64.NuGet.CredentialProvider'
142+
expectedCredentialProviderVersion: 'Microsoft.Net8.osx-arm64.NuGet.CredentialProvider'
103143
- job: LinuxInstallNet8osxx64
104144
pool:
105145
vmImage: ubuntu-latest
@@ -112,4 +152,25 @@ jobs:
112152
export USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER=true
113153
export ARTIFACTS_CREDENTIAL_PROVIDER_RID=osx-x64
114154
expectedCredentialProviderVersion: 'Microsoft.Net8.osx-x64.NuGet.CredentialProvider'
155+
- job: LinuxInstallNet8osxx64NoParams
156+
pool:
157+
vmImage: ubuntu-latest
158+
steps:
159+
- template: validate-install-script-bash.yml@self
160+
parameters:
161+
repo: self
162+
scriptEnvVariables: |
163+
export ARTIFACTS_CREDENTIAL_PROVIDER_RID=osx-x64
164+
expectedCredentialProviderVersion: 'Microsoft.Net8.osx-x64.NuGet.CredentialProvider'
165+
- job: LinuxInstallNet8osxx64Net6Params
166+
pool:
167+
vmImage: ubuntu-latest
168+
steps:
169+
- template: validate-install-script-bash.yml@self
170+
parameters:
171+
repo: self
172+
scriptEnvVariables: |
173+
export USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=true
174+
export ARTIFACTS_CREDENTIAL_PROVIDER_RID=osx-x64
175+
expectedCredentialProviderVersion: 'Microsoft.Net8.osx-x64.NuGet.CredentialProvider'
115176

helpers/installcredprovider.ps1

+59-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,49 @@
1-
# A PowerShell script that adds the latest version of the Azure Artifacts credential provider
2-
# plugin for Dotnet and/or NuGet to ~/.nuget/plugins directory
3-
# To install netcore, run installcredprovider.ps1
4-
# To install netcore and netfx, run installcredprovider.ps1 -AddNetfx
5-
# To overwrite existing plugin with the latest version, run installcredprovider.ps1 -Force
6-
# To use a specific version of a credential provider, run installcredprovider.ps1 -Version "1.0.1" or installcredprovider.ps1 -Version "1.0.1" -Force
1+
<#
2+
.SYNOPSIS
3+
Installs the Azure Artifacts Credential Provider for DotNet or NuGet tool usage.
74
5+
.DESCRIPTION
6+
This script installs the latest version of the Azure Artifacts Credential Provider plugin
7+
for DotNet and/or NuGet to the ~/.nuget/plugins directory.
8+
9+
.PARAMETER AddNetfx
10+
Installs the .NET Framework 4.6.1 Credential Provider.
11+
12+
.PARAMETER AddNetfx48
13+
Installs the .NET Framework 4.8.1 Credential Provider.
14+
15+
.PARAMETER Force
16+
Forces overwriting of existing Credential Provider installations.
17+
18+
.PARAMETER Version
19+
Specifies the GitHub release version of the Credential Provider to install.
20+
21+
.PARAMETER InstallNet6
22+
Installs the .NET 6 Credential Provider (default).
23+
24+
.PARAMETER InstallNet8
25+
Installs the .NET 8 Credential Provider.
26+
27+
.PARAMETER RuntimeIdentifier
28+
Installs the self-contained Credential Provider for the specified Runtime Identifier.
29+
30+
.EXAMPLE
31+
.\installcredprovider.ps1 -InstallNet8
32+
.\installcredprovider.ps1 -Version "1.0.1" -Force
33+
#>
34+
35+
[CmdletBinding(HelpUri = "https://github.com/microsoft/artifacts-credprovider/blob/master/README.md#setup")]
836
param(
9-
# whether or not to install netfx folder for nuget
1037
[switch]$AddNetfx,
11-
# whether or not to install netfx 4.8.1 folder for nuget
1238
[switch]$AddNetfx48,
13-
# override existing cred provider with the latest version
1439
[switch]$Force,
15-
# install the version specified
1640
[string]$Version,
17-
# install the .NET 6 cred provider instead of NetCore3.1
1841
[switch]$InstallNet6 = $true,
19-
# install the .NET 8 cred provider instead of NetCore3.1
2042
[switch]$InstallNet8,
21-
# install the self-contained cred provider for the specified RuntimeIdentifier .
22-
[string]$RuntimeIdentifier
43+
[string]$RuntimeIdentifier
2344
)
2445

25-
$script:ErrorActionPreference='Stop'
46+
$script:ErrorActionPreference = 'Stop'
2647

2748
# Without this, System.Net.WebClient.DownloadFile will fail on a client with TLS 1.0/1.1 disabled
2849
if ([Net.ServicePointManager]::SecurityProtocol.ToString().Split(',').Trim() -notcontains 'Tls12') {
@@ -42,6 +63,16 @@ if ($AddNetfx -eq $True -and $AddNetfx48 -eq $True) {
4263
Write-Error "Please select a single .Net framework version to install"
4364
return
4465
}
66+
if (![string]::IsNullOrEmpty($RuntimeIdentifier)) {
67+
if (($Version.StartsWith("0.") -or $Version.StartsWith("1.0") -or $Version.StartsWith("1.1") -or $Version.StartsWith("1.2") -or $Version.StartsWith("1.3"))) {
68+
Write-Error "You cannot install the .Net 8 self-contained version or with versions lower than 1.4.0"
69+
return
70+
}
71+
72+
Write-Host "RuntimeIdentifier parameter is specified, the .Net 8 self-contained version will be installed"
73+
$InstallNet6 = $False
74+
$InstallNet8 = $True
75+
}
4576
if ($InstallNet6 -eq $True -and $InstallNet8 -eq $True) {
4677
# InstallNet6 defaults to true, in the case of .Net 8 install, overwrite
4778
$InstallNet6 = $False
@@ -50,7 +81,8 @@ if ($InstallNet6 -eq $True -and $InstallNet8 -eq $True) {
5081
$userProfilePath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile);
5182
if ($userProfilePath -ne '') {
5283
$profilePath = $userProfilePath
53-
} else {
84+
}
85+
else {
5486
$profilePath = $env:UserProfile
5587
}
5688

@@ -91,7 +123,8 @@ if (![string]::IsNullOrEmpty($Version)) {
91123
$releaseJson = $releases | ConvertFrom-Json
92124
$correctReleaseVersion = $releaseJson | ? { $_.name -eq $Version }
93125
$releaseId = $correctReleaseVersion.id
94-
} catch {
126+
}
127+
catch {
95128
Write-Error $versionError
96129
return
97130
}
@@ -103,14 +136,13 @@ if (!$releaseId) {
103136
}
104137

105138
$releaseUrl = [System.IO.Path]::Combine($releaseUrlBase, $releaseId)
106-
$releaseUrl = $releaseUrl.Replace("\","/")
139+
$releaseUrl = $releaseUrl.Replace("\", "/")
107140

108141
$releaseRidPart = ""
109142
if (![string]::IsNullOrEmpty($RuntimeIdentifier)) {
110-
$releaseRIdPart = $RuntimeIdentifier + "."
143+
$releaseRIdPart = $RuntimeIdentifier + "."
111144
}
112145

113-
$zipFile = "Microsoft.NetCore3.NuGet.CredentialProvider.zip"
114146
if ($Version.StartsWith("0.")) {
115147
# versions lower than 1.0.0 installed NetCore2 zip
116148
$zipFile = "Microsoft.NetCore2.NuGet.CredentialProvider.zip"
@@ -122,11 +154,16 @@ if ($InstallNet8 -eq $True) {
122154
$zipFile = "Microsoft.Net8.${releaseRidPart}NuGet.CredentialProvider.zip"
123155
}
124156
if ($AddNetfx -eq $True) {
157+
Write-Warning "The .Net Framework 4.6.1 version of the Credential Provider is deprecated and will be removed in the next major release. Please migrate to the .Net Framework 4.8 or .Net Core versions."
125158
$zipFile = "Microsoft.NuGet.CredentialProvider.zip"
126159
}
127160
if ($AddNetfx48 -eq $True) {
128161
$zipFile = "Microsoft.NetFx48.NuGet.CredentialProvider.zip"
129162
}
163+
if (-not $zipFile) {
164+
Write-Warning "The .Net Core 3.1 version of the Credential Provider is deprecated and will be removed in the next major release. Please migrate to the .Net 8 version."
165+
$zipFile = "Microsoft.NetCore3.NuGet.CredentialProvider.zip"
166+
}
130167

131168
function InstallZip {
132169
Write-Verbose "Using $zipFile"
@@ -168,7 +205,8 @@ function InstallZip {
168205
try {
169206
$client = New-Object System.Net.WebClient
170207
$client.DownloadFile($packageSourceUrl, $pluginZip)
171-
} catch {
208+
}
209+
catch {
172210
Write-Error "Unable to download $packageSourceUrl to the location $pluginZip"
173211
}
174212

helpers/installcredprovider.sh

+31-14
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,32 @@
1111
REPO="Microsoft/artifacts-credprovider"
1212
NUGET_PLUGIN_DIR="$HOME/.nuget/plugins"
1313

14-
# .NET 6 is the default installation, attempt to install unless set to false.
15-
if [ -z ${USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER} ] || [ ${USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER} != "false" ]; then
16-
FILE="Microsoft.Net6.NuGet.CredentialProvider.tar.gz"
14+
# If a RuntimeID (RID) is set, install the self-contained version of the .NET 8 credential provider.
15+
# To install a release with a specific runtime version set the `ARTIFACTS_CREDENTIAL_PROVIDER_RID` enviornment variable.
16+
if [ ! -z ${ARTIFACTS_CREDENTIAL_PROVIDER_RID} ]; then
17+
echo "INFO: ARTIFACTS_CREDENTIAL_PROVIDER_RID variable set, defaulting to NET8 installation."
1718

18-
# throw if version starts with 0. (net6 not supported)
19+
FILE="Microsoft.Net8.${ARTIFACTS_CREDENTIAL_PROVIDER_RID}.NuGet.CredentialProvider.tar.gz"
20+
21+
if [ -z ${USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER} ]; then
22+
echo "WARNING: The USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER variable is set, but ARTIFACTS_CREDENTIAL_PROVIDER_RID variable is defined. The NET8 version of the credential provider will be installed."
23+
fi
24+
25+
# throw if version starts < 1.4.0. (self-contained not supported)
1926
case ${AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION} in
20-
0.*|v0.*)
21-
echo "ERROR: To install NET6 cred provider using the USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER variable, version to be installed must be 1.0.0 or greater. Check your AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION variable."
27+
0.*|v0.*|1.0.*|v1.0.*|1.1.*|v1.1.*|1.2.*|v1.2.*|1.3.*|v1.3.*)
28+
echo "ERROR: To install NET8 cred provider using the ARTIFACTS_CREDENTIAL_PROVIDER_RID variable, version to be installed must be 1.4.0 or greater. Check your AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION variable."
2229
exit 1
2330
;;
2431
esac
25-
# Don't attempt to install .NET 8 without a set variable.
32+
# If .NET 8 variable is set, install the .NET 8 version of the credential provider even if USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER is true.
2633
elif [ ! -z ${USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER} ] && [ ${USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER} != "false" ]; then
27-
# Self-contained versions are available in latest versions of the .NET 8 credprovider.
28-
# To install a release with a specific runtime version set the `ARTIFACTS_CREDENTIAL_PROVIDER_RID` enviornment variable.
29-
# Otherwise default to the full zip file.
30-
RID=""
31-
if [ ! -z ${ARTIFACTS_CREDENTIAL_PROVIDER_RID} ]; then
32-
RID=".${ARTIFACTS_CREDENTIAL_PROVIDER_RID}"
34+
# Default to the full zip file since ARTIFACTS_CREDENTIAL_PROVIDER_RID is not specified.
35+
FILE="Microsoft.Net8.NuGet.CredentialProvider.tar.gz"
36+
37+
if [ -z ${USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER} ]; then
38+
echo "WARNING: The USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER variable is set, but USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER variable is true. The NET8 version of the credential provider will be installed."
3339
fi
34-
FILE="Microsoft.Net8$RID.NuGet.CredentialProvider.tar.gz"
3540

3641
# throw if version starts < 1.3.0. (net8 not supported)
3742
case ${AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION} in
@@ -40,8 +45,20 @@ elif [ ! -z ${USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER} ] && [ ${USE_NET8_ARTIFACT
4045
exit 1
4146
;;
4247
esac
48+
# .NET 6 is the default installation, attempt to install unless set to false.
49+
elif [ -z ${USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER} ] || [ ${USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER} != "false" ]; then
50+
FILE="Microsoft.Net6.NuGet.CredentialProvider.tar.gz"
51+
52+
# throw if version starts with 0. (net6 not supported)
53+
case ${AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION} in
54+
0.*|v0.*)
55+
echo "ERROR: To install NET6 cred provider using the USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER variable, version to be installed must be 1.0.0 or greater. Check your AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION variable."
56+
exit 1
57+
;;
58+
esac
4359
# If .NET 6 is disabled and .NET 8 isn't explicitly enabled, fall back to the legacy .NET Framework.
4460
else
61+
echo "WARNING: The .Net Framework 3.1 version of the Credential Provider is deprecated and will be removed in the next major release. Please migrate to the .Net Framework 4.8 or .Net Core versions."
4562
FILE="Microsoft.NuGet.CredentialProvider.tar.gz"
4663
fi
4764

0 commit comments

Comments
 (0)