-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to GitLink 3.0 #17736
Move to GitLink 3.0 #17736
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Collection of powershell build utility functions that we use across our scripts. | ||
|
||
Set-StrictMode -version 2.0 | ||
$ErrorActionPreference="Stop" | ||
|
||
# Declare a number of useful variables for other scripts to use | ||
[string]$repoDir = Resolve-Path (Join-Path $PSScriptRoot "..\..") | ||
[string]$binariesDir = Join-Path $repoDir "Binaries" | ||
[string]$scriptDir = $PSScriptRoot | ||
|
||
function Create-Directory([string]$dir) { | ||
New-Item $dir -ItemType Directory -ErrorAction SilentlyContinue | out-null | ||
} | ||
|
||
# Return the version of the NuGet package as used in this repo | ||
function Get-PackageVersion([string]$name) { | ||
$deps = Join-Path $repoDir "build\Targets\Dependencies.props" | ||
$nodeName = "$($name)Version" | ||
$x = [xml](Get-Content -raw $deps) | ||
$node = $x.Project.PropertyGroup[$nodeName] | ||
if ($node -eq $null) { | ||
throw "Cannot find package $name in Dependencies.props" | ||
} | ||
|
||
return $node.InnerText | ||
} | ||
|
||
# Locate the directory where our NuGet packages will be deployed. Needs to be kept in sync | ||
# with the logic in Version.props | ||
function Get-PackagesDir { | ||
$d = $null | ||
if ($env:NUGET_PACKAGES -ne $null) { | ||
$d = $env:NUGET_PACKAGES | ||
} | ||
else { | ||
$d = Join-Path $env:UserProfile ".nuget\packages\" | ||
} | ||
|
||
Create-Directory $d | ||
return $d | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Run GitLink on the binaries that we are producing. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you include a comment as to why the old mechanism wasn't sufficient? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (if the answer was "it's no longer supported", then that should have been written in the commit message) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I should have added more detail to this commit about that. I had put a write up of the problem in our previous convo and didn't think to add it here. The PR has a discussion of why this approach was taken now. |
||
|
||
param([string]$config = "Release") | ||
Set-StrictMode -version 2.0 | ||
$ErrorActionPreference="Stop" | ||
|
||
try { | ||
. (Join-Path $PSScriptRoot "..\..\..\build\scripts\build-utils.ps1") | ||
|
||
$configDir = Join-Path $binariesDir $config | ||
$gitlinkVersion = Get-PackageVersion "GitLink" | ||
$gitlink = Join-Path (Get-PackagesDir) "GitLink\$gitlinkVersion\build\GitLink.exe" | ||
|
||
Write-Host "Running GitLink" | ||
|
||
$config = Join-Path $repoDir "build\config\SignToolData.json" | ||
$j = ConvertFrom-Json (Get-Content -raw $config) | ||
foreach ($entry in $j.sign) { | ||
foreach ($v in $entry.values) { | ||
$ext = [IO.Path]::GetExtension($v) | ||
if (($ext -eq ".dll") -or ($ext -eq ".exe")) { | ||
$name = [IO.Path]::ChangeExtension($v, ".pdb") | ||
$pdbPath = Join-Path $configDir $name | ||
Write-Host "`t$pdbPath" | ||
|
||
$output = & $gitlink -u "https://github.com/dotnet/roslyn" $pdbPath | ||
if (-not $?) { | ||
Write-Host "Error!!!" | ||
Write-Host $output | ||
exit 1 | ||
} | ||
} | ||
} | ||
} | ||
|
||
exit 0 | ||
} | ||
catch [exception] { | ||
write-host $_.Exception | ||
exit 1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if it legitimately fails to create the directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then presumably the next command which uses the directory will fail 😄
I don't meant to be trolly there but there isn't a good answer to this question. Asking if the directory actually failed to create or already exists is just a variation of the File.Exists problem. I could test for existence of the directory after the call but it's a racy check.