From bd31a9ab38491f9cf66da1855fecccc4470e1712 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Thu, 1 Jun 2023 17:48:54 +0700 Subject: [PATCH] Add some tests for changing the app version properties (#15338) * Revert "Set Version for Windows (#15238)" This reverts commit 130f7884327b490332d0094d87521c0a91c9a18f. * Add the test * tbis * oops --- .../src/nuget/buildTransitive/WinUI.targets | 8 ++++++ .../TemplateTests.cs | 27 +++++++++++++++++++ .../Utilities/DotnetInternal.cs | 9 +++++-- .../Sdk/Microsoft.Maui.Sdk.Before.targets | 9 ------- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/Core/src/nuget/buildTransitive/WinUI.targets b/src/Core/src/nuget/buildTransitive/WinUI.targets index d82a5b31dbd7..e6a9d3e59b13 100644 --- a/src/Core/src/nuget/buildTransitive/WinUI.targets +++ b/src/Core/src/nuget/buildTransitive/WinUI.targets @@ -1,6 +1,14 @@ + + + $(ApplicationDisplayVersion) + + <_ReferenceRelatedPaths diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs index 65816ddec731..794cdf033133 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs @@ -121,6 +121,33 @@ public void BuildWithoutPackageReference(string id, string framework, string con $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); } + [Test] + [TestCase("maui", "Debug", "2.0", "2")] + [TestCase("maui", "Release", "2.0", "2")] + [TestCase("maui", "Release", "0.3", "3")] + [TestCase("maui-blazor", "Debug", "2.0", "2")] + [TestCase("maui-blazor", "Release", "2.0", "2")] + [TestCase("maui-blazor", "Release", "0.3", "3")] + public void BuildWithDifferentVersionNumber(string id, string config, string display, string version) + { + var projectDir = TestDirectory; + var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj"); + + Assert.IsTrue(DotnetInternal.New(id, projectDir), + $"Unable to create template {id}. Check test output for errors."); + + EnableTizen(projectFile); + FileUtilities.ReplaceInFile(projectFile, + $"1.0", + $"{display}"); + FileUtilities.ReplaceInFile(projectFile, + $"1", + $"{version}"); + + Assert.IsTrue(DotnetInternal.Build(projectFile, config, properties: BuildProps), + $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); + } + void EnableTizen(string projectFile) { FileUtilities.ReplaceInFile(projectFile, new Dictionary() diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/DotnetInternal.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/DotnetInternal.cs index 269747a17f20..b080e80d20c5 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/DotnetInternal.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/DotnetInternal.cs @@ -37,9 +37,14 @@ public static bool Build(string projectFile, string config, string target = "", return Run("build", $"{buildArgs} -bl:\"{binlogPath}\""); } - public static bool New(string shortName, string outputDirectory, string framework) + public static bool New(string shortName, string outputDirectory, string framework = "") { - var output = RunForOutput("new", $"{shortName} -o \"{outputDirectory}\" -f {framework}", out int exitCode, timeoutInSeconds: 300); + var args = $"{shortName} -o \"{outputDirectory}\""; + + if (!string.IsNullOrEmpty(framework)) + args += $" -f {framework}"; + + var output = RunForOutput("new", args, out int exitCode, timeoutInSeconds: 300); TestContext.WriteLine(output); return exitCode == 0; } diff --git a/src/Workload/Microsoft.Maui.Sdk/Sdk/Microsoft.Maui.Sdk.Before.targets b/src/Workload/Microsoft.Maui.Sdk/Sdk/Microsoft.Maui.Sdk.Before.targets index 7f68a95e8c37..9c41f276d316 100644 --- a/src/Workload/Microsoft.Maui.Sdk/Sdk/Microsoft.Maui.Sdk.Before.targets +++ b/src/Workload/Microsoft.Maui.Sdk/Sdk/Microsoft.Maui.Sdk.Before.targets @@ -19,13 +19,4 @@ <_MauiUsingDefaultRuntimeIdentifier>true - - - $(ApplicationDisplayVersion) - -