Skip to content

Commit

Permalink
Fix the build in Visual Studio (git-ecosystem#1711)
Browse files Browse the repository at this point in the history
Michael J. Lyons reached out privately and reported a problem with
building inside Visual Studio. The symptom is:

| Error (active) | MSB4044 | The "GenerateWindowsAppManifest" task was
not given a value for the required parameter "Version". |
| - | - | - |

This PR fixes this error, and then also addresses all the warnings
pointed out by Visual Studio.
  • Loading branch information
Matthew John Cheetham authored Sep 30, 2024
2 parents 4e8e593 + 1a774c1 commit f4b50c4
Show file tree
Hide file tree
Showing 34 changed files with 197 additions and 161 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

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

Expand Down
3 changes: 2 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Import Project="$(RepoPath)build\GCM.tasks" />

<!-- Use version specified in VERSION file -->
<Target Name="GetVersion" BeforeTargets="BeforeBuild">
<Target Name="GetVersion" BeforeTargets="BeforeBuild;GenerateWindowsAppManifest">
<GetVersion VersionFile="$(RepoPath)VERSION">
<Output TaskParameter="Version" PropertyName="Version" />
<Output TaskParameter="AssemblyVersion" PropertyName="AssemblyVersion" />
Expand All @@ -21,6 +21,7 @@

<!-- Generate the manifest file before we set the win32 manifest properties -->
<Target Name="GenerateWindowsAppManifest"
AfterTargets="GetVersion"
BeforeTargets="SetWin32ManifestProperties"
Condition="'$(GenerateWindowsAppManifest)' != 'false'"
Inputs="$(FileVersion);$(AssemblyName)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="ReportGenerator" Version="5.1.9" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="ReportGenerator" Version="5.3.10" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/shared/Core.Tests/ApplicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public async Task Application_UnconfigureAsync_EmptyAndGcmWithOthersBefore_Remov

Assert.Single(context.Git.Configuration.Global);
Assert.True(context.Git.Configuration.Global.TryGetValue(key, out var actualValues));
Assert.Equal(1, actualValues.Count);
Assert.Single(actualValues);
Assert.Equal(beforeHelper, actualValues[0]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace GitCredentialManager.Tests.Authentication
public class BasicAuthenticationTests
{
[Fact]
public void BasicAuthentication_GetCredentials_NullResource_ThrowsException()
public async Task BasicAuthentication_GetCredentials_NullResource_ThrowsException()
{
var context = new TestCommandContext();
var basicAuth = new BasicAuthentication(context);

Assert.ThrowsAsync<ArgumentNullException>(() => basicAuth.GetCredentialsAsync(null));
await Assert.ThrowsAsync<ArgumentNullException>(() => basicAuth.GetCredentialsAsync(null));
}

[Fact]
Expand Down Expand Up @@ -58,7 +58,7 @@ public async Task BasicAuthentication_GetCredentials_NonDesktopSession_Resource_
}

[Fact]
public void BasicAuthentication_GetCredentials_NonDesktopSession_NoTerminalPrompts_ThrowsException()
public async Task BasicAuthentication_GetCredentials_NonDesktopSession_NoTerminalPrompts_ThrowsException()
{
const string testResource = "https://example.com";

Expand All @@ -70,7 +70,7 @@ public void BasicAuthentication_GetCredentials_NonDesktopSession_NoTerminalPromp

var basicAuth = new BasicAuthentication(context);

Assert.ThrowsAsync<InvalidOperationException>(() => basicAuth.GetCredentialsAsync(testResource));
await Assert.ThrowsAsync<GitCredentialManager.Trace2InvalidOperationException>(() => basicAuth.GetCredentialsAsync(testResource));
}

[Fact]
Expand Down
11 changes: 7 additions & 4 deletions src/shared/Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="ReportGenerator" Version="5.1.9" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="ReportGenerator" Version="5.3.10" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/shared/Core.Tests/CurlCookieTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void CurlCookieParser_Parse_MissingFields_SkipsInvalidLines()

IList<Cookie> actual = parser.Parse(content);

Assert.Equal(1, actual.Count);
Assert.Single(actual);
AssertCookie(actual[0], ".example.com", "/path/here", true, 0, "cookie1", "value1");
}

Expand Down
22 changes: 11 additions & 11 deletions src/shared/Core.Tests/EnvironmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class EnvironmentTests
private const string PosixPathVar = "/home/john.doe/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
private const string PosixExecName = "foo";

[PlatformFact(Platforms.Windows)]
[WindowsFact]
public void WindowsEnvironment_TryLocateExecutable_NotExists_ReturnFalse()
{
var fs = new TestFileSystem();
Expand All @@ -28,7 +28,7 @@ public void WindowsEnvironment_TryLocateExecutable_NotExists_ReturnFalse()
Assert.Null(actualPath);
}

[PlatformFact(Platforms.Windows)]
[WindowsFact]
public void WindowsEnvironment_TryLocateExecutable_Exists_ReturnTrueAndPath()
{
string expectedPath = @"C:\Windows\system32\foo.exe";
Expand All @@ -48,7 +48,7 @@ public void WindowsEnvironment_TryLocateExecutable_Exists_ReturnTrueAndPath()
Assert.Equal(expectedPath, actualPath);
}

[PlatformFact(Platforms.Windows)]
[WindowsFact]
public void WindowsEnvironment_TryLocateExecutable_ExistsMultiple_ReturnTrueAndFirstPath()
{
string expectedPath = @"C:\Users\john.doe\bin\foo.exe";
Expand All @@ -70,7 +70,7 @@ public void WindowsEnvironment_TryLocateExecutable_ExistsMultiple_ReturnTrueAndF
Assert.Equal(expectedPath, actualPath);
}

[PlatformFact(Platforms.Posix)]
[PosixFact]
public void PosixEnvironment_TryLocateExecutable_NotExists_ReturnFalse()
{
var fs = new TestFileSystem();
Expand All @@ -83,7 +83,7 @@ public void PosixEnvironment_TryLocateExecutable_NotExists_ReturnFalse()
Assert.Null(actualPath);
}

[PlatformFact(Platforms.Posix)]
[PosixFact]
public void PosixEnvironment_TryLocateExecutable_Exists_ReturnTrueAndPath()
{
string expectedPath = "/usr/local/bin/foo";
Expand All @@ -103,7 +103,7 @@ public void PosixEnvironment_TryLocateExecutable_Exists_ReturnTrueAndPath()
Assert.Equal(expectedPath, actualPath);
}

[PlatformFact(Platforms.Posix)]
[PosixFact]
public void PosixEnvironment_TryLocateExecutable_ExistsMultiple_ReturnTrueAndFirstPath()
{
string expectedPath = "/home/john.doe/bin/foo";
Expand All @@ -125,7 +125,7 @@ public void PosixEnvironment_TryLocateExecutable_ExistsMultiple_ReturnTrueAndFir
Assert.Equal(expectedPath, actualPath);
}

[PlatformFact(Platforms.MacOS)]
[MacOSFact]
public void MacOSEnvironment_TryLocateExecutable_Paths_Are_Ignored()
{
List<string> pathsToIgnore = new List<string>()
Expand All @@ -150,8 +150,8 @@ public void MacOSEnvironment_TryLocateExecutable_Paths_Are_Ignored()
Assert.True(actualResult);
Assert.Equal(expectedPath, actualPath);
}
[PlatformFact(Platforms.Posix)]

[PosixFact]
public void PosixEnvironment_SetEnvironmentVariable_Sets_Expected_Value()
{
var variable = "FOO_BAR";
Expand All @@ -166,8 +166,8 @@ public void PosixEnvironment_SetEnvironmentVariable_Sets_Expected_Value()
Assert.Contains(env.Variables, item
=> item.Key.Equals(variable) && item.Value.Equals(value));
}
[PlatformFact(Platforms.Windows)]

[WindowsFact]
public void WindowsEnvironment_SetEnvironmentVariable_Sets_Expected_Value()
{
var variable = "FOO_BAR";
Expand Down
4 changes: 2 additions & 2 deletions src/shared/Core.Tests/GenericHostProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ public async Task GenericHostProvider_CreateCredentialAsync_NonHttpProtocol_Retu
basicAuthMock.Verify(x => x.GetCredentialsAsync(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}

[PlatformFact(Platforms.Posix)]
[PosixFact]
public async Task GenericHostProvider_CreateCredentialAsync_NonWindows_WiaSupported_ReturnsBasicCredential()
{
await TestCreateCredentialAsync_ReturnsBasicCredential(wiaSupported: true);
}

[PlatformFact(Platforms.Windows)]
[WindowsFact]
public async Task GenericHostProvider_CreateCredentialAsync_Windows_WiaSupported_ReturnsEmptyCredential()
{
await TestCreateCredentialAsync_ReturnsEmptyCredential(wiaSupported: true);
Expand Down
8 changes: 4 additions & 4 deletions src/shared/Core.Tests/HostProviderRegistryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public void HostProviderRegistry_Register_AutoAuthorityId_ThrowException()
}

[Fact]
public void HostProviderRegistry_GetProvider_NoProviders_ThrowException()
public async Task HostProviderRegistry_GetProvider_NoProviders_ThrowException()
{
var context = new TestCommandContext();
var registry = new HostProviderRegistry(context);
var input = new InputArguments(new Dictionary<string, string>());

Assert.ThrowsAsync<Exception>(() => registry.GetProviderAsync(input));
await Assert.ThrowsAsync<GitCredentialManager.Trace2Exception>(() => registry.GetProviderAsync(input));
}

[Fact]
Expand Down Expand Up @@ -119,7 +119,7 @@ public async Task HostProviderRegistry_GetProvider_Auto_HasProviders_DynamicMatc

Assert.Same(providerMock.Object, result);
Assert.True(context.Git.Configuration.Global.TryGetValue(configKey, out IList<string> config));
Assert.Equal(1, config.Count);
Assert.Single(config);
Assert.Equal(providerId, config[0]);
}

Expand Down Expand Up @@ -148,7 +148,7 @@ public async Task HostProviderRegistry_GetProvider_Auto_HasProviders_DynamicMatc

Assert.Same(providerMock.Object, result);
Assert.True(context.Git.Configuration.Global.TryGetValue(configKey, out IList<string> config));
Assert.Equal(1, config.Count);
Assert.Single(config);
Assert.Equal(providerId, config[0]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/Core.Tests/HostProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task HostProvider_GetCredentialAsync_CredentialExists_ReturnsExisti
IsSupportedFunc = _ => true,
GenerateCredentialFunc = _ =>
{
Assert.True(false, "Should never be called");
Assert.Fail("Should never be called");
return null;
},
};
Expand Down
6 changes: 3 additions & 3 deletions src/shared/Core.Tests/IniFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ recovery tests]
Assert.Equal(6, ini.Sections.Count);

AssertSection(ini, "one", out IniSection one);
Assert.Equal(1, one.Properties.Count);
Assert.Single(one.Properties);
AssertProperty(one, "foo", "123");

AssertSection(ini, "two", out IniSection twoA);
Expand All @@ -88,7 +88,7 @@ recovery tests]
AssertProperty(twoA, "widget", "Hello, World!");

