From f501d24f10bb0ceb0212be5b1c69b7e48e219de6 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 12 Dec 2023 22:59:40 +0200 Subject: [PATCH] Do not use underscores in the ApplicationId Underscores are not supported on Windows --- .../TemplateTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs index 8c8d1968130f..9785f1d786d4 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs @@ -1,3 +1,4 @@ +using System.Xml.Linq; using Microsoft.Maui.IntegrationTests.Apple; namespace Microsoft.Maui.IntegrationTests @@ -47,6 +48,33 @@ public void Build(string id, string framework, string config, bool shouldPack) $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); } + [Test] + // with spaces + [TestCase("maui", "Project Space", "projectspace")] + [TestCase("maui-blazor", "Project Space", "projectspace")] + [TestCase("mauilib", "Project Space", "projectspace")] + // with invalid characters + [TestCase("maui", "Project@Symbol", "projectsymbol")] + [TestCase("maui-blazor", "Project@Symbol", "projectsymbol")] + [TestCase("mauilib", "Project@Symbol", "projectsymbol")] + public void BuildsWithSpecialCharacters(string id, string projectName, string expectedId) + { + var projectDir = TestDirectory; + var projectFile = Path.Combine(projectDir, $"{projectName}.csproj"); + + Assert.IsTrue(DotnetInternal.New(id, projectDir, DotNetCurrent), + $"Unable to create template {id}. Check test output for errors."); + + EnableTizen(projectFile); + + var doc = XDocument.Load(docPath); + var appId = doc.Root.Elements("PropertyGroup").Element("ApplicationId").Value; + Assert.AreEqual($"com.companyname.{expectedId}", appId); + + Assert.IsTrue(DotnetInternal.Build(projectFile, "Debug", properties: BuildProps, msbuildWarningsAsErrors: true), + $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); + } + [Test] // Parameters: short name, target framework, build config, use pack target [TestCase("maui", DotNetPrevious, "Debug", false)]