Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@
]
}
},
"XmlEncodedAppNameParam": {
"XmlEncodedAppNameParam": {
"type": "derived",
"valueSource": "name",
"valueTransform": "encode",
"replaces": "XmlEncodedAppName"
},
"defaultAppId":{
"defaultAppId":{
"type": "generated",
"generator": "join",
"parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>MauiApp.1</string>
<string>XmlEncodedAppName</string>
<key>CFBundleIdentifier</key>
<string>com.companyname.mauiapp</string>
<key>CFBundleShortVersionString</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>MauiApp.1</string>
<string>XmlEncodedAppName</string>
<key>CFBundleIdentifier</key>
<string>com.companyname.mauiapp</string>
<key>CFBundleShortVersionString</key>
Expand Down
16 changes: 8 additions & 8 deletions src/Templates/src/templates/maui-multiproject/MauiApp.1.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
#if (winui)
#if (AllPlatforms || winui)
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp.1.WinUI", "MauiApp.1.WinUI\MauiApp.1.WinUI.csproj", "{1AA5F22B-62F8-414F-AE50-635E99EB3F76}"
EndProject
#endif
#if (maccatalyst)
#if (AllPlatforms || maccatalyst)
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp.1.Mac", "MauiApp.1.Mac\MauiApp.1.Mac.csproj", "{C2800ABA-8C19-4553-A552-BFF679BEB039}"
EndProject
#endif
#if (ios)
#if (AllPlatforms || ios)
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp.1.iOS", "MauiApp.1.iOS\MauiApp.1.iOS.csproj", "{7C064C71-30BE-4D8D-9B68-E7249ED18FA1}"
EndProject
#endif
#if (android)
#if (AllPlatforms || android)
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp.1.Droid", "MauiApp.1.Droid\MauiApp.1.Droid.csproj", "{9E30318E-74DD-491B-9BAF-814DC9E892B8}"
EndProject
#endif
Expand All @@ -33,7 +33,7 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
#if (winui)
#if (AllPlatforms || winui)
{1AA5F22B-62F8-414F-AE50-635E99EB3F76}.Debug|Any CPU.ActiveCfg = Debug|x64
{1AA5F22B-62F8-414F-AE50-635E99EB3F76}.Debug|Any CPU.Build.0 = Debug|x64
{1AA5F22B-62F8-414F-AE50-635E99EB3F76}.Debug|Any CPU.Deploy.0 = Debug|x64
Expand All @@ -59,7 +59,7 @@ Global
{1AA5F22B-62F8-414F-AE50-635E99EB3F76}.Release|x86.Build.0 = Release|x86
{1AA5F22B-62F8-414F-AE50-635E99EB3F76}.Release|x86.Deploy.0 = Release|x86
#endif
#if (maccatalyst)
#if (AllPlatforms || maccatalyst)
{C2800ABA-8C19-4553-A552-BFF679BEB039}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2800ABA-8C19-4553-A552-BFF679BEB039}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2800ABA-8C19-4553-A552-BFF679BEB039}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand All @@ -85,7 +85,7 @@ Global
{C2800ABA-8C19-4553-A552-BFF679BEB039}.Release|x86.Build.0 = Release|Any CPU
{C2800ABA-8C19-4553-A552-BFF679BEB039}.Release|x86.Deploy.0 = Release|Any CPU
#endif
#if (ios)
#if (AllPlatforms || ios)
{7C064C71-30BE-4D8D-9B68-E7249ED18FA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C064C71-30BE-4D8D-9B68-E7249ED18FA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C064C71-30BE-4D8D-9B68-E7249ED18FA1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand All @@ -111,7 +111,7 @@ Global
{7C064C71-30BE-4D8D-9B68-E7249ED18FA1}.Release|x86.Build.0 = Release|Any CPU
{7C064C71-30BE-4D8D-9B68-E7249ED18FA1}.Release|x86.Deploy.0 = Release|Any CPU
#endif
#if (android)
#if (AllPlatforms || android)
{9E30318E-74DD-491B-9BAF-814DC9E892B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E30318E-74DD-491B-9BAF-814DC9E892B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E30318E-74DD-491B-9BAF-814DC9E892B8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ public void BuildMultiProject(string config, string projectName)
Assert.IsTrue(DotnetInternal.New("maui-multiproject", projectDir, DotNetCurrent),
$"Unable to create template maui-multiproject. Check test output for errors.");

if (!TestEnvironment.IsWindows)
// Always remove WinUI project if the project name contains special characters that cause WinRT source generator issues
// See: https://github.com/microsoft/CsWinRT/issues/1809 (under "Special characters in assembly name" section)
bool containsSpecialChars = projectName.IndexOfAny(new[] { '@', '&', '+', '%', '!', '#', '$', '^', '*', ' ', '-' }) >= 0;

if (!TestEnvironment.IsWindows || containsSpecialChars)
{
Assert.IsTrue(DotnetInternal.Run("sln", $"\"{solutionFile}\" remove \"{projectDir}/{name}.WinUI/{name}.WinUI.csproj\""),
$"Unable to remove WinUI project from solution. Check test output for errors.");
}

Assert.IsTrue(DotnetInternal.Build(solutionFile, config, properties: BuildProps, msbuildWarningsAsErrors: true),
// TODO, we should not need this but hitting: https://github.com/dotnet/maui/issues/19840
var buildProps = BuildProps;
buildProps.Add("ResizetizerErrorOnDuplicateOutputFilename=false");

Assert.IsTrue(DotnetInternal.Build(solutionFile, config, properties: buildProps, msbuildWarningsAsErrors: true),
$"Solution {name} failed to build. Check test output/attachments for errors.");
}

Expand All @@ -50,4 +58,63 @@ public void BuildMultiProjectSinglePlatform(string config, string platformArg)
Assert.IsTrue(DotnetInternal.Build(solutionFile, config, properties: BuildProps, msbuildWarningsAsErrors: true),
$"Solution {name} failed to build. Check test output/attachments for errors.");
}

[Test]
[TestCase("--android")]
[TestCase("--ios")]
[TestCase("--windows")]
[TestCase("--macos")]
[TestCase("")] // no platform arg means all platforms
// https://github.com/dotnet/maui/issues/28695
public void VerifyIncludedPlatformsInSln(string platformArg)
{
var projectDir = TestDirectory;
var name = Path.GetFileName(projectDir);
var solutionFile = Path.Combine(projectDir, $"{name}.sln");

Assert.IsTrue(DotnetInternal.New($"maui-multiproject {platformArg}", projectDir, DotNetCurrent),
$"Unable to create template maui-multiproject. Check test output for errors.");

var slnListOutput = DotnetInternal.RunForOutput("sln", $"{solutionFile} list", out int exitCode);

// Asserts the process completed successfully
Assert.AreEqual(0, exitCode, $"Unable to list projects in solution. Check test output for errors.");

// Asserts if the shared project is included in the solution, this should always be the case
Assert.IsTrue(slnListOutput.Contains($"{name}.csproj", StringComparison.OrdinalIgnoreCase),
$"Expected shared project (with name {name}.csproj) to be included in the solution.");

var expectedCsprojFiles = new List<string> { "Droid.csproj", "iOS.csproj", "Mac.csproj", "WinUI.csproj" };

switch (platformArg)
{
case "--android":
expectedCsprojFiles.Remove("iOS.csproj");
expectedCsprojFiles.Remove("WinUI.csproj");
expectedCsprojFiles.Remove("Mac.csproj");
break;
case "--ios":
expectedCsprojFiles.Remove("Droid.csproj");
expectedCsprojFiles.Remove("WinUI.csproj");
expectedCsprojFiles.Remove("Mac.csproj");
break;
case "--windows":
expectedCsprojFiles.Remove("Droid.csproj");
expectedCsprojFiles.Remove("iOS.csproj");
expectedCsprojFiles.Remove("Mac.csproj");
break;
case "--macos":
expectedCsprojFiles.Remove("Droid.csproj");
expectedCsprojFiles.Remove("iOS.csproj");
expectedCsprojFiles.Remove("WinUI.csproj");
break;
}

// Depending on the platform argument, we assert if the expected projects are included in the solution
foreach (var platformCsproj in expectedCsprojFiles)
{
Assert.IsTrue(slnListOutput.Contains(platformCsproj, StringComparison.Ordinal),
$"Expected {platformCsproj} to be included in the solution.");
}
}
}
Loading