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

Enable assembly trimming and single-file publish on all platforms #1419

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 8.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 6.0.201
dotnet-version: 8.0.x

- name: Install dependencies
run: dotnet restore
Expand All @@ -37,9 +37,9 @@ jobs:
shell: bash
run: |
mkdir -p artifacts/bin
mv out/windows/Installer.Windows/bin/Release/net472/win-x86 artifacts/bin/
cp out/windows/Installer.Windows/bin/Release/net472/win-x86.sym/* artifacts/bin/win-x86/
mv out/windows/Installer.Windows/bin/Release/net472/gcm*.exe artifacts/
mv out/windows/Installer.Windows/bin/Release/net8.0/win-x86 artifacts/bin/
cp out/windows/Installer.Windows/bin/Release/net8.0/win-x86.sym/* artifacts/bin/win-x86/
mv out/windows/Installer.Windows/bin/Release/net8.0/gcm*.exe artifacts/

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 6.0.201
dotnet-version: 8.0.x

- name: Install dependencies
run: dotnet restore
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 6.0.201
dotnet-version: 8.0.x

- name: Install dependencies
run: dotnet restore
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build
run: |
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build
run: |
Expand Down Expand Up @@ -192,15 +192,15 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build with signed payload
run: |
dotnet build $env:GITHUB_WORKSPACE\src\windows\Installer.Windows `
/p:PayloadPath=$env:GITHUB_WORKSPACE\payload /p:NoLayout=true `
--configuration=WindowsRelease
mkdir installers
Move-Item -Path .\out\windows\Installer.Windows\bin\Release\net472\*.exe `
Move-Item -Path .\out\windows\Installer.Windows\bin\Release\net8.0\*.exe `
-Destination $env:GITHUB_WORKSPACE\installers

- name: Sign installers with Azure Code Signing
Expand Down Expand Up @@ -238,7 +238,7 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build
run: dotnet build --configuration=LinuxRelease
Expand Down Expand Up @@ -316,7 +316,7 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build .NET tool
run: |
Expand Down Expand Up @@ -410,7 +410,7 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Package tool
run: |
Expand Down Expand Up @@ -523,7 +523,7 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Download artifacts
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -593,7 +593,7 @@ jobs:
- name: Set up .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Download artifacts
uses: actions/download-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/out/shared/Git-Credential-Manager/bin/Debug/net7.0/git-credential-manager.dll",
"program": "${workspaceFolder}/out/shared/Git-Credential-Manager/bin/Debug/net8.0/git-credential-manager.dll",
"args": ["get"],
"cwd": "${workspaceFolder}/out/shared/Git-Credential-Manager",
"console": "integratedTerminal",
Expand All @@ -22,7 +22,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/out/shared/Git-Credential-Manager/bin/Debug/net7.0/git-credential-manager.dll",
"program": "${workspaceFolder}/out/shared/Git-Credential-Manager/bin/Debug/net8.0/git-credential-manager.dll",
"args": ["store"],
"cwd": "${workspaceFolder}/out/shared/Git-Credential-Manager",
"console": "integratedTerminal",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"type": "shell",
"group": "test",
"args": [
"~/.nuget/packages/reportgenerator/*/*/net7.0/ReportGenerator.dll",
"~/.nuget/packages/reportgenerator/*/*/net8.0/ReportGenerator.dll",
"-reports:${workspaceFolder}/**/TestResults/**/coverage.cobertura.xml",
"-targetdir:${workspaceFolder}/out/code-coverage"
],
Expand All @@ -71,7 +71,7 @@
"type": "shell",
"group": "test",
"args": [
"${env:USERROFILE}/.nuget/packages/reportgenerator/*/*/net7.0/ReportGenerator.dll",
"${env:USERROFILE}/.nuget/packages/reportgenerator/*/*/net8.0/ReportGenerator.dll",
"-reports:${workspaceFolder}/**/TestResults/**/coverage.cobertura.xml",
"-targetdir:${workspaceFolder}/out/code-coverage"
],
Expand Down
6 changes: 0 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,4 @@
<GenerateWindowsAppManifest Condition="'$(GenerateWindowsAppManifest)' == '' AND '$(OSPlatform)' == 'windows' AND '$(_IsExeProject)' == 'true'">true</GenerateWindowsAppManifest>
</PropertyGroup>

