Skip to content
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 @@ -29,6 +29,11 @@ jobs:
with:
dotnet-version: 8.0.x

- 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@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
/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
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'">
Copy link
Contributor

Choose a reason for hiding this comment

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

Glad to be getting rid of this!

<PackageReference Include="System.Text.Json">
<Version>8.0.5</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 @@ -34,4 +34,9 @@
</ItemGroup>
</Target>

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

</Project>
4 changes: 2 additions & 2 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
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>net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OSPlatform)'=='windows'">net8.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
4 changes: 0 additions & 4 deletions src/shared/Core/Authentication/AuthenticationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ protected internal virtual async Task<IDictionary<string, string>> InvokeHelperA
// Write the standard input to the process if we have any to write
if (standardInput is not null)
{
#if NETFRAMEWORK
await standardInput.BaseStream.CopyToAsync(process.StandardInput.BaseStream);
#else
await standardInput.BaseStream.CopyToAsync(process.StandardInput.BaseStream, ct);
#endif
process.StandardInput.Close();
}

Expand Down
29 changes: 8 additions & 21 deletions src/shared/Core/Authentication/MicrosoftAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
using GitCredentialManager.UI.ViewModels;
using GitCredentialManager.UI.Views;
using Microsoft.Identity.Client.AppConfig;

#if NETFRAMEWORK
using Microsoft.Identity.Client.Broker;
#endif

namespace GitCredentialManager.Authentication
{
Expand Down Expand Up @@ -508,15 +505,13 @@ private async Task<IPublicClientApplication> CreatePublicClientApplicationAsync(
// to save on the distribution size of the .NET builds (no need for MSALRuntime bits).
if (enableBroker)
{
#if NETFRAMEWORK
appBuilder.WithBroker(
new BrokerOptions(BrokerOptions.OperatingSystems.Windows)
{
Title = "Git Credential Manager",
MsaPassthrough = msaPt,
}
);
#endif
}

IPublicClientApplication app = appBuilder.Build();
Expand Down Expand Up @@ -808,7 +803,6 @@ public HttpClient GetHttpClient()

public bool CanUseBroker()
{
#if NETFRAMEWORK
// We only support the broker on Windows 10+ and in an interactive session
if (!Context.SessionManager.IsDesktopSession || !PlatformUtils.IsWindowsBrokerSupported())
{
Expand All @@ -827,34 +821,27 @@ public bool CanUseBroker()
}

return defaultValue;
#else
// OS broker requires .NET Framework right now until we migrate to .NET 5.0 (net5.0-windows10.x.y.z)
return false;
#endif
}

private bool CanUseEmbeddedWebView()
{
// If we're in an interactive session and on .NET Framework then MSAL can show the WinForms-based embedded UI
#if NETFRAMEWORK
return Context.SessionManager.IsDesktopSession;
#else
return false;
#endif
// If we're in an interactive session and on Windows then MSAL can show the WinForms-based embedded UI
return PlatformUtils.IsWindows() && Context.SessionManager.IsDesktopSession;
}

private void EnsureCanUseEmbeddedWebView()
{
#if NETFRAMEWORK
if (!Context.SessionManager.IsDesktopSession)
{
throw new Trace2InvalidOperationException(Context.Trace2,
"Embedded web view is not available without a desktop session.");
}
#else
throw new Trace2InvalidOperationException(Context.Trace2,
"Embedded web view is not available on .NET Core.");
#endif

if (!PlatformUtils.IsWindows())
{
throw new Trace2InvalidOperationException(Context.Trace2,
"Embedded web view is only available on Windows.");
}
}

private bool CanUseSystemWebView(IPublicClientApplication app, Uri redirectUri)
Expand Down
5 changes: 5 additions & 0 deletions src/shared/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public static class Constants
public const string GcmDataDirectoryName = ".gcm";

public const string MacOSBundleId = "git-credential-manager";

public const string WindowsPlatformName = "windows";
public const string LinuxPlatformName = "linux";
public const string MacOSPlatformName = "osx";

public static readonly Guid DevBoxPartnerId = new("e3171dd9-9a5f-e5be-b36c-cc7c4f3f3bcf");

/// <summary>
Expand Down
17 changes: 3 additions & 14 deletions src/shared/Core/Core.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OSPlatform)'=='windows'">net8.0;net472</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>gcmcore</AssemblyName>
<RootNamespace>GitCredentialManager</RootNamespace>
<IsTestProject>false</IsTestProject>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Reference Include="System.Net.Http" />
<Reference Include="System.Web" />
<PackageReference Include="Microsoft.Identity.Client.Broker" Version="4.65.0" />
<PackageReference Include="Avalonia.Win32" Version="11.1.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net472'">
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Identity.Client" Version="4.65.0" />
<PackageReference Include="Microsoft.Identity.Client.Broker" Version="4.65.0" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.65.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Avalonia" Version="11.1.3" />
<PackageReference Include="Avalonia.Skia" Version="11.1.3" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.3" />
</ItemGroup>

Expand Down
12 changes: 3 additions & 9 deletions src/shared/Core/CurlCookie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,12 @@ public IList<Cookie> Parse(string content)

private static DateTime ParseExpires(string expires)
{
#if NETFRAMEWORK
DateTime epoch = new DateTime(1970, 01, 01, 0, 0, 0, DateTimeKind.Utc);
#else
DateTime epoch = DateTime.UnixEpoch;
#endif

if (long.TryParse(expires, out long i))
{
return epoch.AddSeconds(i);
return DateTime.UnixEpoch.AddSeconds(i);
}

return epoch;
return DateTime.UnixEpoch;
}
}
}
}
20 changes: 0 additions & 20 deletions src/shared/Core/HttpClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ public HttpClient CreateClient()
_streams.Error.WriteLine("warning: ---------------------------------------------------");
_streams.Error.WriteLine($"warning: HTTPS connections may not be secure. See {Constants.HelpUrls.GcmTlsVerification} for more information.");

