File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939 - name : Publish Blazor WASM app
4040 run : |
4141 REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
42- dotnet publish csharp/PhoneNumbers.Demo/PhoneNumbers.Demo.csproj -c Release -o release -p:StaticWebAssetBasePath =/$REPO_NAME
42+ dotnet publish csharp/PhoneNumbers.Demo/PhoneNumbers.Demo.csproj -c Release -o release -p:PathBase =/${ REPO_NAME}/
4343
4444 - name : Configure for GitHub Pages
4545 run : |
Original file line number Diff line number Diff line change 55 <RootNamespace >PhoneNumbers.Demo</RootNamespace >
66 <Nullable >enable</Nullable >
77 <ImplicitUsings >enable</ImplicitUsings >
8+ <PathBase Condition =" '$(PathBase)' == ''" >/</PathBase >
89 </PropertyGroup >
910
1011 <ItemGroup >
1617 <ProjectReference Include =" ..\PhoneNumbers\PhoneNumbers.csproj" />
1718 </ItemGroup >
1819
20+ <UsingTask TaskName =" ReplaceFileText" TaskFactory =" RoslynCodeTaskFactory" AssemblyFile =" $(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
21+ <ParameterGroup >
22+ <InputFile Required =" true" ParameterType =" System.String" />
23+ <OldText Required =" true" ParameterType =" System.String" />
24+ <NewText Required =" true" ParameterType =" System.String" />
25+ </ParameterGroup >
26+ <Task >
27+ <Code Type =" Fragment" Language =" cs" >
28+ var content = System.IO.File.ReadAllText(InputFile);
29+ if (!content.Contains(OldText))
30+ throw new System.InvalidOperationException($"Could not find '{OldText}' in {InputFile}");
31+ content = content.Replace(OldText, NewText);
32+ System.IO.File.WriteAllText(InputFile, content);
33+ </Code >
34+ </Task >
35+ </UsingTask >
36+
37+ <Target Name =" UpdateBaseHref" AfterTargets =" Publish" Condition =" '$(PathBase)' != '/'" >
38+ <ReplaceFileText InputFile =" $(PublishDir)wwwroot/index.html"
39+ OldText =' < base href="/" /> '
40+ NewText =' < base href="$(PathBase)" /> ' />
41+ </Target >
42+
1943</Project >
You can’t perform that action at this time.
0 commit comments