<ItemGroup Condition = "'$(TargetFramework)' == 'net472'">
<PackageReference Include="System.Text.Json">
<Version>7.0.2</Version>
</PackageReference>
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@
</ItemGroup>
</Target>

<PropertyGroup>
<!-- Ignore platform API compatibilty checks in test projects -->
<NoWarn Condition="'$(IsTestProject)'=='true'">$(NoWarn);CA1416</NoWarn>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion build/GCM.MSBuild.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

Expand Down
8 changes: 4 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ To build from the command line, run:
dotnet build -c WindowsDebug
```

You can find a copy of the installer .exe file in `out\windows\Installer.Windows\bin\Debug\net472`.
You can find a copy of the installer .exe file in `out\windows\Installer.Windows\bin\Debug\net8.0`.

The flat binaries can also be found in `out\windows\Payload.Windows\bin\Debug\net472\win-x86`.
The flat binaries can also be found in `out\windows\Payload.Windows\bin\Debug\net8.0\win-x86`.

### Linux

Expand Down Expand Up @@ -209,13 +209,13 @@ HTML reports can be generated using ReportGenerator, this should be installed
during the build process, from the command line:

```shell
dotnet ~/.nuget/packages/reportgenerator/*/*/net7.0/ReportGenerator.dll -reports:./**/TestResults/**/coverage.cobertura.xml -targetdir:./out/code-coverage
dotnet ~/.nuget/packages/reportgenerator/*/*/net8.0/ReportGenerator.dll -reports:./**/TestResults/**/coverage.cobertura.xml -targetdir:./out/code-coverage
```

or

```shell
dotnet {$env:USERPROFILE}/.nuget/packages/reportgenerator/*/*/net7.0/ReportGenerator.dll -reports:./**/TestResults/**/coverage.cobertura.xml -targetdir:./out/code-coverage
dotnet {$env:USERPROFILE}/.nuget/packages/reportgenerator/*/*/net8.0/ReportGenerator.dll -reports:./**/TestResults/**/coverage.cobertura.xml -targetdir:./out/code-coverage
```

Or via VSCode Terminal/Run Task:
Expand Down
2 changes: 1 addition & 1 deletion src/linux/Packaging.Linux/Packaging.Linux.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/linux/Packaging.Linux/install-from-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ case "$distribution" in
# Install dotnet packages and dependencies if needed.
if [ -z "$(verify_existing_dotnet_installation)" ]; then
# First try to use native feeds (Ubuntu 22.04 and later).
if ! apt_install dotnet7; then
if ! apt_install dotnet8; then
# If the native feeds fail, we fall back to
# packages.microsoft.com. We begin by adding the dotnet package
# repository/signing key.
Expand Down
3 changes: 1 addition & 2 deletions src/linux/Packaging.Linux/layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ GCM_SRC="$SRC/shared/Git-Credential-Manager"
PROJ_OUT="$OUT/linux/Packaging.Linux"

# Build parameters
FRAMEWORK=net7.0
FRAMEWORK=net8.0
RUNTIME=linux-x64

# Perform pre-execution checks
Expand Down Expand Up @@ -74,7 +74,6 @@ $DOTNET_ROOT/dotnet publish "$GCM_SRC" \
--framework="$FRAMEWORK" \
--runtime="$RUNTIME" \
--self-contained \
-p:PublishSingleFile=true \
--output="$(make_absolute "$PAYLOAD")" || exit 1

# Collect symbols
Expand Down
2 changes: 1 addition & 1 deletion src/osx/Installer.Mac/Installer.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

Expand Down
3 changes: 1 addition & 2 deletions src/osx/Installer.Mac/layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ SRC="$ROOT/src"
OUT="$ROOT/out"
INSTALLER_SRC="$SRC/osx/Installer.Mac"
GCM_SRC="$SRC/shared/Git-Credential-Manager"
GCM_UI_SRC="$SRC/shared/Git-Credential-Manager.UI.Avalonia"

# Build parameters
FRAMEWORK=net7.0
FRAMEWORK=net8.0

# Parse script arguments
for i in "$@"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
Expand Down
7 changes: 1 addition & 6 deletions src/shared/Atlassian.Bitbucket/Atlassian.Bitbucket.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OSPlatform)'=='windows'">net7.0;net472</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>Atlassian.Bitbucket</AssemblyName>
<RootNamespace>Atlassian.Bitbucket</RootNamespace>
<IsTestProject>false</IsTestProject>
Expand All @@ -13,10 +12,6 @@
<ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<AvaloniaResource Include="UI\Assets\atlassian-logo.png" />
</ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/shared/Atlassian.Bitbucket/BitbucketJsonSerializerContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace Atlassian.Bitbucket;

[JsonSourceGenerationOptions(
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNameCaseInsensitive = true
)]
[JsonSerializable(typeof(BitbucketTokenEndpointResponseJson))]
[JsonSerializable(typeof(Cloud.UserInfo), TypeInfoPropertyName = "Cloud_UserInfo")]
[JsonSerializable(typeof(DataCenter.UserInfo), TypeInfoPropertyName = "DataCenter_UserInfo")]
[JsonSerializable(typeof(DataCenter.LoginOptions))]
internal partial class BitbucketJsonSerializerContext : JsonSerializerContext
{
}
3 changes: 2 additions & 1 deletion src/shared/Atlassian.Bitbucket/BitbucketOAuth2Client.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using GitCredentialManager;
Expand Down Expand Up @@ -42,7 +43,7 @@ protected override bool TryCreateTokenEndpointResult(string json, out OAuth2Toke
// We override the token endpoint response parsing because the Bitbucket authority returns
// the non-standard 'scopes' property for the list of scopes, rather than the (optional)
// 'scope' (note the singular vs plural) property as outlined in the standard.
if (TryDeserializeJson(json, out BitbucketTokenEndpointResponseJson jsonObj))
if (TryDeserializeJson(json, BitbucketJsonSerializerContext.Default, out BitbucketTokenEndpointResponseJson jsonObj))
{
result = jsonObj.ToResult();
return true;
Expand Down
6 changes: 1 addition & 5 deletions src/shared/Atlassian.Bitbucket/Cloud/BitbucketRestApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ public async Task<RestApiResult<IUserInfo>> GetUserInformationAsync(string userN

if (response.IsSuccessStatusCode)
{
var obj = JsonSerializer.Deserialize<UserInfo>(json,
new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
});
UserInfo obj = JsonSerializer.Deserialize(json, BitbucketJsonSerializerContext.Default.Cloud_UserInfo);

return new RestApiResult<IUserInfo>(response.StatusCode, obj);
}
Expand Down
9 changes: 2 additions & 7 deletions src/shared/Atlassian.Bitbucket/DataCenter/BitbucketRestApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,7 @@ public async Task<List<AuthenticationMethod>> GetAuthenticationMethodsAsync()

if (response.IsSuccessStatusCode)
{
var loginOptions = JsonSerializer.Deserialize<LoginOptions>(json,
new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
});
LoginOptions loginOptions = JsonSerializer.Deserialize(json, BitbucketJsonSerializerContext.Default.LoginOptions);

if (loginOptions.Results.Any(r => "LOGIN_FORM".Equals(r.Type)))
{
Expand Down Expand Up @@ -151,4 +146,4 @@ private Uri ApiUri
}
}
}
}
}
2 changes: 2 additions & 0 deletions src/shared/Atlassian.Bitbucket/UI/Views/CredentialsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
xmlns:vm="clr-namespace:Atlassian.Bitbucket.UI.ViewModels;assembly=Atlassian.Bitbucket"
xmlns:converters="clr-namespace:GitCredentialManager.UI.Converters;assembly=gcmcore"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="vm:CredentialsViewModel"
x:CompileBindings="True"
x:Class="Atlassian.Bitbucket.UI.Views.CredentialsView">
<Design.DataContext>
<vm:CredentialsViewModel/>
Expand Down
2 changes: 1 addition & 1 deletion src/shared/Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
Expand Down
Loading