Skip to content
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

Add icon to dotnet tool NuGet package #905

Merged
merged 4 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,11 @@ jobs:

- name: Package tool
run: |
src/shared/DotnetTool/pack-tool.sh
src/shared/DotnetTool/pack-tool.sh \
--version=$GitBuildVersionSimple \
--configuration=Release

- name: Publish tool
run: |
dotnet nuget push ./out/nupkg/*.nupkg \
dotnet nuget push ./out/shared/DotnetTool/nupkg/Release/*.nupkg \
--api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
3 changes: 2 additions & 1 deletion src/shared/DotnetTool/DotnetTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
publishDir=$(PublishDir);
</NuspecProperties>
<NoBuild>true</NoBuild>
<OutputPath>../../../out/nupkg</OutputPath>
<OutputPath>$(ProjectOutPath)nupkg\$(Configuration)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just prevents MSBuild from creating the empty/not used net6.0 directory under $(OutputPath)/.

</PropertyGroup>
</Project>
5 changes: 4 additions & 1 deletion src/shared/DotnetTool/dotnet-tool.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
<version>$version$</version>
<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/GitCredentialManager/git-credential-manager/main/assets/gcm-transparent.png</iconUrl>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iconUrl is deprecated, but icon is only supported by newer versions of NuGet and VS.. so include both, with iconUrl as a fallback.

Newer tools will only use icon.

<packageTypes>
<packageType name="DotnetTool" />
</packageTypes>
</metadata>
<files>
<file src="$publishdir$" target="tools/net6.0/any" />
<file src="$publishdir$payload/" target="tools/net6.0/any" />
<file src="$publishdir$images/icon.png" target="images" />
Comment on lines +15 to +16
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$publishdir$ includes the trailing slash.. so this looks weird but is correct 😁

</files>
</package>
Binary file added src/shared/DotnetTool/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 45 additions & 44 deletions src/shared/DotnetTool/pack-tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ make_absolute () {
#####################################################################
# Lay out
#####################################################################
echo "Laying out files for dotnet tool..."
# Parse script arguments
for i in "$@"
do
Expand All @@ -38,7 +37,7 @@ esac
done

if [ -z "$VERSION" ]; then
VERSION="$GitBuildVersionSimple"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$GitBuildVersionSimple isn't set in dev builds, so let's just require it and have the CI pass this in. If $VERSION ends up being empty the dev builds ended up half-baked.

die "--version was not set"
fi

# Directories
Expand All @@ -47,42 +46,32 @@ ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )"
SRC="$ROOT/src"
OUT="$ROOT/out"
GCM_SRC="$SRC/shared/Git-Credential-Manager"
GCM_UI_SRC="$SRC/shared/Git-Credential-Manager.UI.Avalonia"
BITBUCKET_UI_SRC="$SRC/shared/Atlassian.Bitbucket.UI.Avalonia"
GITHUB_UI_SRC="$SRC/shared/GitHub.UI.Avalonia"
GITLAB_UI_SRC="$SRC/shared/GitLab.UI.Avalonia"
DOTNET_TOOL="shared/DotnetTool"
PROJ_OUT="$OUT/$DOTNET_TOOL"

PACKAGE="$ROOT/nuget"
CONFIGURATION="${CONFIGURATION:=Release}"
CONFIGURATION="${CONFIGURATION:=Debug}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched the default back to Debug from Release.

Thinking about it again, we should make these scripts easy to call locally in dev (where we'd want debug bits) since CI doesn't care how long command line args get 😁


# Build parameters
FRAMEWORK=net6.0

# Outputs
PAYLOAD="$PROJ_OUT/payload/$CONFIGURATION"
SYMBOLOUT="$PROJ_OUT/payload.sym/$CONFIGURATION"

# Cleanup payload directory
if [ -d "$PAYLOAD" ]; then
echo "Cleaning existing payload directory '$PAYLOAD'..."
rm -rf "$PAYLOAD"
fi

# Cleanup symbol directory
if [ -d "$SYMBOLOUT" ]; then
echo "Cleaning existing symbols directory '$SYMBOLOUT'..."
rm -rf "$SYMBOLOUT"
fi

# Cleanup package directory
if [ -d "$PACKAGE" ]; then
echo "Cleaning existing package directory '$PACKAGE'..."
rm -rf "$PACKAGE"
OUTDIR="$PROJ_OUT/nupkg/$CONFIGURATION"
IMGOUT="$OUTDIR/images"
PAYLOAD="$OUTDIR/payload"
SYMBOLOUT="$OUTDIR/payload.sym"
Comment on lines +62 to +65
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything sits under $OUTDIR now which is /out/shared/DotnetTool/nupkg/$CONFIGURATION.


# Cleanup output directory
if [ -d "$OUTDIR" ]; then
echo "Cleaning existing output directory '$OUTDIR'..."
rm -rf "$OUTDIR"
fi

# Ensure directories exist
mkdir -p "$PAYLOAD" "$SYMBOLOUT" "$PACKAGE"
# Ensure output directories exist
mkdir -p "$PAYLOAD" "$SYMBOLOUT" "$IMGOUT"

if [ -z "$DOTNET_ROOT" ]; then
DOTNET_ROOT="$(dirname $(which dotnet))"
Expand All @@ -91,49 +80,61 @@ fi
# Publish core application executables
echo "Publishing core application..."
$DOTNET_ROOT/dotnet publish "$GCM_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
-p:UseAppHost=false || exit 1

echo "Publishing core UI helper..."
$DOTNET_ROOT/dotnet publish "$GCM_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
-p:UseAppHost=false || exit 1

echo "Publishing Bitbucket UI helper..."
$DOTNET_ROOT/dotnet publish "$BITBUCKET_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
-p:UseAppHost=false || exit 1

echo "Publishing GitHub UI helper..."
$DOTNET_ROOT/dotnet publish "$GITHUB_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
-p:UseAppHost=false || exit 1

echo "Publishing GitLab UI helper..."
$DOTNET_ROOT/dotnet publish "$GITLAB_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--output="$(make_absolute "$PAYLOAD")" \
-p:UseAppHost=false || exit 1

# Collect symbols
echo "Collecting managed symbols..."
mv "$PAYLOAD"/*.pdb "$SYMBOLOUT" || exit 1

# Copy DotnetToolSettings.xml file
echo "Copying out package configuration files..."
cp "$SRC/$DOTNET_TOOL/DotnetToolSettings.xml" "$PAYLOAD/"

# Copy package icon image
echo "Copying images..."
cp "$SRC/$DOTNET_TOOL/icon.png" "$IMGOUT" || exit 1

echo "Build complete."

#####################################################################
# Pack dotnet tool
#####################################################################
echo "Creating dotnet tool package..."

mkdir -p "$PACKAGE" || exit 1
echo "Laying out files..."
cp -r "$SRC/$DOTNET_TOOL/DotnetToolSettings.xml" \
"$PAYLOAD/." \
"$PACKAGE/"
Comment on lines -133 to -135
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to copy the output to another directory just to pack it. Instead we're now dotnet publish-ing outputs to a payload directory, and copying associated .xml/.png files to the right dir structure in the first place.


dotnet pack "$SRC/$DOTNET_TOOL/DotnetTool.csproj" /p:PackageVersion="$VERSION" /p:PublishDir="$PACKAGE/"
dotnet pack "$SRC/$DOTNET_TOOL/DotnetTool.csproj" \
/p:Configuration="$CONFIGURATION" \
/p:PackageVersion="$VERSION" \
/p:PublishDir="$OUTDIR/"

echo "Dotnet tool pack complete."
2 changes: 0 additions & 2 deletions src/windows/Installer.Windows/layout.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ dotnet publish "$GCM_SRC" `

Write-Output "Publishing core UI helper..."
dotnet publish "$GCM_UI_SRC" `
--framework net472 `
--configuration "$CONFIGURATION" `
--runtime win-x86 `
--output "$PAYLOAD"

Write-Output "Publishing Bitbucket UI helper..."
Expand Down