Skip to content

Commit

Permalink
Fix example deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Feb 26, 2025
1 parent 99d8124 commit f254a55
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build/PublishBlazorTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public async Task<int> RunAsync(CancellationToken cancellationToken)
var projectPath = Path.Combine("samples", "BlazorWebAssemblyApp");
var publishPath = Path.Combine(projectPath, "bin");
var rootPath = Path.Combine(publishPath, "wwwroot");
Summary($"Root path: {rootPath}");
if (Directory.Exists(rootPath))
{
Directory.Delete(rootPath, true);
}

var result = await new DotNetPublish()
.WithProject(projectPath)
.WithConfiguration("Release")
Expand All @@ -32,7 +38,7 @@ public async Task<int> RunAsync(CancellationToken cancellationToken)
// Change the base-tag in index.html from '/' to 'BlazorWebAssemblyApp' to match GitHub Pages repository subdirectory
var indexFile = Path.Combine(rootPath, "index.html");
var indexContent = await File.ReadAllTextAsync(indexFile, cancellationToken);
indexContent = indexContent.Replace("""<base href="/" />""", """<base href="/Pure.DI/" />""");
indexContent = indexContent.Replace("href=\"/\"", "href=\"/Pure.DI/\"");
await File.WriteAllTextAsync(indexFile, indexContent, cancellationToken);

// Copy index.html to 404.html to serve the same file when a file is not found
Expand Down

0 comments on commit f254a55

Please sign in to comment.