Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 2fbc064

Browse files
dotnet-maestro[bot]nosami
authored andcommitted
[master] Update dependencies from dotnet/arcade (dotnet#7706)
* Update dependencies from https://github.com/dotnet/arcade build 20191004.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19504.2 * Update dependencies from https://github.com/dotnet/arcade build 20191005.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19505.1 * Update dependencies from https://github.com/dotnet/arcade build 20191006.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19506.1 * Update dependencies from https://github.com/dotnet/arcade build 20191009.5 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19509.5 * Update dependencies from https://github.com/dotnet/arcade build 20191010.4 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19510.4 * Update dependencies from https://github.com/dotnet/arcade build 20191011.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19511.1 * Update dependencies from https://github.com/dotnet/arcade build 20191015.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19515.1 * Update dependencies from https://github.com/dotnet/arcade build 20191015.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19515.2 * Update dependencies from https://github.com/dotnet/arcade build 20191017.8 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19517.8 * Update dependencies from https://github.com/dotnet/arcade build 20191018.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19518.2 * Update dependencies from https://github.com/dotnet/arcade build 20191021.4 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19521.4 * Update dependencies from https://github.com/dotnet/arcade build 20191022.8 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19522.8 * Update dependencies from https://github.com/dotnet/arcade build 20191023.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19523.3 * Update dependencies from https://github.com/dotnet/arcade build 20191024.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19524.2 * Update dependencies from https://github.com/dotnet/arcade build 20191025.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19525.2 * Update dependencies from https://github.com/dotnet/arcade build 20191026.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19526.1 * Update dependencies from https://github.com/dotnet/arcade build 20191027.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19527.3 * Update dependencies from https://github.com/dotnet/arcade build 20191028.5 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19528.5 * Update dependencies from https://github.com/dotnet/arcade build 20191029.9 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19529.9 * Update dependencies from https://github.com/dotnet/arcade build 20191030.15 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19530.15 * Update dependencies from https://github.com/dotnet/arcade build 20191031.14 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19531.14 * Update dependencies from https://github.com/dotnet/arcade build 20191101.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19551.3 * Update dependencies from https://github.com/dotnet/arcade build 20191102.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19552.1 * Update dependencies from https://github.com/dotnet/arcade build 20191104.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19554.3 * work around dotnet/wpf#1718 by not embedding untracked sources * use arcade mechanism of populating package icons
1 parent 0f76d9e commit 2fbc064

37 files changed

+927
-113
lines changed

FSharpBuild.Directory.Build.props

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<Project>
2+
3+
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
4+
<Import Project="eng\targets\Settings.props" />
5+
6+
<PropertyGroup>
7+
<BUILD_IN_FSHARP_REPOSITORY>true</BUILD_IN_FSHARP_REPOSITORY>
8+
</PropertyGroup>
9+
10+
<!-- directory locations -->
11+
<PropertyGroup>
12+
<FSharpSourcesRoot>$(RepoRoot)src</FSharpSourcesRoot>
13+
<SymStoreDirectory>$(ArtifactsDir)\SymStore</SymStoreDirectory>
14+
<ProtoOutputPath>$(ArtifactsDir)\Bootstrap</ProtoOutputPath>
15+
<ValueTupleImplicitPackageVersion>4.4.0</ValueTupleImplicitPackageVersion>
16+
<WarningsAsErrors>1182;0025;$(WarningsAsErrors)</WarningsAsErrors>
17+
</PropertyGroup>
18+
19+
<!-- nuget -->
20+
<PropertyGroup>
21+
<PackageIconFullPath>$(MSBuildThisFileDirectory)icon.png</PackageIconFullPath>
22+
23+
<!-- Point to artifacts folder as an additional nuget package source -->
24+
<RestoreAdditionalProjectSources Condition = "Exists('$(ArtifactsPackagesDir)') and '$(RestoreAdditionalProjectSources)' != ''">$(RestoreAdditionalProjectSources);$(ArtifactsPackagesDir)</RestoreAdditionalProjectSources>
25+
<RestoreAdditionalProjectSources Condition = "Exists('$(ArtifactsPackagesDir)') and '$(RestoreAdditionalProjectSources)' == ''">$(ArtifactsPackagesDir)</RestoreAdditionalProjectSources>
26+
27+
<!-- default NuGet package restore location -->
28+
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == ''">$(NUGET_PACKAGES)</NuGetPackageRoot>
29+
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' == 'Windows_NT'">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
30+
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' != 'Windows_NT'">$(HOME)/.nuget/packages/</NuGetPackageRoot>
31+
32+
<!-- ensure there is a trailing slash -->
33+
<NuGetPackageRoot Condition="!HasTrailingSlash('$(NuGetPackageRoot)') AND '$(OS)' == 'Windows_NT'">$(NuGetPackageRoot)\</NuGetPackageRoot>
34+
<NuGetPackageRoot Condition="!HasTrailingSlash('$(NuGetPackageRoot)') AND '$(OS)' != 'Windows_NT'">$(NuGetPackageRoot)/</NuGetPackageRoot>
35+
36+
<!-- ensure all NuGet packages come from the `$(NuGetPackageRoot)` variable -->
37+
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
38+
</PropertyGroup>
39+
40+
<!-- mono -->
41+
<PropertyGroup Condition="'$(OS)' == 'Unix'">
42+
<MonoRoot Condition="'$(MonoRoot)' == '' and $([MSBuild]::IsOsPlatform('Linux'))">/usr</MonoRoot>
43+
<MonoRoot Condition="'$(MonoRoot)' == '' and $([MSBuild]::IsOsPlatform('OSX'))">/Library/Frameworks/Mono.framework/Versions/Current</MonoRoot>
44+
<MonoLibFolder>$(MonoRoot)/lib/mono</MonoLibFolder>
45+
<MonoPackaging Condition="$(TargetFramework.StartsWith('net4'))">true</MonoPackaging>
46+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net45'">$(MonoLibFolder)/4.5-api</FrameworkPathOverride>
47+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net451'">$(MonoLibFolder)/4.5.1-api</FrameworkPathOverride>
48+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net452'">$(MonoLibFolder)/4.5.2-api</FrameworkPathOverride>
49+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net46'">$(MonoLibFolder)/4.6-api</FrameworkPathOverride>
50+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net461'">$(MonoLibFolder)/4.6.1-api</FrameworkPathOverride>
51+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net462'">$(MonoLibFolder)/4.6.2-api</FrameworkPathOverride>
52+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net47'">$(MonoLibFolder)/4.7-api</FrameworkPathOverride>
53+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net471'">$(MonoLibFolder)/4.7.1-api</FrameworkPathOverride>
54+
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net472'">$(MonoLibFolder)/4.7.2-api</FrameworkPathOverride>
55+
</PropertyGroup>
56+
57+
<!-- signing -->
58+
<PropertyGroup>
59+
<StrongNameKeyId>Microsoft</StrongNameKeyId>
60+
</PropertyGroup>
61+
<PropertyGroup Condition="'$(MonoPackaging)' == 'true'">
62+
<AssemblyOriginatorKeyFile>$(FSharpSourcesRoot)\fsharp\test.snk</AssemblyOriginatorKeyFile>
63+
<DelaySign>false</DelaySign>
64+
<DefineConstants>STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY;$(DefineConstants)</DefineConstants>
65+
</PropertyGroup>
66+
67+
<!-- localization -->
68+
<PropertyGroup>
69+
<EnableXlfLocalization Condition="'$(EnableXlfLocalization)' == '' AND ('$(Configuration)' == 'Proto' OR '$(MonoPackaging)' == 'true')">false</EnableXlfLocalization>
70+
<UpdateXlfOnBuild Condition="'$(CI)' != '1'">true</UpdateXlfOnBuild>
71+
</PropertyGroup>
72+
73+
<!-- source-build workarounds -->
74+
<PropertyGroup Condition="'$(FSharpSourceBuild)' == 'true'">
75+
<DeterministicSourcePaths>false</DeterministicSourcePaths>
76+
<PublishWindowsPdb>false</PublishWindowsPdb>
77+
<RepositoryUrl Condition="'$(RepositoryUrl)' == ''">https://github.com/Microsoft/visualfsharp</RepositoryUrl>
78+
<RepositoryType Condition="'$(RepositoryType)' == ''">git</RepositoryType>
79+
</PropertyGroup>
80+
81+
<PropertyGroup Condition="'$(FSharpSourceBuild)' == 'true' AND '$(RepositoryCommit)' == ''">
82+
<_DotGitDir>$(RepoRoot).git</_DotGitDir>
83+
<_HeadFileContent Condition="Exists('$(_DotGitDir)/HEAD')">$([System.IO.File]::ReadAllText('$(_DotGitDir)/HEAD').Trim())</_HeadFileContent>
84+
<_RefPath Condition="$(_HeadFileContent.StartsWith('ref: '))">$(_DotGitDir)/$(_HeadFileContent.Substring(5))</_RefPath>
85+
<RepositoryCommit>$(BUILD_SOURCEVERSION)</RepositoryCommit>
86+
<RepositoryCommit Condition="'$(RepositoryCommit)' == '' AND '$(_RefPath)' != '' and Exists('$(_RefPath)')">$([System.IO.File]::ReadAllText('$(_RefPath)').Trim())</RepositoryCommit>
87+
</PropertyGroup>
88+
89+
<!-- other -->
90+
<PropertyGroup>
91+
<NoWarn Condition="'$(Language)' == 'F#'">$(NoWarn);FS2003</NoWarn><!-- warning when AssemblyInformationalVersion looks like '1.2.3-dev' -->
92+
<NoCompilerStandardLib>true</NoCompilerStandardLib><!-- necessary for resource generation using csc.exe -->
93+
<DebugType>embedded</DebugType>
94+
<MicroBuildAssemblyFileLanguage>fs</MicroBuildAssemblyFileLanguage>
95+
<UseStandardResourceNames>false</UseStandardResourceNames>
96+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
97+
</PropertyGroup>
98+
99+
<PropertyGroup Condition="'$(OS)' == 'Unix'">
100+
<DefineConstants>$(DefineConstants);TESTING_ON_LINUX</DefineConstants>
101+
</PropertyGroup>
102+
103+
<!-- SDK targets override -->
104+
<PropertyGroup Condition="'$(Configuration)' != 'Proto' AND '$(DisableCompilerRedirection)'!='true' AND Exists('$(ProtoOutputPath)')">
105+
<FSharpTargetsPath>$(ProtoOutputPath)\fsc\Microsoft.FSharp.Targets</FSharpTargetsPath>
106+
<FSharpPropsShim>$(ProtoOutputPath)\fsc\Microsoft.FSharp.NetSdk.props</FSharpPropsShim>
107+
<FSharpTargetsShim>$(ProtoOutputPath)\fsc\Microsoft.FSharp.NetSdk.targets</FSharpTargetsShim>
108+
<FSharpOverridesTargetsShim>$(ProtoOutputPath)\fsc\Microsoft.FSharp.Overrides.NetSdk.targets</FSharpOverridesTargetsShim>
109+
</PropertyGroup>
110+
111+
</Project>

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<ProductDependencies>
44
</ProductDependencies>
55
<ToolsetDependencies>
6-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.19502.11">
6+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.19554.3">
77
<Uri>https://github.com/dotnet/arcade</Uri>
8-
<Sha>da75c6547c64a91eb8a9cecf8c503331c2cc394a</Sha>
8+
<Sha>ec6a0344dd2b1237cd63b38281295ce1e4b71458</Sha>
99
</Dependency>
1010
</ToolsetDependencies>
1111
</Dependencies>

eng/common/PublishToSymbolServers.proj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
<PropertyGroup>
3838
<DotNetSymbolExpirationInDays Condition="'$(DotNetSymbolExpirationInDays)' == ''">3650</DotNetSymbolExpirationInDays>
3939
<PublishToSymbolServer>true</PublishToSymbolServer>
40+
<PublishToSymWeb Condition="'$(PublishToSymWeb)' == ''">true</PublishToSymWeb>
41+
<PublishToMSDL Condition="'$(PublishToMSDL)' == ''">true</PublishToMSDL>
4042
<PublishToSymbolServer Condition="'@(FilesToPublishToSymbolServer)' == '' and '@(PackagesToPublishToSymbolServer)' == ''">false</PublishToSymbolServer>
4143
</PropertyGroup>
4244

@@ -56,7 +58,7 @@
5658
DryRun="false"
5759
ConvertPortablePdbsToWindowsPdbs="false"
5860
PdbConversionTreatAsWarning=""
59-
Condition="$(PublishToSymbolServer)"/>
61+
Condition="$(PublishToSymbolServer) and $(PublishToMSDL)"/>
6062

6163
<!--
6264
Symbol Uploader: SymWeb
@@ -73,7 +75,7 @@
7375
DryRun="false"
7476
ConvertPortablePdbsToWindowsPdbs="false"
7577
PdbConversionTreatAsWarning=""
76-
Condition="$(PublishToSymbolServer)"/>
78+
Condition="$(PublishToSymbolServer) and $(PublishToSymWeb)"/>
7779
</Target>
7880

7981
<ItemGroup>

eng/common/SetupNugetSources.ps1

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# This file is a temporary workaround for internal builds to be able to restore from private AzDO feeds.
2+
# This file should be removed as part of this issue: https://github.com/dotnet/arcade/issues/4080
3+
#
4+
# What the script does is iterate over all package sources in the pointed NuGet.config and add a credential entry
5+
# under <packageSourceCredentials> for each Maestro managed private feed. Two additional credential
6+
# entries are also added for the two private static internal feeds: dotnet3-internal and dotnet3-internal-transport.
7+
#
8+
# This script needs to be called in every job that will restore packages and which the base repo has
9+
# private AzDO feeds in the NuGet.config.
10+
#
11+
# See example YAML call for this script below. Note the use of the variable `$(dn-bot-dnceng-artifact-feeds-rw)`
12+
# from the AzureDevOps-Artifact-Feeds-Pats variable group.
13+
#
14+
# - task: PowerShell@2
15+
# displayName: Setup Private Feeds Credentials
16+
# condition: eq(variables['Agent.OS'], 'Windows_NT')
17+
# inputs:
18+
# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1
19+
# arguments: -ConfigFile ${Env:BUILD_SOURCESDIRECTORY}/NuGet.config -Password $Env:Token
20+
# env:
21+
# Token: $(dn-bot-dnceng-artifact-feeds-rw)
22+
23+
[CmdletBinding()]
24+
param (
25+
[Parameter(Mandatory = $true)][string]$ConfigFile,
26+
[Parameter(Mandatory = $true)][string]$Password
27+
)
28+
29+
$ErrorActionPreference = "Stop"
30+
Set-StrictMode -Version 2.0
31+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
32+
33+
. $PSScriptRoot\tools.ps1
34+
35+
# Add source entry to PackageSources
36+
function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $Password) {
37+
$packageSource = $sources.SelectSingleNode("add[@key='$SourceName']")
38+
39+
if ($packageSource -eq $null)
40+
{
41+
$packageSource = $doc.CreateElement("add")
42+
$packageSource.SetAttribute("key", $SourceName)
43+
$packageSource.SetAttribute("value", $SourceEndPoint)
44+
$sources.AppendChild($packageSource) | Out-Null
45+
}
46+
else {
47+
Write-Host "Package source $SourceName already present."
48+
}
49+
50+
AddCredential -Creds $creds -Source $SourceName -Username $Username -Password $Password
51+
}
52+
53+
# Add a credential node for the specified source
54+
function AddCredential($creds, $source, $username, $password) {
55+
# Looks for credential configuration for the given SourceName. Create it if none is found.
56+
$sourceElement = $creds.SelectSingleNode($Source)
57+
if ($sourceElement -eq $null)
58+
{
59+
$sourceElement = $doc.CreateElement($Source)
60+
$creds.AppendChild($sourceElement) | Out-Null
61+
}
62+
63+
# Add the <Username> node to the credential if none is found.
64+
$usernameElement = $sourceElement.SelectSingleNode("add[@key='Username']")
65+
if ($usernameElement -eq $null)
66+
{
67+
$usernameElement = $doc.CreateElement("add")
68+
$usernameElement.SetAttribute("key", "Username")
69+
$sourceElement.AppendChild($usernameElement) | Out-Null
70+
}
71+
$usernameElement.SetAttribute("value", $Username)
72+
73+
# Add the <ClearTextPassword> to the credential if none is found.
74+
# Add it as a clear text because there is no support for encrypted ones in non-windows .Net SDKs.
75+
# -> https://github.com/NuGet/Home/issues/5526
76+
$passwordElement = $sourceElement.SelectSingleNode("add[@key='ClearTextPassword']")
77+
if ($passwordElement -eq $null)
78+
{
79+
$passwordElement = $doc.CreateElement("add")
80+
$passwordElement.SetAttribute("key", "ClearTextPassword")
81+
$sourceElement.AppendChild($passwordElement) | Out-Null
82+
}
83+
$passwordElement.SetAttribute("value", $Password)
84+
}
85+
86+
function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Password) {
87+
$maestroPrivateSources = $Sources.SelectNodes("add[contains(@key,'darc-int')]")
88+
89+
Write-Host "Inserting credentials for $($maestroPrivateSources.Count) Maestro's private feeds."
90+
91+
ForEach ($PackageSource in $maestroPrivateSources) {
92+
Write-Host "`tInserting credential for Maestro's feed:" $PackageSource.Key
93+
AddCredential -Creds $creds -Source $PackageSource.Key -Username $Username -Password $Password
94+
}
95+
}
96+
97+
if (!(Test-Path $ConfigFile -PathType Leaf)) {
98+
Write-Host "Couldn't find the file NuGet config file: $ConfigFile"
99+
ExitWithExitCode 1
100+
}
101+
102+
# Load NuGet.config
103+
$doc = New-Object System.Xml.XmlDocument
104+
$filename = (Get-Item $ConfigFile).FullName
105+
$doc.Load($filename)
106+
107+
# Get reference to <PackageSources> or create one if none exist already
108+
$sources = $doc.DocumentElement.SelectSingleNode("packageSources")
109+
if ($sources -eq $null) {
110+
$sources = $doc.CreateElement("packageSources")
111+
$doc.DocumentElement.AppendChild($sources) | Out-Null
112+
}
113+
114+
# Looks for a <PackageSourceCredentials> node. Create it if none is found.
115+
$creds = $doc.DocumentElement.SelectSingleNode("packageSourceCredentials")
116+
if ($creds -eq $null) {
117+
$creds = $doc.CreateElement("packageSourceCredentials")
118+
$doc.DocumentElement.AppendChild($creds) | Out-Null
119+
}
120+
121+
# Insert credential nodes for Maestro's private feeds
122+
InsertMaestroPrivateFeedCredentials -Sources $sources -Creds $creds -Password $Password
123+
124+
AddPackageSource -Sources $sources -SourceName "dotnet3-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal/nuget/v2" -Creds $creds -Username "dn-bot" -Password $Password
125+
AddPackageSource -Sources $sources -SourceName "dotnet3-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal-transport/nuget/v2" -Creds $creds -Username "dn-bot" -Password $Password
126+
127+
$doc.Save($filename)

