Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ jobs:
run: |
src/shared/DotnetTool/pack.sh --configuration=Release \
--version="${{ needs.prereqs.outputs.version }}" \
--publish-dir=$(pwd)/signed
--package-root=$(pwd)/signed

- name: Upload unsigned package
uses: actions/upload-artifact@v5
Expand Down
5 changes: 2 additions & 3 deletions src/shared/DotnetTool/dotnet-tool.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
<description>Secure, cross-platform Git credential storage with authentication to Azure Repos, GitHub, and other popular Git hosting services.</description>
<authors>git-credential-manager</authors>
<icon>images\icon.png</icon>
<iconUrl>https://raw.githubusercontent.com/git-ecosystem/git-credential-manager/main/assets/gcm-transparent.png</iconUrl>
<packageTypes>
<packageType name="DotnetTool" />
</packageTypes>
</metadata>
<files>
<file src="$publishdir$payload/" target="tools/net8.0/any" />
<file src="$publishdir$images/icon.png" target="images" />
<file src="tools/net8.0/any/**" />
<file src="images/**" />
</files>
</package>
90 changes: 90 additions & 0 deletions src/shared/DotnetTool/layout.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<#
.SYNOPSIS
Lays out the .NET tool package directory.

.PARAMETER Configuration
Build configuration (Debug/Release). Defaults to Debug.

.PARAMETER Output
Root output directory for the nupkg layout. If omitted:
out/shared/DotnetTool/nupkg/<Configuration>

.EXAMPLE
pwsh ./layout.ps1 -Configuration Release

.EXAMPLE
pwsh ./layout.ps1 -Output C:\temp\tool-layout

#>

[CmdletBinding()]
param(
[string]$Configuration = "Debug",
[string]$Output
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

function Make-Absolute {
param([string]$Path)
if ([string]::IsNullOrWhiteSpace($Path)) { return $null }
if ([System.IO.Path]::IsPathRooted($Path)) { return $Path }
return (Join-Path -Path (Get-Location) -ChildPath $Path)
}

Write-Host "Starting layout..." -ForegroundColor Cyan

# Directories
$ScriptDir = $PSScriptRoot
$Root = (Resolve-Path (Join-Path $ScriptDir "..\..\..")).Path
$Src = Join-Path $Root "src"
$Out = Join-Path $Root "out"
$DotnetToolRel = "shared/DotnetTool"
$GcmSrc = Join-Path $Src "shared\Git-Credential-Manager"
$ProjOut = Join-Path $Out $DotnetToolRel

$Framework = "net8.0"

if (-not $Output -or $Output.Trim() -eq "") {
$Output = Join-Path $ProjOut "nupkg\$Configuration"
}

$ImgOut = Join-Path $Output "images"
$BinOut = Join-Path $Output "tools\$Framework\any"

# Cleanup previous layout
if (Test-Path $Output) {
Write-Host "Cleaning existing output directory '$Output'..."
Remove-Item -Force -Recurse $Output
}

# Recreate directories
$null = New-Item -ItemType Directory -Path $BinOut -Force
$null = New-Item -ItemType Directory -Path $ImgOut -Force

# Determine DOTNET_ROOT if not set
if (-not $env:DOTNET_ROOT -or $env:DOTNET_ROOT.Trim() -eq "") {
$dotnetCmd = Get-Command dotnet -ErrorAction Stop
$env:DOTNET_ROOT = Split-Path -Parent $dotnetCmd.Source
}

Write-Host "Publishing core application..."
& "$env:DOTNET_ROOT/dotnet" publish $GcmSrc `
--configuration $Configuration `
--framework $Framework `
--output (Make-Absolute $BinOut) `
-p:UseAppHost=false

if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet publish failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}

Write-Host "Copying package configuration file..."
Copy-Item -Path (Join-Path $Src "$DotnetToolRel\DotnetToolSettings.xml") -Destination $BinOut -Force

Write-Host "Copying images..."
Copy-Item -Path (Join-Path $Src "$DotnetToolRel\icon.png") -Destination $ImgOut -Force

Write-Host "Layout complete." -ForegroundColor Green
83 changes: 0 additions & 83 deletions src/shared/DotnetTool/layout.sh

This file was deleted.

95 changes: 95 additions & 0 deletions src/shared/DotnetTool/pack.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<#
.SYNOPSIS
Creates the NuGet package for the .NET tool.

.PARAMETER Configuration
Build configuration (Debug/Release). Defaults to Debug.

.PARAMETER Version
Package version (required).

.PARAMETER PackageRoot
Root of the pre-laid-out package structure (from layout). Defaults to:
out/shared/DotnetTool/nupkg/<Configuration>

.PARAMETER Output
Optional directory for the produced .nupkg/.snupkg. If omitted NuGet chooses.

.EXAMPLE
pwsh ./pack.ps1 -Version 2.0.123-beta

.EXAMPLE
pwsh ./pack.ps1 -Configuration Release -Version 2.1.0 -Output C:\pkgs

#>

[CmdletBinding()]
param(
[string]$Configuration = "Debug",
[Parameter(Mandatory = $true)]
[string]$Version,
[string]$PackageRoot,
[string]$Output
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

Write-Host "Starting pack..." -ForegroundColor Cyan

# Directories
$ScriptDir = $PSScriptRoot
$Root = (Resolve-Path (Join-Path $ScriptDir "..\..\..")).Path
$Src = Join-Path $Root "src"
$Out = Join-Path $Root "out"
$DotnetToolRel = "shared\DotnetTool"
$NuspecFile = Join-Path $Src "$DotnetToolRel\dotnet-tool.nuspec"

if (-not (Test-Path $NuspecFile)) {
Write-Error "Could not locate nuspec file at '$NuspecFile'"
exit 1
}

if (-not $PackageRoot -or $PackageRoot.Trim() -eq "") {
$PackageRoot = Join-Path $Out "$DotnetToolRel\nupkg\$Configuration"
}

if (-not (Test-Path $PackageRoot)) {
Write-Error "Package root '$PackageRoot' does not exist. Run layout.ps1 first."
exit 1
}

# Locate nuget
$nugetCmd = Get-Command nuget -ErrorAction SilentlyContinue
if (-not $nugetCmd) {
Write-Error "nuget CLI not found in PATH (install: https://www.nuget.org/downloads)"
exit 1
}
$nugetExe = $nugetCmd.Source

Write-Host "Creating .NET tool package..."

$packArgs = @(
"pack", "$NuspecFile",
"-Properties", "Configuration=$Configuration",
"-Version", $Version,
"-Symbols", "-SymbolPackageFormat", "snupkg",
"-BasePath", "$PackageRoot"
)

if ($Output -and $Output.Trim() -ne "") {
if (-not (Test-Path $Output)) {
Write-Host "Creating output directory '$Output'..."
New-Item -ItemType Directory -Force -Path $Output | Out-Null
}
$packArgs += @("-OutputDirectory", "$Output")
}

& $nugetExe @packArgs

if ($LASTEXITCODE -ne 0) {
Write-Error "nuget pack failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}

Write-Host ".NET tool pack complete." -ForegroundColor Green
52 changes: 0 additions & 52 deletions src/shared/DotnetTool/pack.sh

This file was deleted.