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 @@ -462,6 +462,7 @@
<_MauiSplashAssets Include="$(_MauiIntermediateSplashScreen)**\*" />
<ContentWithTargetPath Include="@(_MauiSplashAssets)">
<TargetPath>%(_MauiSplashAssets.Filename)%(_MauiSplashAssets.Extension)</TargetPath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ContentWithTargetPath>
</ItemGroup>

Expand Down Expand Up @@ -548,6 +549,7 @@

<ContentWithTargetPath Include="@(_MauiFontCopied)" Condition="'@(_MauiFontCopied)' != ''">
<TargetPath>$([System.IO.Path]::GetFileName(%(_MauiFontCopied.Identity)))</TargetPath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ContentWithTargetPath>

</ItemGroup>
Expand Down Expand Up @@ -654,6 +656,7 @@
<ItemGroup Condition="'$(_ResizetizerIsWindowsAppSdk)' == 'True'">
<ContentWithTargetPath Include="@(_ResizetizerCollectedImages)">
<TargetPath>%(_ResizetizerCollectedImages.Filename)%(_ResizetizerCollectedImages.Extension)</TargetPath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ContentWithTargetPath>

<FileWrites Include="@(_ResizetizerCollectedImages)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public string TestName
public string TestNuGetConfig => Path.Combine(TestEnvironment.GetTestDirectoryRoot(), "NuGet.config");

// Properties that ensure we don't use cached packages, and *only* the empty NuGet.config
protected string[] BuildProps => new[]
protected List<string> BuildProps => new()
{
"RestoreNoCache=true",
//"GenerateAppxPackageOnBuild=true",
Expand Down
33 changes: 33 additions & 0 deletions src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,39 @@ public void BuildUnpackaged(string id, string framework, string config)
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");
}

[Test]
[TestCase("maui", "net7.0", "Release")]
public void PublishUnpackaged(string id, string framework, string config)
{
if (!TestEnvironment.IsWindows)
Assert.Ignore("Running Windows templates is only supported on Windows.");

var projectDir = TestDirectory;
var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj");

Assert.IsTrue(DotnetInternal.New(id, projectDir, framework),
$"Unable to create template {id}. Check test output for errors.");

BuildProps.Add("WindowsPackageType=None");

Assert.IsTrue(DotnetInternal.Publish(projectFile, config, framework: $"{framework}-windows10.0.19041.0", properties: BuildProps),
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");

var assetsRoot = Path.Combine(projectDir, $"bin/{config}/{framework}-windows10.0.19041.0/win10-x64/publish");

AssetExists("dotnet_bot.scale-100.png");
AssetExists("appiconLogo.scale-100.png");
AssetExists("OpenSans-Regular.ttf");
AssetExists("splashSplashScreen.scale-100.png");

void AssetExists(string filename)
{
var fullpath = Path.Combine(assetsRoot!, filename);
Assert.IsTrue(File.Exists(fullpath),
$"Unable to find expected asset: {fullpath}");
}
}

[Test]
[TestCase("mauilib", "net6.0", "Debug")]
[TestCase("mauilib", "net6.0", "Release")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ public static bool Build(string projectFile, string config, string target = "",
return Run("build", $"{buildArgs} -bl:\"{binlogPath}\"");
}

public static bool Publish(string projectFile, string config, string target = "", string framework = "", IEnumerable<string>? properties = null, string binlogPath = "")
{
var binlogName = $"publish-{DateTime.UtcNow.ToFileTimeUtc()}.binlog";
var buildArgs = $"\"{projectFile}\" -c {config}";

if (!string.IsNullOrEmpty(target))
{
binlogName = $"{target}-{DateTime.UtcNow.ToFileTimeUtc()}.binlog";
buildArgs += $" -t:{target}";
}

if (!string.IsNullOrEmpty(framework))
buildArgs += $" -f:{framework}";

if (properties != null)
{
foreach (var p in properties)
{
buildArgs += $" -p:{p}";
}
}

if (string.IsNullOrEmpty(binlogPath))
{
binlogPath = Path.Combine(Path.GetDirectoryName(projectFile) ?? "", binlogName);
}

return Run("publish", $"{buildArgs} -bl:\"{binlogPath}\"");
}

public static bool New(string shortName, string outputDirectory, string framework = "")
{
var args = $"{shortName} -o \"{outputDirectory}\"";
Expand Down