eng/common/SetupNugetSources.sh

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env bash
2+
3+
# This file is a temporary workaround for internal builds to be able to restore from private AzDO feeds.
4+
# This file should be removed as part of this issue: https://github.com/dotnet/arcade/issues/4080
5+
#
6+
# What the script does is iterate over all package sources in the pointed NuGet.config and add a credential entry
7+
# under <packageSourceCredentials> for each Maestro's managed private feed. Two additional credential
8+
# entries are also added for the two private static internal feeds: dotnet3-internal and dotnet3-internal-transport.
9+
#
10+
# This script needs to be called in every job that will restore packages and which the base repo has
11+
# private AzDO feeds in the NuGet.config.
12+
#
13+
# See example YAML call for this script below. Note the use of the variable `$(dn-bot-dnceng-artifact-feeds-rw)`
14+
# from the AzureDevOps-Artifact-Feeds-Pats variable group.
15+
#
16+
# - task: Bash@3
17+
# displayName: Setup Private Feeds Credentials
18+
# inputs:
19+
# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
20+
# arguments: $BUILD_SOURCESDIRECTORY/NuGet.config $Token
21+
# condition: ne(variables['Agent.OS'], 'Windows_NT')
22+
# env:
23+
# Token: $(dn-bot-dnceng-artifact-feeds-rw)
24+
25+
ConfigFile=$1
26+
CredToken=$2
27+
NL='\n'
28+
TB=' '
29+
30+
source="${BASH_SOURCE[0]}"
31+
32+
# resolve $source until the file is no longer a symlink
33+
while [[ -h "$source" ]]; do
34+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
35+
source="$(readlink "$source")"
36+
# if $source was a relative symlink, we need to resolve it relative to the path where the
37+
# symlink file was located
38+
[[ $source != /* ]] && source="$scriptroot/$source"
39+
done
40+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
41+
42+
. "$scriptroot/tools.sh"
43+
44+
if [ ! -f "$ConfigFile" ]; then
45+
echo "Couldn't find the file NuGet config file: $ConfigFile"
46+
ExitWithExitCode 1
47+
fi
48+
49+
if [[ `uname -s` == "Darwin" ]]; then
50+
NL=$'\\\n'
51+
TB=''
52+
fi
53+
54+
# Ensure there is a <packageSources>...</packageSources> section.
55+
grep -i "<packageSources>" $ConfigFile
56+
if [ "$?" != "0" ]; then
57+
echo "Adding <packageSources>...</packageSources> section."
58+
ConfigNodeHeader="<configuration>"
59+
PackageSourcesTemplate="${TB}<packageSources>${NL}${TB}</packageSources>"
60+
61+
sed -i.bak "s|$ConfigNodeHeader|$ConfigNodeHeader${NL}$PackageSourcesTemplate|" NuGet.config
62+
fi
63+
64+
# Ensure there is a <packageSourceCredentials>...</packageSourceCredentials> section.
65+
grep -i "<packageSourceCredentials>" $ConfigFile
66+
if [ "$?" != "0" ]; then
67+
echo "Adding <packageSourceCredentials>...</packageSourceCredentials> section."
68+
69+
PackageSourcesNodeFooter="</packageSources>"
70+
PackageSourceCredentialsTemplate="${TB}<packageSourceCredentials>${NL}${TB}</packageSourceCredentials>"
71+
72+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourcesNodeFooter${NL}$PackageSourceCredentialsTemplate|" NuGet.config
73+
fi
74+
75+
# Ensure dotnet3-internal and dotnet3-internal-transport is in the packageSources
76+
grep -i "<add key=\"dotnet3-internal\">" $ConfigFile
77+
if [ "$?" != "0" ]; then
78+
echo "Adding dotnet3-internal to the packageSources."
79+
80+
PackageSourcesNodeFooter="</packageSources>"
81+
PackageSourceTemplate="${TB}<add key=\"dotnet3-internal\" value=\"https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal/nuget/v2\" />"
82+
83+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" NuGet.config
84+
fi
85+
86+
# Ensure dotnet3-internal and dotnet3-internal-transport is in the packageSources
87+
grep -i "<add key=\"dotnet3-internal-transport\">" $ConfigFile
88+
if [ "$?" != "0" ]; then
89+
echo "Adding dotnet3-internal-transport to the packageSources."
90+
91+
PackageSourcesNodeFooter="</packageSources>"
92+
PackageSourceTemplate="${TB}<add key=\"dotnet3-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal-transport/nuget/v2\" />"
93+
94+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" NuGet.config
95+
fi
96+
97+
# I want things split line by line
98+
PrevIFS=$IFS
99+
IFS=$'\n'
100+
PackageSources=$(grep -oh '"darc-int-[^"]*"' $ConfigFile | tr -d '"')
101+
IFS=$PrevIFS
102+
103+
PackageSources+=('dotnet3-internal')
104+
PackageSources+=('dotnet3-internal-transport')
105+
106+
for FeedName in ${PackageSources[@]} ; do
107+
# Check if there is no existing credential for this FeedName
108+
grep -i "<$FeedName>" $ConfigFile
109+
if [ "$?" != "0" ]; then
110+
echo "Adding credentials for $FeedName."
111+
112+
PackageSourceCredentialsNodeFooter="</packageSourceCredentials>"
113+
NewCredential="${TB}${TB}<$FeedName>${NL}<add key=\"Username\" value=\"dn-bot\" />${NL}<add key=\"ClearTextPassword\" value=\"$CredToken\" />${NL}</$FeedName>"
114+
115+
sed -i.bak "s|$PackageSourceCredentialsNodeFooter|$NewCredential${NL}$PackageSourceCredentialsNodeFooter|" NuGet.config
116+
fi
117+
done

0 commit comments

Comments
 (0)