#if NETFRAMEWORK
ServicePointManager.ServerCertificateValidationCallback = (req, cert, chain, errors) => true;
#else
handler.ServerCertificateCustomValidationCallback = (req, cert, chain, errors) => true;
#endif
}
// If schannel is the TLS backend, custom certificate usage must be explicitly enabled
else if (!string.IsNullOrWhiteSpace(_settings.CustomCertificateBundlePath) &&
Expand Down Expand Up @@ -178,23 +174,7 @@ public HttpClient CreateClient()

// Set the custom server certificate validation callback.
// NOTE: this is executed after the default platform server certificate validation is performed
#if NETFRAMEWORK
ServicePointManager.ServerCertificateValidationCallback = (_, cert, chain, errors) =>
{
// Fail immediately if the cert or chain isn't present
if (cert is null || chain is null)
{
return false;
}

using (X509Certificate2 cert2 = new X509Certificate2(cert))
{
return validationCallback(cert2, chain, errors);
}
};
#else
handler.ServerCertificateCustomValidationCallback = (_, cert, chain, errors) => validationCallback(cert, chain, errors);
#endif
}

// If CustomCookieFilePath is set, set Cookie header from cookie file, which is written by libcurl
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Core/Interop/Linux/LinuxFileSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.IO;
using System.Runtime.Versioning;
using GitCredentialManager.Interop.Posix;

namespace GitCredentialManager.Interop.Linux
{
[SupportedOSPlatform(Constants.LinuxPlatformName)]
public class LinuxFileSystem : PosixFileSystem
{
public override bool IsSamePath(string a, string b)
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Core/Interop/Linux/LinuxSessionManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Runtime.Versioning;
using GitCredentialManager.Interop.Posix;

namespace GitCredentialManager.Interop.Linux;

[SupportedOSPlatform(Constants.LinuxPlatformName)]
public class LinuxSessionManager : PosixSessionManager
{
private bool? _isWebBrowserAvailable;
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Core/Interop/Linux/LinuxTerminal.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Runtime.Versioning;
using GitCredentialManager.Interop.Linux.Native;
using GitCredentialManager.Interop.Posix;
using GitCredentialManager.Interop.Posix.Native;

namespace GitCredentialManager.Interop.Linux
{
[SupportedOSPlatform(Constants.LinuxPlatformName)]
public class LinuxTerminal : PosixTerminal
{
public LinuxTerminal(ITrace trace, ITrace2 trace2)
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Core/Interop/MacOS/MacOSEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.Versioning;
using System.Threading;
using GitCredentialManager.Interop.Posix;

namespace GitCredentialManager.Interop.MacOS
{
[SupportedOSPlatform(Constants.MacOSPlatformName)]
public class MacOSEnvironment : PosixEnvironment
{
private ICollection<string> _pathsToIgnore;
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Core/Interop/MacOS/MacOSFileSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.IO;
using System.Runtime.Versioning;
using GitCredentialManager.Interop.Posix;

namespace GitCredentialManager.Interop.MacOS
{
[SupportedOSPlatform(Constants.MacOSPlatformName)]
public class MacOSFileSystem : PosixFileSystem
{
public override bool IsSamePath(string a, string b)
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Core/Interop/MacOS/MacOSSessionManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Runtime.Versioning;
using GitCredentialManager.Interop.MacOS.Native;
using GitCredentialManager.Interop.Posix;

namespace GitCredentialManager.Interop.MacOS
{
[SupportedOSPlatform(Constants.MacOSPlatformName)]
public class MacOSSessionManager : PosixSessionManager
{
public MacOSSessionManager(IEnvironment env, IFileSystem fs) : base(env, fs)
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Core/Interop/MacOS/MacOSTerminal.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Runtime.Versioning;
using GitCredentialManager.Interop.MacOS.Native;
using GitCredentialManager.Interop.Posix;
using GitCredentialManager.Interop.Posix.Native;

namespace GitCredentialManager.Interop.MacOS
{
[SupportedOSPlatform(Constants.MacOSPlatformName)]
public class MacOSTerminal : PosixTerminal
{
public MacOSTerminal(ITrace trace, ITrace2 trace2)
Expand Down
3 changes: 3 additions & 0 deletions src/shared/Core/Interop/Posix/PosixEnvironment.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;

namespace GitCredentialManager.Interop.Posix
{
[SupportedOSPlatform(Constants.LinuxPlatformName)]
[SupportedOSPlatform(Constants.MacOSPlatformName)]
public class PosixEnvironment : EnvironmentBase
{
public PosixEnvironment(IFileSystem fileSystem)
Expand Down
Loading