Skip to content

Commit 5a63fd8

Browse files
committed
Use versions repo tooling from BuildTools.
Sets up dependencies.props config. Removes UpdateDependencies powershell script, to be replaced by a call into VersionTools in Maestro automation. Changes UpdatePublishedVersions to pass through to VersionTools for backward compatibility.
1 parent 158db01 commit 5a63fd8

File tree

6 files changed

+112
-338
lines changed

6 files changed

+112
-338
lines changed

Diff for: UpdateDependencies.ps1

-157
This file was deleted.

Diff for: UpdatePublishedVersions.ps1

+10-128
Original file line numberDiff line numberDiff line change
@@ -14,131 +14,13 @@ param(
1414
[Parameter(Mandatory=$true)][string]$versionsRepo,
1515
[Parameter(Mandatory=$true)][string]$versionsRepoPath,
1616
# A pattern matching all packages in the set that the versions repository should be set to.
17-
[Parameter(Mandatory=$true)][string]$nupkgPath,
18-
# Print out the new file contents, but don't change the versions repository.
19-
[switch]$dryRun)
20-
21-
function ConvertPathTo-Package([string]$path)
22-
{
23-
# Find the package ID and version using a regex. This matches the semantic version
24-
# and assumes everything to the left is the id or a path to the package directory.
25-
$matched = $path -match '^(.*\\)?(.*?)\.(([0-9]+\.)?[0-9]+\.[0-9]+(-([A-z0-9-]+))?)\.(symbols\.)?nupkg$'
26-
if ($matched)
27-
{
28-
$packageInfo = @{
29-
Path = $path
30-
Name = $matches[2]
31-
Version = $matches[3]
32-
Prerelease = $matches[6]
33-
}
34-
$packageInfo.NameVersion = "$($packageInfo.Name) $($packageInfo.Version)"
35-
return $packageInfo
36-
}
37-
else
38-
{
39-
throw "Couldn't find name and version from path $path."
40-
}
41-
}
42-
43-
# Updates a GitHub file with the specified file contents
44-
function Update-GitHub-File(
45-
[string]$user = $gitHubUser,
46-
[string]$email = $gitHubEmail,
47-
[string]$authToken = $gitHubAuthToken,
48-
[string]$owner = $versionsRepoOwner,
49-
[string]$repo = $versionsRepo,
50-
[string]$path,
51-
[string]$newFileContent,
52-
[string]$commitMessage)
53-
{
54-
function message([string]$message)
55-
{
56-
Write-Host -ForegroundColor Green "*** $message ***"
57-
}
58-
59-
$headers = @{
60-
'Accept' = 'application/vnd.github.v3+json'
61-
'Authorization' = "token $authToken"
62-
}
63-
64-
$fileUrl = "https://api.github.com/repos/$owner/$repo/contents/$path"
65-
66-
message "Getting the `"sha`" of the current contents of file '$owner/$repo/$path'"
67-
68-
$currentFile = Invoke-WebRequest $fileUrl -UseBasicParsing -Headers $headers
69-
$currentSha = (ConvertFrom-Json $currentFile.Content).sha
70-
71-
message "Got `"sha`" value of '$currentSha'"
72-
73-
message "Request to update file '$owner/$repo/$path' contents to:"
74-
Write-Host $newFileContent
75-
76-
if ($dryRun)
77-
{
78-
message 'Not sending request: dry run.'
79-
return
80-
}
81-
82-
# Base64 encode the string
83-
function ToBase64([string]$value)
84-
{
85-
return [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($value))
86-
}
87-
88-
$updateFileBody =
89-
@"
90-
{
91-
"message": "$commitMessage",
92-
"committer": {
93-
"name": "$user",
94-
"email": "$email"
95-
},
96-
"content": "$(ToBase64 $newFileContent)",
97-
"sha": "$currentSha"
98-
}
99-
"@
100-
101-
message 'Sending request...'
102-
$putResponse = Invoke-WebRequest $fileUrl -UseBasicParsing -Method PUT -Body $updateFileBody -Headers $headers
103-
104-
if ($putResponse.StatusCode -ge 200 -and $putResponse.StatusCode -lt 300)
105-
{
106-
message 'Successfully updated the file'
107-
}
108-
}
109-
110-
# Store result of Get-ChildItem before piping to ConvertPathTo-Package. When directly piping, exceptions are ignored.
111-
$packagePaths = Get-ChildItem $nupkgPath
112-
$packages = $packagePaths | %{ ConvertPathTo-Package $_ }
113-
114-
$prereleaseVersion = ''
115-
foreach ($package in $packages)
116-
{
117-
if ($package.Prerelease)
118-
{
119-
$prereleaseVersion = $package.Prerelease
120-
break
121-
}
122-
}
123-
124-
if (!$prereleaseVersion)
125-
{
126-
throw "Could not find a Prerelease version in '$newPackages'"
127-
}
128-
129-
$versionFilePath = "$versionsRepoPath/Latest.txt"
130-
$versionFileContent = "$prereleaseVersion`n"
131-
132-
Update-GitHub-File `
133-
-path $versionFilePath `
134-
-newFileContent $versionFileContent `
135-
-commitMessage "Update '$versionFilePath' with $prereleaseVersion"
136-
137-
$packageInfoFilePath = "$versionsRepoPath/Latest_Packages.txt"
138-
$packageInfoFileContent = ($packages | %{ $_.NameVersion } | Sort-Object) -join "`r`n"
139-
140-
Update-GitHub-File `
141-
-path $packageInfoFilePath `
142-
-newFileContent $packageInfoFileContent `
143-
-commitMessage "Adding package info to '$packageInfoFilePath' for $prereleaseVersion"
144-
17+
[Parameter(Mandatory=$true)][string]$nupkgPath)
18+
19+
& "$PSScriptRoot\run.cmd" build -- tests\build.proj /t:UpdatePublishedVersions `
20+
/p:GitHubUser="$gitHubUser" `
21+
/p:GitHubEmail="$gitHubEmail" `
22+
/p:GitHubAuthToken="$gitHubAuthToken" `
23+
/p:VersionsRepoOwner="$versionsRepoOwner" `
24+
/p:VersionsRepo="$versionsRepo" `
25+
/p:VersionsRepoPath="$versionsRepoPath" `
26+
/p:ShippedNuGetPackageGlobPath="$nupkgPath"

Diff for: dependencies.props

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<!-- Source of truth for dependency tooling: the commit hash of the dotnet/versions master branch as of the last auto-upgrade. -->
3+
<PropertyGroup>
4+
<CoreFxCurrentRef>afe7fab6bb2a2cd82d381eab880d290b23ed5214</CoreFxCurrentRef>
5+
<CoreClrCurrentRef>5adc811e2d62ae1543bc3e88748476d088532d2a</CoreClrCurrentRef>
6+
<ExternalCurrentRef>039e8532657c2599e2f8baf2c3dcd95265f28645</ExternalCurrentRef>
7+
</PropertyGroup>
8+
9+
<!-- Auto-upgraded properties for each build info dependency. -->
10+
<PropertyGroup>
11+
<CoreFxExpectedPrerelease>beta-24328-05</CoreFxExpectedPrerelease>
12+
<ExternalExpectedPrerelease>beta-24417-00</ExternalExpectedPrerelease>
13+
</PropertyGroup>
14+
15+
<!-- Full package version strings that are used in other parts of the build. -->
16+
<PropertyGroup>
17+
<CoreClrPackageVersion>1.0.4-beta-24325-02</CoreClrPackageVersion>
18+
<XunitPackageVersion>2.1.0</XunitPackageVersion>
19+
</PropertyGroup>
20+
21+
<!-- Package dependency verification/auto-upgrade configuration. -->
22+
<PropertyGroup>
23+
<BaseDotNetBuildInfo>build-info/dotnet/</BaseDotNetBuildInfo>
24+
<DependencyBranch>master</DependencyBranch>
25+
<CurrentRefXmlPath>$(MSBuildThisFileFullPath)</CurrentRefXmlPath>
26+
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<RemoteDependencyBuildInfo Include="CoreFx">
30+
<BuildInfoPath>$(BaseDotNetBuildInfo)corefx/$(DependencyBranch)</BuildInfoPath>
31+
<CurrentRef>$(CoreFxCurrentRef)</CurrentRef>
32+
</RemoteDependencyBuildInfo>
33+
<RemoteDependencyBuildInfo Include="CoreClr">
34+
<BuildInfoPath>$(BaseDotNetBuildInfo)coreclr/$(DependencyBranch)</BuildInfoPath>
35+
<CurrentRef>$(CoreClrCurrentRef)</CurrentRef>
36+
</RemoteDependencyBuildInfo>
37+
<RemoteDependencyBuildInfo Include="External">
38+
<BuildInfoPath>$(BaseDotNetBuildInfo)projectk-tfs/$(DependencyBranch)</BuildInfoPath>
39+
<CurrentRef>$(ExternalCurrentRef)</CurrentRef>
40+
</RemoteDependencyBuildInfo>
41+
42+
<DependencyBuildInfo Include="@(RemoteDependencyBuildInfo)">
43+
<RawVersionsBaseUrl>https://raw.githubusercontent.com/dotnet/versions</RawVersionsBaseUrl>
44+
</DependencyBuildInfo>
45+
46+
<XmlUpdateStep Include="CoreFx">
47+
<Path>$(MSBuildThisFileFullPath)</Path>
48+
<ElementName>CoreFxExpectedPrerelease</ElementName>
49+
<BuildInfoName>CoreFx</BuildInfoName>
50+
</XmlUpdateStep>
51+
<XmlUpdateStep Include="CoreClr">
52+
<Path>$(MSBuildThisFileFullPath)</Path>
53+
<ElementName>CoreClrPackageVersion</ElementName>
54+
<PackageId>Microsoft.NETCore.Runtime.CoreCLR</PackageId>
55+
</XmlUpdateStep>
56+
<XmlUpdateStep Include="External">
57+
<Path>$(MSBuildThisFileFullPath)</Path>
58+
<ElementName>ExternalExpectedPrerelease</ElementName>
59+
<BuildInfoName>External</BuildInfoName>
60+
</XmlUpdateStep>
61+
</ItemGroup>
62+
63+
<!-- Set up dependencies on packages that aren't found in a BuildInfo. -->
64+
<ItemGroup>
65+
<XUnitDependency Include="xunit"/>
66+
<XUnitDependency Include="xunit.assert"/>
67+
<XUnitDependency Include="xunit.core"/>
68+
<XUnitDependency Include="xunit.runner.console"/>
69+
<XUnitDependency Include="xunit.runner.msbuild"/>
70+
<XUnitDependency Include="xunit.runner.utility"/>
71+
<StaticDependency Include="@(XUnitDependency)">
72+
<Version>$(XunitPackageVersion)</Version>
73+
</StaticDependency>
74+
75+
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.analysis" />
76+
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.analysis.cli" />
77+
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.metrics" />
78+
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.run.core" />
79+
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.runner.cli" />
80+
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.runner.Windows" />
81+
<StaticDependency Include="@(XunitPerformanceDependency)">
82+
<Version>1.0.0-alpha-build0035</Version>
83+
</StaticDependency>
84+
85+
<StaticDependency Include="xunit.console.netcore">
86+
<Version>1.0.2-prerelease-00101</Version>
87+
</StaticDependency>
88+
89+
<DependencyBuildInfo Include="@(StaticDependency)">
90+
<PackageId>%(Identity)</PackageId>
91+
<UpdateStableVersions>true</UpdateStableVersions>
92+
</DependencyBuildInfo>
93+
</ItemGroup>
94+
</Project>

0 commit comments

Comments
 (0)