Skip to content

Commit

Permalink
Do not use underscores in the ApplicationId (#19377)
Browse files Browse the repository at this point in the history
* Do not use underscores in the ApplicationId

Underscores are not supported on Windows

* Update DotnetInternal.cs
  • Loading branch information
mattleibow authored Jan 23, 2024
1 parent 55ad2d8 commit e9029d0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"steps": [
{
"regex": "[^a-z0-9_\\.]",
"replacement": "_"
"replacement": ""
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"steps": [
{
"regex": "[^a-z0-9_\\.]",
"replacement": "_"
"replacement": ""
}
]
}
Expand Down
36 changes: 36 additions & 0 deletions src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Xml.Linq;
using Microsoft.Maui.IntegrationTests.Apple;

namespace Microsoft.Maui.IntegrationTests
Expand Down Expand Up @@ -47,6 +48,41 @@ 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 = Path.Combine(TestDirectory, projectName);
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);

// libraries do not have application IDs
if (id != "mauilib")
{
var doc = XDocument.Load(projectFile);
var appId = doc.Root!
.Elements("PropertyGroup")
.Elements("ApplicationId")
.Single()
.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)]
Expand Down

0 comments on commit e9029d0

Please sign in to comment.