AssertSection(ini, "two", "subsection name", out IniSection twoB);
Assert.Equal(1, twoB.Properties.Count);
Assert.Single(twoB.Properties);
AssertProperty(twoB, "foo", "this is different");

AssertSection(ini, "three", out IniSection three);
Expand All @@ -97,7 +97,7 @@ recovery tests]
AssertProperty(three, "empty", "");

AssertSection(ini, "four", out IniSection four);
Assert.Equal(0, four.Properties.Count);
Assert.Empty(four.Properties);

AssertSection(ini, "five", out IniSection five);
Assert.Equal(3, five.Properties.Count);
Expand Down
12 changes: 6 additions & 6 deletions src/shared/Core.Tests/Interop/Linux/LinuxFileSystemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace GitCredentialManager.Tests.Interop.Linux
{
public class LinuxFileSystemTests
{
[PlatformFact(Platforms.Linux)]
[LinuxFact]
public static void LinuxFileSystem_IsSamePath_SamePath_ReturnsTrue()
{
var fs = new LinuxFileSystem();
Expand All @@ -18,7 +18,7 @@ public static void LinuxFileSystem_IsSamePath_SamePath_ReturnsTrue()
Assert.True(fs.IsSamePath(fileA, fileA));
}

[PlatformFact(Platforms.Linux)]
[LinuxFact]
public static void LinuxFileSystem_IsSamePath_DifferentFile_ReturnsFalse()
{
var fs = new LinuxFileSystem();
Expand All @@ -31,7 +31,7 @@ public static void LinuxFileSystem_IsSamePath_DifferentFile_ReturnsFalse()
Assert.False(fs.IsSamePath(fileB, fileA));
}

[PlatformFact(Platforms.Linux)]
[LinuxFact]
public static void LinuxFileSystem_IsSamePath_SameFileDifferentCase_ReturnsFalse()
{
var fs = new LinuxFileSystem();
Expand All @@ -44,7 +44,7 @@ public static void LinuxFileSystem_IsSamePath_SameFileDifferentCase_ReturnsFalse
Assert.False(fs.IsSamePath(fileA2, fileA1));
}

[PlatformFact(Platforms.Linux)]
[LinuxFact]
public static void LinuxFileSystem_IsSamePath_SameFileDifferentPathNormalization_ReturnsTrue()
{
var fs = new LinuxFileSystem();
Expand All @@ -58,7 +58,7 @@ public static void LinuxFileSystem_IsSamePath_SameFileDifferentPathNormalization
Assert.True(fs.IsSamePath(fileA2, fileA1));
}

[PlatformFact(Platforms.Linux)]
[LinuxFact]
public static void LinuxFileSystem_IsSamePath_SameFileViaSymlink_ReturnsTrue()
{
var fs = new LinuxFileSystem();
Expand All @@ -71,7 +71,7 @@ public static void LinuxFileSystem_IsSamePath_SameFileViaSymlink_ReturnsTrue()
Assert.True(fs.IsSamePath(fileA2, fileA1));
}

[PlatformFact(Platforms.Linux)]
[LinuxFact]
public static void LinuxFileSystem_IsSamePath_SameFileRelativePath_ReturnsTrue()
{
var fs = new LinuxFileSystem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SecretServiceCollectionTests
{
private const string TestNamespace = "git-test";

[PlatformFact(Platforms.Linux, Skip = "Cannot run headless")]
[LinuxFact(Skip = "Cannot run headless")]
public void SecretServiceCollection_ReadWriteDelete()
{
var collection = new SecretServiceCollection(TestNamespace);
Expand Down Expand Up @@ -37,7 +37,7 @@ public void SecretServiceCollection_ReadWriteDelete()
}
}

[PlatformFact(Platforms.Linux, Skip = "Cannot run headless")]
[LinuxFact(Skip = "Cannot run headless")]
public void SecretServiceCollection_Get_NotFound_ReturnsNull()
{
var collection = new SecretServiceCollection(TestNamespace);
Expand All @@ -49,7 +49,7 @@ public void SecretServiceCollection_Get_NotFound_ReturnsNull()
Assert.Null(credential);
}

[PlatformFact(Platforms.Linux, Skip = "Cannot run headless")]
[LinuxFact(Skip = "Cannot run headless")]
public void SecretServiceCollection_Remove_NotFound_ReturnsFalse()
{
var collection = new SecretServiceCollection(TestNamespace);
Expand Down
Loading

0 comments on commit f4b50c4

Please sign in to comment.